//<![CDATA[

//var sUrl = "http://www.keralit.nl/";
//var sUrl = "http://keralit.cl2-jahzo.nl/";
//var sUrl = "http://93.186.179.238/~keralit/";
//var sUrl = "http://"+window.location.hostname+"/";

var sPreload = "<img src='"+sUrl+"images/preloader.gif' style='vertical-align: middle' /> "+LADEN;

var iSlideshowSpeed = 7000;
var currentSlide = 1;

jQuery(function(){
		 
	jQuery.fn.flush = function(){ return jQuery(this.context).find(this.selector); }  

		//color rollover images
		jQuery(".colorHolder").hover(function() {
										  
		jQuery(this).css({'z-index' : '9999'}); /*Add a higher z-index value so this image stays on top*/ 
		jQuery(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-152px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-75px',
				top: '50%',
				left: '50%',
				width: '150px', /* Set new width */
				height: '150px', /* Set new height */
				padding: '8px'
			}, 200).css({'border' : 'solid 1px #aaa'}); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		jQuery(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		jQuery(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: '57px', /* Set width back to default */
				height: '57px', /* Set height back to default */
				padding: '4px'
			}, 400).css({'border' : 'solid 1px #FFF'});
	});
		
	//load verkoopadressen formulier 
	if(jQuery("#verkoopadressen").length || jQuery("#requestSamples").length || jQuery("#register").length || jQuery("#requestOrder").length || jQuery("#form").length ){
		jQuery("#verkoopadressen, #requestSamples, #register, #requestOrder, #form").validate({					  
		  rules: { 
		  	'adressen[]': { 
				required: true, 
				minlength: 1
			 }, 
			 'folders_brochures[]': { 
				required: true, 
				minlength: 1
			 }, 
			 'geslacht': "required",
			 'bedrijfsnaam': "required",
			 'voorletters': "required", 
			 'achternaam': "required",
			 'straatnaam': "required",
			 'huisnummer': "required",
			 'postcode': "required",
			 'plaats': "required",
			 'land': "required", 
			 'telefoon': {
			  	required: true,
      			digits: true
			 },
			 'akkoord': "required",
			 'btw':"required",
			 'kvk':"required",
			 'werkzaamheden':"required",
			 'emailadres': {
				required: true,
			   email: true
			 }
			 
		   },
		  messages: {

			 'geslacht': "Kies a.u.b. uw aanhef", 
			 'voorletters': dit_veld_is_vereist, 
			 'huisnummer': dit_veld_is_vereist, 
			 'plaats': dit_veld_is_vereist, 
			 'land': dit_veld_is_vereist,
			 'telefoon': {
			   required: dit_veld_is_vereist,
			   digits: 'Geen geldig telefoon nummer'
			 },
			 'postcode': dit_veld_is_vereist, 
			 'achternaam': dit_veld_is_vereist, 
 			 'straatnaam': dit_veld_is_vereist, 
			 'bedrijfsnaam': dit_veld_is_vereist,
			 'postcode': dit_veld_is_vereist, 
			 'btw':dit_veld_is_vereist,
			 'kvk':dit_veld_is_vereist,
			 'werkzaamheden':dit_veld_is_vereist,
			 'emailadres': {
			   required: dit_veld_is_vereist,
			   email: foute_email
			 }
		   },
		   
		   	submitHandler: function(form) {  
				jQuery('#placeRequestSample').unbind('click');
				showPopup("<img src='"+sUrl+"images/preloader.gif' style='vertical-align: middle' /> "+UW_GEGEVENS_WORDEN_VERZONDEN+"");	
				//jQuery(this).parent().prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
				//jQuery(this).css("display","none");
				//jQuery('#verkoopadressen').css("display","none");
				//jQuery('.placerequestsampleholder').prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
				form.submit();
				
		   }
		});
	}
	/*if(jQuery("#requestSamples").length){
		jQuery("#requestSamples").validate({					  
		  rules: { 
		  	'adressen[]': { 
				required: true, 
				minlength: 1
			 }, 
			 'geslacht': "required",
			 'bedrijfsnaam': "required",
			 'voorletters': "required", 
			 'achternaam': "required",
			 'straatnaam': "required",
			 'huisnummer': "required",
			 'postcode': "required",
			 'plaats': "required",
			 'land': "required", 
			 'telefoon': "required",
			 'akkoord': "required",
			 'emailadres': {
				required: true,
			   email: true
			 }
			 
		   },
		  messages: {

			 'geslacht': "Kies a.u.b. uw aanhef", 
			 'voorletters': dit_veld_is_vereist, 
			 'huisnummer': dit_veld_is_vereist, 
			 'plaats': dit_veld_is_vereist, 
			 'land': dit_veld_is_vereist,
			 'telefoon': dit_veld_is_vereist,
			 'postcode': dit_veld_is_vereist, 
			 'achternaam': dit_veld_is_vereist, 
 			 'straatnaam': dit_veld_is_vereist, 
			 'bedrijfsnaam': dit_veld_is_vereist,
			 'postcode': dit_veld_is_vereist, 
 			 'akkoord': "U moet akkoord gaan met de voorwaarden.",
			 'emailadres': {
			   required: dit_veld_is_vereist,
			   email: "Uw e-mailadres moet in de vorm van naam@domein.nl zijn."
			 }
		   },
		   
		   	submitHandler: function(form) {  
			
				//jQuery(this).parent().prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
				//jQuery(this).css("display","none");
				//jQuery(this).parent().prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
				//jQuery(this).css("display","none");
				//jQuery('#verkoopadressen').css("display","none");
				//jQuery('.placerequestsampleholder').prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
				form.submit();
		   }
		});
	}*/
		
	jQuery("textarea").keyup(function(){
		if(jQuery(this).val().length > 400){
			jQuery(this).val(jQuery(this).val().substring(0,400));  
		}
	});
	
	if(jQuery("#tabs").length ) {
		jQuery( "#tabs" ).tabs({
			collapsible: true
		});
	}
	
	if(jQuery("#modellen").length ) {
		jQuery( "#modellen" ).tabs({
			 fx: { opacity: 'toggle' }
		});
	}
	
	$( ".selector" ).tabs({ selected: 3 });	
	
	if(jQuery("input[name=datumgereed]").length) {
		jQuery("input[name=datumgereed]").datepicker({dateFormat: 'yy-mm-dd'});
	}
	
	
	var winHeight = jQuery(window).height();
	var contentHeight = jQuery("#menu").height();
	//alert(contentHeight);

	jQuery("#findProjects input").change(function(){
		jQuery("#findProjects").submit();
	});
	
	jQuery(".selectColor").live("click",function(){

		var parentname = jQuery(this).parent().parent().attr('id');
		var parentid = jQuery(this).parent().parent().attr('id').replace('tabs-','');

		var noChecked = jQuery("#"+parentname+" .selectColor:checked").length;
			var colorarray1 = new Array();
			var colorarray2 = new Array();
		if(noChecked > 3) {  jQuery(this).attr("checked",false); alert(max_kleuren_selecteren);	}
		else { 

			if (parentid =='gevel' || parentid =='model1' || parentid =='model2' || parentid =='model3'){
				
				jQuery("#"+parentname+" .selectColor:checked").each(function(){ colorarray1.push(jQuery(this).attr("name"));	});
				
				var explArray1 = colorarray1.join("|");
				jQuery("#selectedColorsgevel").html(explArray1);

				var titles1 = jQuery("#selectedColorsgevel").html().replace(/\|/g,"<br>");
				jQuery("#colorgevel").html(titles1);

			} else if (parentid =='dakrand'){
				
				jQuery("#"+parentname+" .selectColor:checked").each(function(){ colorarray2.push(jQuery(this).attr("name"));	});
				
				var explArray2 = colorarray2.join("|");
				jQuery("#selectedColors"+parentid).html(explArray2);
				
				var titles2 = jQuery("#selectedColors"+parentid).html().replace(/\|/g,"<br>");
				jQuery("#color"+parentid).html(titles2);
			}
			
			
			
			
		}
		
		jQuery("#doConfirm").css("display","block");
	

		
		return true; 
	});
	
/*	jQuery(".colorNew").live("click",function(){
		
		var noChecked = jQuery(".selectColor:checked").length;
		if(noChecked > 3) {  
			alert('U kunt maximaal 3 kleuren selecteren!');	
		}
		else {
			var currentState = jQuery(this).parent().find(".selectColor").attr("checked");
			if(currentState == true) {	jQuery(this).parent().find(".selectColor").attr("checked",false); }
			else { jQuery(this).parent().find(".selectColor").attr("checked",true);  }
		}
				
	});
*/	
	
/*
	jQuery("#searchProjects").click(function(){
		jQuery("#findProjects").submit();
	});
*/	
	jQuery(".project").live("click",function(){
		var getRealID = jQuery(this).children(":first").attr("id").replace(/[^0-9]+/g,'');
		showProject(getRealID);

	});

	jQuery(".projectThumb").hover(
								 
		 function(){ jQuery(this).stop().fadeTo('fast',0.5); },
		 function(){ jQuery(this).stop().fadeTo('fast',1);}
	);
	
	jQuery(".colorLarge").hover(
		function(){ 
			var titel = jQuery(this).attr("title").replace(verkrijgbaar_in_gevel_dakrand,"");
			var titel = titel.replace(verkrijgbaar_in_gevel,"");
			var titel = titel.replace(verkrijgbaar_in_dakrand,"");
			
			var info = jQuery(this).attr("name");
			
			if(info == "11" || info == "10" || info == "01") { 
				if(info == "11") { var extraInfo = verkrijgbaar_in_gevel_dakrand;	}
				if(info == "10") { var extraInfo = verkrijgbaar_in_gevel;	}
				if(info == "01") { var extraInfo = verkrijgbaar_in_dakrand;	}
			}
			else { var extraInfo = ""; }
			
			jQuery("#colorTitle").html("<b>Naam: "+titel+"</b><br />"+extraInfo).css("color","#0b4771");
		},
		function(){ 
			jQuery("#colorTitle").html("Rol over een kleur voor meer informatie...").css("color","#a0a0a0");
		}
	);
	
	
	jQuery("#nextProject").live("click",function(){
		var currentSlide = parseInt(jQuery("#currentDisplayedProject").val());
		var total = parseInt(jQuery("#totalNoOfProjects").val());
		if(currentSlide < total) {
			showProject(parseInt(currentSlide + 1));
		}
	});
	
	jQuery("#prevProject").live("click",function(){
		var currentSlide = parseInt(jQuery("#currentDisplayedProject").val());
		var total = parseInt(jQuery("#totalNoOfProjects").val());
		if(currentSlide > 1) {
			showProject(parseInt(currentSlide - 1));
		}
	});
	
	function showProject(slideID) {
		
		var getRealID = jQuery("#projectImg"+slideID).parent().attr("id").replace(/[^0-9]+/g,'');
		var currentLang = jQuery("#lang").val();
		
		jQuery("#selectedProject").val(slideID);
		jQuery("#contentLoader").css("display","block");
		
		if(jQuery("#projectInfo").length) { jQuery("#projectInfo").html("<img style='margin: 220px 0 0 200px;' src='images/preloadProject.gif' />");	}
		else {	jQuery("body").append("<div id='projectInfo'><img style='margin: 220px 0 0 200px;' src='images/preloadProject.gif' /></div>"); }
		
		jQuery.ajax({
			url: 		sUrl+"includes/getProject.php",
			type: 		"get",
			data: 		{ id: getRealID, lang: currentLang, noSlide: slideID, totalNoSlides: jQuery("#totalNoOfProjects").val() },
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
				
					
					//if(jQuery("#projectInfo").length) {	
					jQuery("#projectInfo").html(data);	
					//}
					//else {	jQuery("body").append("<div id='projectInfo'>"+data+"</div>");	}
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' '+ MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html(SERVER_ERROR); } 
				else { jQuery("#submenu_content").html(ONBEKEND_ERROR);	}
			}
		});	
		
	}
	
	
	jQuery("input[type='radio'][name='typeklant']").click(function(){
		var selectedType = jQuery(this).val();
		if(selectedType == "bedrijf") {
			jQuery("#bedrijfsnaamTitel").css("color","#2a3a53");
			jQuery("input[type='text'][name='bedrijfsnaam']").css("background-color","#ffffff").attr("disabled",false).parent().prev().css({"color":"#2a3a53"});
		}
		else {
			jQuery("#bedrijfsnaamTitel").css("color","#a0a0a0");
			jQuery("input[type='text'][name='bedrijfsnaam']").css("background-color","#e9e9e9").attr("disabled",true).parent().prev().css({"color":"#a0a0a0"});
		}
	});
	


	jQuery("#footerlogo").click(function(){
		var current = parseInt(jQuery("#currentSlide").val()) + 1;
		showSlide(current);
	})
	
	jQuery("#contentLoader, #closeProject").live("click",function(){
		jQuery("#projectInfo").remove().flush();
		jQuery("#colorInfo").remove().flush();
		jQuery("#dealerLoginBox").remove().flush();
		jQuery("#popupBox").remove().flush();
		jQuery("#popupBoxComplete").remove().flush();
		jQuery("#contentLoader").css("display","none");	
	});
	
	jQuery("#dealerLogin, #klantAdressen").click(function(){
		jQuery.ajax({
			url: 		sUrl+"includes/getDealerLoginBox.php",
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='dealerLoginBox'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
					jQuery("#dealerEmail").focus();
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' '+ MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html(SERVER_ERROR); } 
				else { jQuery("#submenu_content").html(ONBEKEND_ERROR);	}
			}
		});	
	});
	jQuery("#promo").click(function(){
		jQuery.ajax({
			url: 		sUrl+"includes/getDealerLoginBox.php?dealer=hbh",
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='dealerLoginBox'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
					jQuery("#dealerEmail").focus();
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' '+ MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html(SERVER_ERROR); } 
				else { jQuery("#submenu_content").html(ONBEKEND_ERROR);	}
			}
		});	
	});
	
	jQuery("#dealerLogout").click(function(){
		var conf = confirm("Weet u zeker dat u wilt uitloggen?");
		if(conf == true) {
			window.location.assign(sUrl+"nl/professionals/uitloggen/");
		}
	});
	
	
	
	function checkFields() {
		var emailReg = /^[A-Za-z0-9]{1,}$/;
		if(emailReg.test(jQuery("#submitDealerLogin input[name='emailadres']").val()) && jQuery("#submitDealerLogin input[name='wachtwoord']").val() !== '') { jQuery("#submitDealerLogin").submit(); 	}
		else { jQuery("#loginError").html(LEEG); }
	}
	
	jQuery("#submitDealerLogin input").live("keypress",function(e){
		if(e.which == 13){	checkFields();	}
	});
		
	jQuery("#voltooid").live("click",function(){ 

		var error = 0;

		if(jQuery("#akkoordVoltooien").attr("checked") == false) {
			jQuery("#error").html("U dient akkoord te gaan!");
			error++;

		}
		if(jQuery("input[type='radio']:checked").length == 0) {
			jQuery("#error").html("U dient een reden van voltooiing te selecteren!");
			error++;
		}
	//alert(jQuery("textarea[name='opmerking']").val());
		if(jQuery("textarea[name='opmerking']").val() == "") {			
			jQuery("#error").html("U dient een reden op te geven!");
			jQuery("textarea[name='opmerking']").css("border","1px solid red");
			error++;
		}
		
		
		if(error == 0) {
			jQuery("#submitCompleteOrder").submit();	
		}
	});
	
	jQuery("#geannuleerd").live("click",function(){ 
											  
		if(jQuery("#akkoordAnnuleren").attr("checked") == false) {
			jQuery("#error").html(AKKOORD_ERROR);
		}
		else {
			jQuery("#submitCancelOrder").submit();	
		}
	});
	
	jQuery("#geopteerd").live("click",function(){ 
											  
		if(jQuery("#akkoordOpteren").attr("checked") == false) {
			jQuery("#error").html(AKKOORD_ERROR);
		}
		else {
			jQuery("#submitClaimOrder").submit();	
		}
	});
	

	
	jQuery("#loginDealer").live("click",function(){ checkFields(); });
	
	/*jQuery(".row").hover(
		function(){ jQuery(this).css("background","#cccccc"); jQuery(this).next().css("background","#cccccc"); },
		function(){ jQuery(this).css("background","#ffffff"); jQuery(this).next().css("background","#ffffff"); }
	);
	*/
	/*
	jQuery(".smallBtn").mousedown(function(){ jQuery(this).css({"margin-top":"0px","margin-right":"1px"}); });
	jQuery(".smallBtn").mouseup(function(){ jQuery(this).css({"margin-top":"0px","margin-right":"0px"}); });
	css("color","#cccccc")
	.css("color","#171b40")
	*/
	
	function collapseAllSamples() {
		jQuery("img[id^='arrowaanvraag']").attr("src","images/arrow_down.gif");
		//jQuery("tr[class^='rowaanvraag']").children().fadeTo(0,1);
		//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().css("color","#171b40");
		jQuery("div[id^='aanvraagInfo']").slideUp('fast', function(){ jQuery(this).html(""); });
	//	jQuery("div[id^='aanvraagInfo']").css('display','none');
	}


	function collapseAllOrders() {
		jQuery("img[id^='arrowofferte']").attr("src","images/arrow_down.gif");
		//jQuery("tr[class^='rowaanvraag']").children().fadeTo(0,1);
		//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().css("color","#171b40");
		jQuery("div[id^='offerteInfo']").slideUp('fast', function(){ jQuery(this).html(""); });
	//	jQuery("div[id^='aanvraagInfo']").css('display','none');
	}


	jQuery("tr[class^='rowaanvraag']").click(
		function(event){
			
			//|| tgt.is("img")
			var tgt = jQuery(event.target);
			if(tgt.is("input[@type='checkbox']")) { 
				// do nothing
			}
			else {
				
				// already claimed?
				var src = jQuery(this).children(":last").find("img").attr("class");
				
				var currentID = jQuery(this).attr("className").replace("rowaanvraag","");
				var infoBox ="#aanvraagInfo"+currentID;
				
				collapseAllSamples();
				
				if(jQuery("#aanvraagInfo"+currentID).css("display") == "none") {
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().fadeTo(0,0.3);
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().css("color","#cccccc");
					jQuery("#arrowaanvraag"+currentID).attr("src","images/preloader_small.gif");
					
					jQuery.ajax({
						url: 		sUrl+"includes/getOrderInfo.php",
						data: 		{ id: currentID, type: "A", status: src },
						type: 		"get",
						dataType:	"html",
						timeout:	20000,
						tryCount: 	0,
						retryLimit:	3,
						success: 	function(data) {
							if(data !== "error") { 
								jQuery(infoBox).html(data).slideDown('fast');
								jQuery("#arrowaanvraag"+currentID).attr("src","images/arrow_up.gif");
							}
						},
						error: 		function(xhr, textStatus, errorThrown ) {
							if (textStatus == 'timeout') {
								this.tryCount++;
								if (this.tryCount <= this.retryLimit) {
								//try again
								jQuery.ajax(this);
								return;
							}
							jQuery(infoBox).html('' + this.retryLimit + ' '+MISLUKT);
								return;
							}
							if (xhr.status == 500) { jQuery(infoBox).html(SERVER_ERROR); } 
							else { jQuery(infoBox).html(ONBEKEND_ERROR);	}
						}
					});	
					
					
					
					
//					jQuery(infoBox).css('display','block');
				}
			
			
			}
		}
	);
	
	jQuery("tr[class^='rowofferte']").click(
		function(event){
			
			var tgt = jQuery(event.target);
			if(tgt.is("input[@type='checkbox']")) { 
				// do nothing
			}
			else {
				
				// already claimed?
				var src = jQuery(this).children(":last").find("img").attr("class");
				var currentID = jQuery(this).attr("className").replace("rowofferte","");
				var infoBox ="#offerteInfo"+currentID;
				
				collapseAllOrders();
				
				if(jQuery("#offerteInfo"+currentID).css("display") == "none") {
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().fadeTo(0,0.3);
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().css("color","#cccccc");
					jQuery("#arrowofferte"+currentID).attr("src","images/preloader_small.gif");
					
					jQuery.ajax({
						url: 		sUrl+"includes/getOrderInfo.php",
						data: 		{ id: currentID, type: "O", status: src },
						type: 		"get",
						dataType:	"html",
						timeout:	20000,
						tryCount: 	0,
						retryLimit:	3,
						success: 	function(data) {
							if(data !== "error") { 
								jQuery(infoBox).html(data).slideDown('fast');
								
								jQuery(infoBox+' .infoimg a').lightBox();
								
								
								jQuery("#arrowofferte"+currentID).attr("src","images/arrow_up.gif");
							}
						},
						error: 		function(xhr, textStatus, errorThrown ) {
							if (textStatus == 'timeout') {
								this.tryCount++;
								if (this.tryCount <= this.retryLimit) {
								//try again
								jQuery.ajax(this);
								return;
							}
							jQuery(infoBox).html('' + this.retryLimit + ' '+MISLUKT);
								return;
							}
							if (xhr.status == 500) { jQuery(infoBox).html(SERVER_ERROR); } 
							else { jQuery(infoBox).html(ONBEKEND_ERROR);	}
						}
					});	
					
					
					
					
//					jQuery(infoBox).css('display','block');
				}
			
			
			}
		}
	);
	
	jQuery("tr[class^='rowkrb']").click(
		function(event){
				
				// already claimed?
				var src = jQuery(this).children(":last").find("img").attr("class");
				var currentID = jQuery(this).attr("className").replace("rowofferte","");
				var infoBox ="#offerteInfo"+currentID;
				
				collapseAllOrders();
				
				if(jQuery("#offerteInfo"+currentID).css("display") == "none") {
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().fadeTo(0,0.3);
					//jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).children().css("color","#cccccc");
					jQuery("#arrowofferte"+currentID).attr("src","images/preloader_small.gif");
					
					jQuery.ajax({
						url: 		sUrl+"includes/getOrderInfo.php",
						data: 		{ id: currentID, type: "O", status: src },
						type: 		"get",
						dataType:	"html",
						timeout:	20000,
						tryCount: 	0,
						retryLimit:	3,
						success: 	function(data) {
							if(data !== "error") { 
								jQuery(infoBox).html(data).slideDown('fast');
								jQuery("#arrowofferte"+currentID).attr("src","images/arrow_up.gif");
							}
						},
						error: 		function(xhr, textStatus, errorThrown ) {
							if (textStatus == 'timeout') {
								this.tryCount++;
								if (this.tryCount <= this.retryLimit) {
								//try again
								jQuery.ajax(this);
								return;
							}
							jQuery(infoBox).html('' + this.retryLimit + ' '+MISLUKT);
								return;
							}
							if (xhr.status == 500) { jQuery(infoBox).html(SERVER_ERROR); } 
							else { jQuery(infoBox).html(ONBEKEND_ERROR);	}
						}
					});	
					

			}
		}
	);
	
	function collapseAllOfferte() {
		jQuery("img[id^='arrowofferte']").attr("src","images/arrow_down.gif");
		jQuery("tr[class^='rowofferte']").children().fadeTo(0,1);
		jQuery("div[id^='offerteInfo']").slideUp('fast');
		//jQuery("div[id^='aanvraagInfo']").css('display','none');
	}
	
/*	jQuery("tr[class^='rowofferte']").click(
		function(event){
			
			var tgt = jQuery(event.target);
			if(tgt.is("input[@type='checkbox']") || tgt.is("img")) { 
				// do nothing
			}
			else {
						
				var currentID = jQuery(this).attr("className").replace("rowofferte","");
				var infoBox ="#offerteInfo"+currentID;
				
				collapseAllOfferte();
				
				if(jQuery("#offerteInfo"+currentID).css("display") == "none") {
					jQuery("tr[class^='rowofferte']").not(jQuery(this)).children().fadeTo(0,0.3);
					jQuery("#arrowofferte"+currentID).attr("src","images/arrow_up.gif");
					jQuery(infoBox).slideDown('fast');
				}
			
			}
		}
	);*/
	
	/*
	
	,
		function(){
			jQuery("tr[class^='rowaanvraag']").not(jQuery(this)).fadeTo('fast',1);
			var currentClass = jQuery(this).attr("className");
			var currentID = jQuery(this).attr("className").replace("rowaanvraag","");
			var infoBox ="#aanvraagInfo"+currentID;
			jQuery("#arrowaanvraag"+currentID).attr("src","images/arrow_down.gif");
			jQuery(infoBox).slideUp('fast');
		}
	
	  jQuery.ajax({
			url: 		sUrl+"includes/getAanvraagInfo.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					 
					 var infoBox ="#aanvraagInfo"+currentID;
					 jQuery(infoBox).hide().html(data).slideDown('fast');
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' maal mislukt. Probeer het nog eens...');
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html('Oeps! Er lijkt een serverprobleem te zijn, probeer het later nog eens.'); } 
				else { jQuery("#submenu_content").html('Oeps! Er is een probleem opgetreden, sorry.');	}
			}
		});	
	  */
	jQuery(".tabletrheader").click(function(){
		var currentID = jQuery(this).attr("id");
		jQuery("#table_"+currentID).toggle();
		
		
		if (jQuery("#table_"+currentID+" tbody").length){
			//
		} else {
			jQuery("#table_"+currentID).append('<tbody><tr><td colspan="13"><img src="images/loading.gif"/>'+LADEN+'</td></tr></tbody>');
			jQuery.ajax({
			url: 		sUrl+"includes/getDealerList.php",
			data: 		{type: currentID},
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
				//alert('success');	
					jQuery("#table_"+currentID+" tbody").html(data);
						//jQuery("#table_"+currentID).tablesorter().tablesorterPager({container: $("#pager")});
						
						jQuery("#table_"+currentID)
							.tablesorter() 
							.tablesorterPager({container: jQuery("#pager_"+currentID)}); 
						
						
						jQuery("#table_"+currentID).bind("sortStart",function() { 
							jQuery("#table_"+currentID+" th.dealer").html(EEN_OGENBLIK); 
						}).bind("sortEnd",function() { 
						   jQuery("#table_"+currentID+" th.dealer").html('Dealer'); 
						});
						
						jQuery("#pager_"+currentID).toggle();
					
				} else {
					alert('error');	
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
							jQuery(infoBox).html('' + this.retryLimit + ' '+MISLUKT);
								return;
							}
							if (xhr.status == 500) { jQuery(infoBox).html(SERVER_ERROR); } 
							else { jQuery(infoBox).html(ONBEKEND_ERROR);	}
			}
		});		
		}
	})
	
	jQuery("div[id^='voltooiO'],div[id^='voltooiM']").live("click",function(){
		var currentID = jQuery(this).attr("id").replace("voltooi","");
		//showPopup("");
		showPopupComplete("");
		
	//	jQuery('#popupBox').html("<div style='margin: 25px 25px 0 25px;'>"+sPreload+"</div>");
		jQuery('#popupBoxComplete').html("<div style='margin: 25px 25px 0 25px;'>"+sPreload+"</div>");
		
		
		
		jQuery.ajax({
			url: 		sUrl+"includes/getCompleteOrderForm.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			success: 	function(data) {
							jQuery('#popupBoxComplete').html(data);
							Cufon.replace('h2', {fontFamily: 'MyriadPro' });
						}
		});

		
	//	var conf = confirm('Weet u zeker dat u deze aanvraag wilt completeren?\nHierna wordt deze verwijderd uit uw lijst.');
	//	if(conf == true) {
		
	//	console.debug('test');
	/*	
		jQuery.ajax({
			url: 		sUrl+"includes/completeOrder.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					 
					 var infoBox ="#aanvraagInfo"+currentID;
					 jQuery(infoBox).hide().html(data).slideDown('fast');
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' maal mislukt. Probeer het nog eens...');
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html('Oeps! Er lijkt een serverprobleem te zijn, probeer het later nog eens.'); } 
				else { jQuery("#submenu_content").html('Oeps! Er is een probleem opgetreden, sorry.');	}
			}
		});	
		*/
	//	}	
		
	});


	jQuery("div[id^='annuleerO'],div[id^='annuleerM']").live("click",function(){
		var currentID = jQuery(this).attr("id").replace("annuleer","");
		
		showPopup("");
		
		jQuery('#popupBox').html("<div style='margin: 25px 25px 0 25px;'>"+sPreload+"</div>");
		
		jQuery.ajax({
			url: 		sUrl+"includes/getCancelOrderForm.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			success: 	function(data) {
							jQuery('#popupBox').html(data);
							Cufon.replace('h2', {fontFamily: 'MyriadPro' });
						}
		});

		
	//	var conf = confirm('Weet u zeker dat u deze aanvraag wilt completeren?\nHierna wordt deze verwijderd uit uw lijst.');
	//	if(conf == true) {
		
	//	console.debug('test');
	/*	
		jQuery.ajax({
			url: 		sUrl+"includes/completeOrder.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					 
					 var infoBox ="#aanvraagInfo"+currentID;
					 jQuery(infoBox).hide().html(data).slideDown('fast');
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' maal mislukt. Probeer het nog eens...');
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html('Oeps! Er lijkt een serverprobleem te zijn, probeer het later nog eens.'); } 
				else { jQuery("#submenu_content").html('Oeps! Er is een probleem opgetreden, sorry.');	}
			}
		});	
		*/
	//	}	
		
	});
	
	
//	jQuery("img[className^='claimO'],img[className^='claimM']").click(function(){
	jQuery("img.claimO, img.claimM").click(function(){
		var currentID = jQuery(this).attr("id");
		
		showPopup("");
		
		jQuery('#popupBox').html("<div style='margin: 25px 25px 0 25px;'>"+sPreload+"</div>");
		
		jQuery.ajax({
			url: 		sUrl+"includes/getClaimOrderForm.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			success: 	function(data) {
							jQuery('#popupBox').html(data);
							Cufon.replace('h2', {fontFamily: 'MyriadPro' });
						}
		});

	


		
	//	var conf = confirm('Weet u zeker dat u deze aanvraag wilt completeren?\nHierna wordt deze verwijderd uit uw lijst.');
	//	if(conf == true) {
		
	//	console.debug('test');
	/*	
		jQuery.ajax({
			url: 		sUrl+"includes/completeOrder.php",
			data: 		{ id: currentID },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					 
					 var infoBox ="#aanvraagInfo"+currentID;
					 jQuery(infoBox).hide().html(data).slideDown('fast');
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery("#submenu_content").html('' + this.retryLimit + ' maal mislukt. Probeer het nog eens...');
					return;
				}
				if (xhr.status == 500) { jQuery("#submenu_content").html('Oeps! Er lijkt een serverprobleem te zijn, probeer het later nog eens.'); } 
				else { jQuery("#submenu_content").html('Oeps! Er is een probleem opgetreden, sorry.');	}
			}
		});	
		*/
	//	}	
		
	});
	jQuery("#changePass").click(function(){
		//jQuery("#changePassForm").parent().append("<tr><td>WW1</td><td><input type='password' value='fffff'></td></tr>");
		jQuery(this).css("display","none");
		jQuery("<tr><td style='padding: 2px 0 2px 0'>Oud wachtwoord</td><td style='padding: 2px 0 2px 0'><input type='password' name='oldpassword' value='' style='width: 220px;'></td></tr><tr><td style='padding: 2px 0 2px 0'>Nieuw wachtwoord</td><td style='padding: 2px 0 2px 0'><input class='newPw' type='password' name='password1' value='' style='width: 220px;'></td></tr><tr><td style='padding: 2px 0 2px 0'>Nogmaals</td><td style='padding: 2px 0 2px 0'><input class='newPw' type='password' name='password2' value='' style='width: 220px;'></td></tr>").insertAfter(jQuery(this).parent().parent().parent());
		
	});
	
	
	
	jQuery("#submitSettingsForm").click(function(){
		
		var errors = 0;
		
		// New pw?
		var newpw = jQuery(".newPw").length;
		
		if(newpw == 2) {
			//do they match?
			var val1 = jQuery(".newPw:first").val();
			var val2 = jQuery(".newPw:last").val();
			
			if(val1 == '' && val2 == '') {
				alert('U hebt geen nieuw wachtwoord ingevuld!');
				errors = 1;
			}
			else if(val1 != val2 && val1 != '' && val2 != '') {
				alert('De nieuwe wachtwoorden komen niet overeen!');
				errors = 1;
			}			
		}
		
		if(errors == 0) {
			jQuery("#updateSettings").submit();
		}
														 
	});
	
/*	
	var top = jQuery.(document.body).children(0).position().top;
	$window.scroll(function () {
		window.clearTimeout(scroll_timer);
		scroll_timer = window.setTimeout(function () {
			if(window.scrollTop() <= top)
			{
				displayed = false;
				jQuery("#toTop").fadeOut(500);
			}
			else if(displayed == false)
			{
				displayed = true;
				jQuery("#toTop").stop(true, true).show().click(function () { jQuery("#toTop").fadeOut(500); });
			}
		}, 100);
	});
*/	
	
//	jQuery("#toTop").click(function(){
		//var top = jQuery(document.body).children(0).position().top;
//		window.scrollTo(0, 0);
//	})


//	var elem = jQuery('body');
				
//	$('#nav_up').fadeIn('slow');
//	$('#nav_down').fadeIn('slow');  
	/*
	jQuery(window).bind('scrollstart', function(){
		jQuery('#toTop').css("display","block");
	});
	jQuery(window).bind('scrollstop', function(){
		jQuery('#toTop').css("display","none");
	});
	*/
/*	jQuery('#nav_down').click(
		function (e) {
			jQuery('html, body').animate({scrollTop: $elem.height()}, 800);
		}
	);
*/
	

	
//	function showScrollToTop(){
//		var docHeight = jQuery(document).height();
//		var scroll    = jQuery(window).height() + jQuery(window).scrollTop();
		//	alert("docheight: "+docHeight+", scroll: "+scroll);
//		if(scroll < docHeight) { jQuery("#toTop").css("display","block"); }
//	}

//	showScrollToTop();	
//	jQuery(window).resize(function() {	showScrollToTop();	});
	
	jQuery("#scrollToTop").click(
		function(e) {
			if(jQuery.browser.safari || jQuery.browser.opera){ bodyelem = jQuery("body"); } else{ bodyelem = jQuery("html,body"); }
			bodyelem.animate({scrollTop: "0px"}, 300);
		}
	);
		
	jQuery("#scrollToBottom").click(
		function(e) {
			if(jQuery.browser.safari || jQuery.browser.opera){ bodyelem = jQuery("body"); } else{ bodyelem = jQuery("html,body"); }
			bodyelem.animate({scrollTop: jQuery("#subpage_overlay_extranet").height()+"px"}, 300);
		}
	);
	
	jQuery(".claimOptie").click(function(){	alert('U heeft al een optie op deze aanvraag!'); });
	jQuery(".claimVol").click(function(){	alert('Het maximum aantal opties op deze aanvraag is bereikt!'); });
	jQuery(".maxbereikt").click(function(){	alert('Uw maximum aantal opties is bereikt!'); });
	
	
	if(jQuery("#toTop").length) {
		var $sidebar   = jQuery("#toTop"),
		$window    = jQuery(window),
		offset     = $sidebar.offset(),
		topPadding = 50;
	
		$window.scroll(function() {
			if ($window.scrollTop() > offset.top) {
				$sidebar.stop().animate({
					marginTop: $window.scrollTop() - offset.top + topPadding
				},500);
			} else {
				$sidebar.stop().animate({
					marginTop: 0
				},500);
			}
		});
	}
//kies kleuren
   var new_page =  window.location.href;
   var char_pos = new_page.search("#");
   new_page = new_page.substring(char_pos);
	if (new_page == "#kleuren"){
		
		var oldvalue = jQuery(".chooseColor").html();
		jQuery(this).html("<img src='"+sUrl+"images/preloader_small.gif' style='vertical-align: middle' /> Kleuren laden...");
		
		var type = jQuery(".chooseColor").attr("id");
		var selected = jQuery(".chooseColor").attr("id").replace(/[^0-9]+/g,'');
		
		if(type == "colorgevel") {	var selectedProds = jQuery("#selectedgevelpanelen").val();	}
		if(type == "colordakrand") { var selectedProds = jQuery("#selecteddakrandpanelen").val();	}
		
		jQuery.ajax({
			url: 		sUrl+"includes/getColors.php",
			data: 		{ no: selected, type: type, selected: selectedProds },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					//jQuery('#popupBox').html(data);
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='colorInfo'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
					jQuery("#"+type).html(oldvalue);
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#popupBox').html('' + this.retryLimit + ' '+MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery('#popupBox').html(SERVER_ERROR); } 
				else { jQuery('#popupBox').html(ONBEKEND_ERROR);	}
			}
		});	
		
		
		
		
		//jQuery(this).append("<div style='position: absolute; top: "+posTop+"px; left: 400px; width: 300px; height: 200px; border: 1px solid; background: yellow'>test</div>");
	
	}

	if (new_page == "#dakrand"){
		
		
		jQuery( "#tabs" ).tabs( "option", "selected", 1 );
	
	}
	
	jQuery(".kleurpopup").click(function(){
		
	
		var type = jQuery(this).attr("id");
		var selected = jQuery(this).attr("id").replace(/[^0-9]+/g,'');
		
		if(type == "colorgevel") {	var selectedProds = jQuery("#selectedgevelpanelen").val();	}
		if(type == "colordakrand") { var selectedProds = jQuery("#selecteddakrandpanelen").val();	}
		
		jQuery.ajax({
			url: 		sUrl+"includes/getColors.php",
			data: 		{ no: selected, type: type, selected: selectedProds },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					//jQuery('#popupBox').html(data);
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='colorInfo'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#popupBox').html('' + this.retryLimit + ' '+MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery('#popupBox').html(SERVER_ERROR); } 
				else { jQuery('#popupBox').html(ONBEKEND_ERROR);	}
			}
		});	
		
		
		
		
		//jQuery(this).append("<div style='position: absolute; top: "+posTop+"px; left: 400px; width: 300px; height: 200px; border: 1px solid; background: yellow'>test</div>");
	});
/*	
	jQuery(".chooseColor").click(function(){
		
		var oldvalue = jQuery(this).html();
		jQuery(this).html("<img src='"+sUrl+"images/preloader_small.gif' style='vertical-align: middle' /> Kleuren laden...");
		
		var type = jQuery(this).attr("id");
		var selected = jQuery(this).attr("id").replace(/[^0-9]+/g,'');
		
		if(type == "colorgevel") {	var selectedProds = jQuery("#selectedgevelpanelen").val();	}
		if(type == "colordakrand") { var selectedProds = jQuery("#selecteddakrandpanelen").val();	}
		if(type == "colorgevel1") {	var selectedProds = jQuery("#selectedgevelpanelen").val();	}
		if(type == "colordakrand1") { var selectedProds = jQuery("#selecteddakrandpanelen").val();	}
		
		jQuery.ajax({
			url: 		sUrl+"includes/getColors.php",
			data: 		{ no: selected, type: type, selected: selectedProds },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					//jQuery('#popupBox').html(data);
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='colorInfo'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
					jQuery("#"+type).html(oldvalue);
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#popupBox').html('' + this.retryLimit + ' maal mislukt. Probeer het nog eens...');
					return;
				}
				if (xhr.status == 500) { jQuery('#popupBox').html('Oeps! Er lijkt een serverprobleem te zijn, probeer het later nog eens.'); } 
				else { jQuery('#popupBox').html('Oeps! Er is een probleem opgetreden, sorry.');	}
			}
		});	
		
		
		
		
		//jQuery(this).append("<div style='position: absolute; top: "+posTop+"px; left: 400px; width: 300px; height: 200px; border: 1px solid; background: yellow'>test</div>");
	});*/
	
	jQuery(".color").live("mouseenter", function(){	
		//var title = jQuery(this).attr("title"); 
		jQuery(this).css("border","2px solid #000");
		//jQuery("#colorTitle").html(title); 
	});

	jQuery(".color").live("mouseleave", function(){	
		jQuery(this).css("border","2px solid #fff");
	});
	
	jQuery(".color").live("click", function(){	
		jQuery(".color").not(this).removeClass("color").addClass("nonColor").fadeTo(0,0.5);
		jQuery(this).removeClass("color").addClass("selectedColor");
		var title = jQuery(this).attr("title");
		jQuery("#colorTitle").html(title+"<br /><span style='color: #a6a6a6'>"+ANDER_KLEUR+"</span>"); 
	});
	
	
	jQuery(".selectedColor").live("click", function(){	
		jQuery("#colorTitle").html("");
		jQuery(".nonColor").removeClass("nonColor").addClass("color").fadeTo(0,1);
		jQuery(this).css("border","2px solid #fff").removeClass("selectedColor").addClass("color");
	});
	
	jQuery("#kiesKleur").live("click", function(){
		
	});
	
	jQuery("#placeRegister").click(function(){
/*		jQuery(this).parent().prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');
		jQuery(this).css("display","none");*/
		jQuery("#register").submit();
	});
	
	jQuery("#placeRequestSample").click(function(){
		//alert(jQuery(".chooseColor").html());
		
		var noChecked = jQuery(".selectColor:checked").length;
		var currentLang = jQuery("#lang").val();
		if(noChecked > 0) {	
			jQuery("#requestSamples").submit();
		}
		else {
			var conf = alert('U heeft geen kleuren geselecteerd!\nSelecteer minstens 1 kleur.');
			if(conf == true) {
				
				if(selectedType == "gevelpanelen") {	
					jQuery("#colorgevel").html("");
					jQuery("#colorgevel").css({"display":"inline","margin-bottom":"0px"}).html(KIES_KLEUREN); 
				}
				if(selectedType == "dakrandpanelen") {	
					jQuery("#colordakrand").html("");
					jQuery("#colordakrand").css({"display":"inline","margin-bottom":"0px"}).html(KIES_KLEUREN); 
				}
			}
		}
		
		
	});
	
	jQuery("#verkoopadresSubmit").live("click", function(){	
		jQuery("#verkoopadressen").submit();
	});
	
	jQuery("#placeRequestPromos").click(function(){						 
		jQuery("#requestPromos").submit();
	});
		
	jQuery("#placeRequestOrder").click(function(){
		//showPopup("<img src='"+sUrl+"images/preloader.gif' style='vertical-align: middle' /> "+UW_GEGEVENS_WORDEN_VERZONDEN+"");										
		jQuery("#requestOrder").submit();
	});
	
	jQuery("#submitForm").click(function(){
		jQuery(this).parent().prepend('<div style="float: right;  margin-right: 5px;  margin-top: 12px;"> '+EEN_OGENBLIK+'</div>');											 
		jQuery(this).css("display","none");								 
		jQuery("#sendForm").submit();
	});
	
	jQuery("#verstuurformulier").click(function(){
		jQuery("#form").submit();	
	});
	
	
	
	
	
	jQuery("#showOfferteVoorwaarden").click(function(){
		jQuery.ajax({
			url: 		sUrl+"includes/getConditions.php",
			data:		{ type: "offerte"},
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					//jQuery('#popupBox').html(data);
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='projectInfo'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#popupBox').html('' + this.retryLimit + ' '+MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery('#popupBox').html(SERVER_ERROR); } 
				else { jQuery('#popupBox').html(ONBEKEND_ERROR);	}
			}
		});	
	});
	
	jQuery("#showClaimVoorwaarden").click(function(){
		jQuery.ajax({
			url: 		sUrl+"includes/getConditions.php",
			data:		{ type: "claim"},
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					//jQuery('#popupBox').html(data);
					jQuery("#contentLoader").css("display","block");
					jQuery("body").append("<div id='projectInfo'>"+data+"</div>");
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#popupBox').html('' + this.retryLimit + ' '+MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery('#popupBox').html(SERVER_ERROR); } 
				else { jQuery('#popupBox').html(ONBEKEND_ERROR);	}
			}
		});	
	});
	
	jQuery("#sentSuccesfull, #sentNotFilled").delay(18000).slideUp("normal");
	
	jQuery("#chooseProv").change(function(){
				
		var selectedProv = jQuery(this).val();
		var provImg = "images/prov_"+selectedProv+".gif";		
		jQuery("#kaartProv").attr("src",provImg);
		
		jQuery('#foundDealers').html(sPreload);
		
		jQuery.ajax({
			url: 		sUrl+"includes/getDealers.php",
			data:		{ provincie: selectedProv },
			type: 		"get",
			dataType:	"html",
			timeout:	20000,
			tryCount: 	0,
			retryLimit:	3,
			success: 	function(data) {
				if(data !== "error") { 
					
					jQuery("#foundDealers").html(data);
					Cufon.replace('h2', {fontFamily: 'MyriadPro' });
				}
			},
			error: 		function(xhr, textStatus, errorThrown ) {
				if (textStatus == 'timeout') {
					this.tryCount++;
					if (this.tryCount <= this.retryLimit) {
					//try again
					jQuery.ajax(this);
					return;
				}
				jQuery('#foundDealers').html('' + this.retryLimit + ' '+MISLUKT);
					return;
				}
				if (xhr.status == 500) { jQuery('#foundDealers').html(SERVER_ERROR); } 
				else { jQuery('#foundDealers').html(ONBEKEND_ERROR);	}
			}
		});	
	});
	
	
	var mpw = jQuery("#mainpagewrapper").height();
	var spb = jQuery("#subpage_bar").height();
	
	if(mpw < spb) { jQuery("#mainpagewrapper").height(spb); }
	
});

function showPopup(data) {
	jQuery("#contentLoader").css("display","block");
	jQuery("body").append("<div id='popupBox'><div style='margin: 25px 25px 0 25px;'>"+data+"</div></div>");
}


function showPopupComplete(data) {
	jQuery("#contentLoader").css("display","block");
	jQuery("body").append("<div id='popupBoxComplete'><div style='margin: 25px 25px 0 25px;'>"+data+"</div></div>");
}



function showPopupMessage(title,text) {
	jQuery("#contentLoader").css("display","block");
	
	jQuery.ajax({
		url: 		sUrl+"includes/fillPopup.php",
		data: 		{ title: title, text: text},
		type: 		"get",
		dataType:	"html",
		success: 	function(data) {
			jQuery("body").append("<div id='popupBox'>"+data+"</div>");
			Cufon.replace('h2', {fontFamily: 'MyriadPro' });
		}
	});
}



function runSlides() {
	showSlide(currentSlide);	
	if(currentSlide == (numOfSlides - 1)) {	return currentSlide = 0; } else {	return currentSlide++; }
}

function showSlide(id) {
	jQuery(".slide").each(function(){ jQuery(this).css("display","none");	});
	//console.log(id);
	jQuery("#slide"+id).fadeIn("slow", function() {
		jQuery("#motto"+id).fadeIn("slow");
		jQuery("#mottoItalic"+id).fadeIn("slow");
		setTimeout(function() {jQuery("#slide"+id).fadeOut("slow");}, 5500);
	});
	jQuery("#currentSlide").val(id);
	
}

function verkoopadressen_form(lang) {

	jQuery(".verkoopbutton").css('display','none');
	jQuery("#verkoopadressen").css('display','block');
	
	/*jQuery.ajax({
	  url: sUrl+"includes/verkoopadressen_form.php",
	  data: "lang="+lang,
	  cache: true,
	  success: function(html){
		$("#subpage_content").append(html);
	  }
	});*/
}
		



var newInterval = setInterval(function () { 	runSlides();	}, iSlideshowSpeed);
//]]>

