/*
	(C) Ordning & Reda, 2010
*/

var telRegExp = /([0-9-]+){11}|([0-9]+){10}/; 
var timeRegExp = /^(\d{1,2}):(\d{2})$/;
var emailRegExp = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.([a-zA-Z]){2,4})$/;
var postcodeRegExp = /^([0-9]){4}([a-zA-Z]){2}$/;

/* --- CUFON --- */
Cufon.replace('h1:not(.no_cufon)',{ fontFamily: 'Century Gothic', hover: true});
Cufon.replace('h2:not(.no_cufon)',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('h3:not(.no_cufon)',{ fontFamily: 'Century Gothic', hover: true});
Cufon.replace('h4:not(.no_cufon)',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('.button',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('#header ul',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('#product .product_cart > p',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('#sub_navigation ul',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});
Cufon.replace('#send',{ fontFamily: 'Helvetica Neue LT Pro', hover: true});

//Confirm goto
function confirm_goto(question, url) {
	var cbox= confirm(question);
	if(cbox==true) {
		window.location=url;
	}
}

$(document).ready(function(){
	
});

function fill_cart_top(country){

	$.ajax({
		type: "GET",
		url: ajax_rel_path+"webshop_ajax.php?_ajax_parser=side_cart&lang="+language_id+"&shop_language="+shop_language_id+"&country="+country,
		cache: false,
		success: function(content){
			$('#cart').html(content);
			Cufon.refresh();
		}
	});
}

//DOM ready
$(document).ready(function(){

	fill_cart_top();

	$('a.fancybox').fancybox();	

	//focus op inputs
	$('.focus').each(function(){
		var value = $(this).attr("value");
		$(this).focus(function() {
			if($(this).val() == value){
				$(this).val('');
				$(this).removeClass('focus');
			}
			$(this).addClass('active');
		});
		$(this).blur(function() {
			if($(this).val() == value) {
				$(this).val(value);
				$(this).removeClass('active');
			}
		});
	});
	//Easy Slider
	if($("#slider").length > 0){
		$("#slider").easySlider({
			auto: 			true, 
			//continuous: 	true,
			numeric:		true,
			numericId:		'controls_1',
			controlsBefore:	'<div class="controls">',
			controlsAfter:	'</div>',	
			pause:			10000,
			speed:			500
		});
	}
	
	if($("#slider_twitter").length > 0){
		$("#slider_twitter").easySlider({	
			auto: 			true, 
			continuous: 	true,
			numeric:		true,
			numericId:		'controls_2',
			controlsBefore:	'<div class="controls">',
			controlsAfter:	'</div>',	
			pause:			6000,
			speed:			200
		});
	}
	
	// When page loads...
	$("#slider_tabs_1 .items div").hide(); //Hide all content
	$("#slider_tabs_1 .menu a:first").addClass("active").show(); //Activate first tab
	$("#slider_tabs_1 .items div:first").show(); //Show first tab content
	
	$("#slider_tabs_2 .items div").hide(); //Hide all content
	$("#slider_tabs_2 .menu a:first").addClass("active").show(); //Activate first tab
	$("#slider_tabs_2 .items div:first").show(); //Show first tab content	

	//On Click Event
	$("#slider_tabs_1 .menu a").click(function() {
		$("#slider_tabs_1 .menu a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$("#slider_tabs_1 .items div").hide(); //Hide all tab content

		var activeTab1 = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab1).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	$("#slider_tabs_2 .menu a").click(function() {
		$("#slider_tabs_2 .menu a").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$("#slider_tabs_2 .items div").hide(); //Hide all tab content

		var activeTab2 = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab2).fadeIn(); //Fade in the active ID content
		return false;
	});	
	
});
