/* Regular expressions */
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}$/;
var relpath = "http://77.74.50.99/~viadict";

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

function close_webshop_menu(type){
	if(!$('#'+type).hasClass('active')){
		$('#'+type).hide();
	}
}

//Cufon
Cufon.replace('h1',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('#product_price',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('h2.c',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('#controls h2',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('h3',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('h4',{ fontFamily: 'Franklin Gothic Demi'});

Cufon.replace('.m1 li.head',{ fontFamily: 'Franklin Gothic Demi'});
Cufon.replace('#slider_container',{ fontFamily: 'Franklin Gothic Demi'});

$(document).ready(function(){

	$('.focus').each(function(){
		value = $(this).attr("value");
		$(this).focus(function() {
			if($(this).val() == value){
				$(this).val('');
			}
			$(this).addClass('active');
		});
		$(this).blur(function() {
			if($(this).val() == value || $(this).val() == "" || $(this).val() == " ") {
				$(this).val(value);
				$(this).removeClass('active');
			}
		});
	});
	

	//Easy Slider
	if($("#slider_container").length > 0){
		$("#slider_container").easySlider({
			auto: 			true, 
			continuous: 	true,
			numeric:		true,
			pause:			4000,
			speed:			500
		});
	}
	$("#slider_navigation").hide();
	
	$("#webshop_nav_left .item").hover(function () {$("h3 a", this).css("color", "#F57B20");Cufon.refresh();},function () {$("h3 a", this).css("color", "#454545");Cufon.refresh();});
	$(".menu_expanded .mid ul.m1").hover(function () { $("li.head", this).css("color", "#302c2c");Cufon.refresh();},function () { $("li.head", this).css("color", "#a9a9a9");Cufon.refresh();});
	
	$(".menu_item .head").click(function () { 
		
		$(".m2").slideUp('slow');
		
		var parent = $(this).parent().attr('id');
		
		$(".menu_item").each(function(){
			if(this.id != parent){
				$(this).removeClass("active");	
			}
		});
		
		$(this).next(".m2").stop().slideToggle('slow');

		if($("#"+parent).hasClass('active')){
			$("#"+parent).removeClass('active');		
		} else {
			$("#"+parent).addClass('active');
		}

	});

	//submenu -- item
	//hoogte van de content divs
	var submenu = $("#submenu").height();
	var item = $("#item").height();
	
	//hoogte instellen van de left_content en right_content
	if(submenu > item){
		$("#item").height(submenu);
	} else {
		$("#submenu").height(item);
	}

	
	//webshop menu 2
	
		//functies hoofdmenu items:
			// mouseover
				// - menubox tonen
			// mouseout
				// - hide alle andere menus met de classe active
				// - set een timeout voor het weghalen
				
	
	//start met de mouseover > ik zet de mouseover functie op de menu_box class	
	var thisid = null;
	
	$(".menu_box").mouseover(function(){
		
		//check of this.id ongelijk is aan thisid
		if("menu_"+this.id != thisid && thisid != null) {
			$("#"+thisid).hide();
		}
		
		//het bepalen van de id	> ik heb in header.php even de box waarin het menu staat een id gegeven wat de prefix 'menu_' heeft
		thisid = "menu_"+this.id;
		
		//controleer of er een menu is > zo ja tonen
		if(thisid.length > 0){
			$(this).addClass('active');
			$("#"+thisid).show();
		}
				
	})
	
	$(".menu_expanded").mouseleave(function(){		
			setTimeout("close_webshop_menu('"+this.id+"');",0);
			
			var id = this.id.replace("menu_", "");
			$("#"+id).removeClass('active');
		
	});
	
	//galery winkelinfo
	$("#winkel_navigation li").click(function() {
		var index = $("#winkel_navigation li").index(this);	
		$("#winkel_navigation li img").removeClass("active");
		$("#winkel_navigation li:nth-child("+(index+1)+") img").addClass("active");
		$("#winkel_slider ul").animate({marginLeft: "-"+index*576 }, { duration: 1000});		
	});

	
	
});
