function showMobFilters(){
	
	if($("#cat").css('display')=='none'){
		$('#fflltt').css('display','block');
		$('#mobColl').css('display','none');
		$('#cat').css('border-bottom','solid 30px #a8235c');
		$('#extraMob').css('border-bottom','solid 10px #a8235c');
		$("#cat").slideDown();
		$('html, body').animate({
				scrollTop: "0px"
		}, 800);
	} else {
		if($('#mobColl').css('display')=='block'){
			$('#mobColl').slideUp();
			$('#fflltt').slideDown();
			$('#cat').css('border-bottom','solid 30px #a8235c');
			$('#extraMob').css('border-bottom','solid 10px #a8235c');
		} else {
			$('#extraMob').css('border-bottom','solid 0px #a8235c');
			$("#cat").slideUp();
			
		}
	}
	
}

function makeSelPoss(){
	if($('#showInputs').val()=='0'){
		$('#showInputs').val('1');
		$('#filtersHome input[type="checkbox"]').css('display','inline');
		$('.filtersoort a').css('cursor','default');
		$('.filtersoort a i').css('display','none');
		$('.filtersoort a').click(function(e) { e.preventDefault();});
		$('.filtersoort a').attr('onclick','');
		$('#toonSel').css('display','none');
		$('#bekijkSel').css('display','inline-block');
	} else {
		$('#showInputs').val('0');
		$('#filtersHome input[type="checkbox"]').css('display','none');
		$('.filtersoort a').css('cursor','pointer');
		$('.filtersoort a i').css('display','inline');
		$('.filtersoort a').click(function(e) {document.location.href=$(this).attr('href');});
		$('.filtersoort a').attr('onclick','javascript:warningLoading();');
		$('#toonSel').css('display','inline-block');
		$('#bekijkSel').css('display','none');
	}
}

function hideAnnn(){
	$('.annKeuze').css('display','none');
	$('.toonsel').css('display','block');
}

function showFilCat(nr){
	if($('#keuzes'+nr).css('display')=='none'){
		down=1;
		$('#fflltt h2').css('display','none');
		$('.gekozenFill').css('display','none');
		$('.catFill').css('display','none');
		$('.filterKies').css('display','none');
		$('#bigFilkeuze').css('display','none');
	
	} else {
		
		down=0;
	}
	$('.keuzes').slideUp();
	if(down==1){
		$('#keuzes'+nr).slideDown();
		$('#catFill'+nr).css('display','block');
	} else {
		$('#keuzes'+nr).slideUp();
	}
	var scrH=$(window).height();
	var scrW=$(window).width();
	if(scrW<851){
		$('html, body').animate({
				scrollTop: "0px"
		}, 800);
	}
}



function inloggen(){
	$('#loginFast').css('display','block');
}
function annuleerInlog(){
	$('#loginFast').css('display','none');
}

function setLoginForm(){
	
	$("#myLoginForm").submit(function(event){
		event.preventDefault(); //prevent default action 
		var post_url = document.mainUrl+'/ajax.php'; //get form action url
		var request_method = $(this).attr("method"); //get form GET/POST method
		var form_data = $(this).serialize(); //Encode form elements for submission
		$('#loginFormHolder').css('display','none');
		$('#loginLoading').html('<div style="text-align:center;"><img style="width:200px;" src="'+document.mainUrl+'/templates/images/spinner.gif" /></div>');
		$.ajax({
			url : post_url,
			type: request_method,
			data : form_data
		}).done(function(response){
			if(response	==	1){
				$('#loginLoading').html('');
				$('#loginFormHolder').html('<img style="width:200px;" src="'+document.mainUrl+'/templates/images/spinner.gif" /><br /><br />'+taalswap('EVEN GEDULD<br />U WORDT AANGEMELD','',''));
				$('#loginFormHolder').css('display','block');
				location.reload();
			} else {
				$('#loginLoading').html('<div style="background-color:#f38576;color:#fff;text-align:left;padding:5px;margin-bottom:5px;text-transform:uppercase;">'+taalswap('Verkeerde inlogpoging','mauvaise tentative de connexion','')+'</div>');
				$('#loginFormHolder').css('display','block');
			}
		});
	});

}


function adderFavs(id){
	
	wanted=(getCookie('favorit'));
	tmpArr=wanted.split(",");
	str='';
	
	for(a=0;a<tmpArr.length;a++){
		if(tmpArr[a]!='')str+=tmpArr[a]+',';
	}
	if(tmpArr.indexOf(id) != -1){
	} else {
		$('#fav'+id).html('<i class="fas fa-heart"></i>');
		$('#fav'+id).parent().addClass('favListOk');
		$('#fav'+id).parent().removeClass('favList');
		$('#fav'+id).attr('href','javascript:removerFavs(\''+id+'\');');
		str+=id;
		setCookie2(str);
		setFavs();
	}
}

function removerFavs(id){
	wanted=(getCookie('favorit'));
	str='';
	tmpArr=wanted.split(",");
	for(a=0;a<tmpArr.length;a++){
		if(tmpArr[a]!=id && tmpArr[a]!=''){
			str+=tmpArr[a];
			if(a!=tmpArr.length-1){
				str+=',';
			}
		}
	}
	if(tmpArr.indexOf(id) != -1){
		$('#fav'+id).html('<i class="far fa-heart"></i>');
		$('#fav'+id).parent().removeClass('favListOk');
		$('#fav'+id).parent().addClass('favList');
		$('#fav'+id).attr('href','javascript:adderFavs(\''+id+'\');');
		setCookie2(str);
		setFavs();
	} else {
		//alert("zit al niet meer in de string");
	}
}

function setFavs(){
	wanted=(getCookie('favorit'));
	str='';
	if(wanted!=''){
		tmpArr=wanted.split(",");
		aantal=0;
		for(a=0;a<tmpArr.length;a++){
			$('#fav'+tmpArr[a]).parent().removeClass("favList");
			$('#fav'+tmpArr[a]).parent().addClass("favListOk");
			$('#fav'+tmpArr[a]).html('<i class="fas fa-heart"></i>');
			$('#fav'+tmpArr[a]).attr('href','javascript:removerFavs(\''+tmpArr[a]+'\');');
			if(tmpArr[a]!=''){
				aantal++;
				str+=tmpArr[a];
				if(a!=tmpArr.length-1){
				str+=',';
			}
			}
		}
		if(aantal>0){
			
			if(isNaN(aantal)){
				$('#aantalFavs').html('');
				$('#aantalFavs2').html('');
			} else {
				$('#aantalFavs').html('<a href="'+document.mainUrl+$("#CAT_DIR").val()+'?fav=1" onclick="javascript:warningLoading();"><span class="favTop">'+taalswap('FAVORIETEN','FAVORIS','')+'</span> '+aantal+' <i class="fas fa-heart" style="color:#c00;"></i></a>');
				$('#aantalFavs2').html('<a href="'+document.mainUrl+$("#CAT_DIR").val()+'?fav=1" onclick="javascript:warningLoading();">'+aantal+' <i class="fas fa-heart" style="color:#c00;"></i><i class="fas fa-chevron-right"></i></a>');
			}
		} else {
			$('#aantalFavs').html('');
			$('#aantalFavs2').html('');
		}
	} else {
		$('#aantalFavs').html('');
		$('#aantalFavs2').html('');
	}
}

function getCookie(cname) {
  var name = cname + "=";
  var decodedCookie = document.cookie;
  var ca = decodedCookie.split(';');
  for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

function setCookie2(cvalue) {
  	var d = new Date();
 	var n = d.getFullYear();
	jaartje=d.toUTCString();
 	jaartje=jaartje.replace(n,parseInt(n)+1);
  	var expires = "expires="+jaartje;
	document.cookie = "favorit=" + cvalue + ";" + expires + ";path=/;";
}


function geenBtw2(){
	if($('#geenBtw').is(':checked')){
		$('#btwnummer').val('');
		$('#btwCountry').val('--');
		$('#btwnummer').attr("disabled", true);
		$('#btwCountry').attr("disabled", true);
	} else {
		$('#btwnummer').attr("disabled", false);
		$('#btwCountry').attr("disabled", false);
	}
}


function setMaatMetStock(pos,id,aantal){
	$('#err').html('');
	$('#err').css('display','none');
	$('.maatDiv').removeClass('selected');
	$('#maat'+pos).addClass('selected');
	$('#maat').val(id);
	if($('#aantal').val()>aantal){
		if($('#maatStockAantal'+$('#maat').val()).length){
			if($('#maatStockAantal'+$('#maat').val()).val()<$('#aantal').val()){
				$('#aantal').val($('#maatStockAantal'+$('#maat').val()).val());
				shopWarning(4,'maar '+$('#maatStockAantal'+$('#maat').val()).val()+' stuk(s) meer voorradig');
			}
		}
		$('#aantal').val(aantal);
	}
}

function plusNumber(field){
	$('#err').html('');
	$('#err').css('display','none');
	val=parseInt($('#'+field).val());
	if($('#'+field).val()=='')val=0;
	val=val+1;
	$('#'+field).val(val);
	if($('#maat').length){
		if(isNaN($('#maat').val()) || $('#maat').val()==''){
			
		} else {
			if($('#maatStockAantal'+$('#maat').val()).length){
				if($('#maatStockAantal'+$('#maat').val()).val()<$('#aantal').val()){
					$('#aantal').val($('#maatStockAantal'+$('#maat').val()).val());
					shopWarning(4,'maar '+$('#maatStockAantal'+$('#maat').val()).val()+' stuk(s) meer voorradig');
				}
			}
		}
	}
	bereken();
}

function minNumber(field){
	
	$('#err').html('');
	$('#err').css('display','none');
	val=parseInt($('#'+field).val());
	if($('#'+field).val()=='')val=0;
	if(val>0)val=val-1;
	$('#'+field).val(val);
	if($('#maat').length){
		if(isNaN($('#maat').val()) || $('#maat').val()==''){
			
		} else {
			if($('#maatStockAantal'+$('#maat').val()).length){
				if($('#maatStockAantal'+$('#maat').val()).val()<$('#aantal').val()){
					$('#aantal').val($('#maatStockAantal'+$('#maat').val()).val());
					$('#err').html('maar '+$('#maatStockAantal'+$('#maat').val()).val()+' stuk(s) meer voorradig');
					$('#err').css('display','block');
					var t=setTimeout('clearDiv("err")',3500);
				}
			}
		}
	}
	bereken();
}

function bereken(){
	
	if($('#aantal').length){
		
		gezet	=	0;
		
		prijs		=	$('#prijs').val();
		
		if($('#staffel').length){
			
			staffel		=	$('#staffel').val();
			staffel		=	staffel.split(';');
			origprijs	=	$('#prijs').val();
			prijs		=	$('#prijs').val();	
			
			if($('#aantal').val()>0){
				for(a=0;a<staffel.length;a+=2){
					if($('#aantal').val()>=parseInt(staffel[a])){
						prijs=financial(origprijs*((100-staffel[a+1])/100))
					}
				}
				bereKK	=	$('#aantal').val()+' x &euro; '+prijs;
				prijsTT	=	'<span style="color:#a8235c;font-size:22px;"> = &euro; '+financial(prijs*$('#aantal').val())+'</span>';
				$('#berekend').html('<div style="font-size:16px;font-weight:bold;margin-top:5px">'+bereKK+prijsTT+'</div>');
			} else {
				$('#berekend').html('');
			}
			gezet=1
			
		}
		
		if($('#perGratis').length){
			
			aantalGratis	=	0;
			perGratis		=	$('#perGratis').val().split(';');
			tot				=	parseFloat(perGratis[0])+parseFloat(perGratis[1]);
			aantalGratis	=	$('#aantal').val()/tot;
			aantalGratis	=	Math.floor(aantalGratis);
			if(($('#aantal').val()%tot)==3){
				$('#aantal').val(parseInt($('#aantal').val())+1);
				perGratis		=	$('#perGratis').val().split(';');
				tot				=	parseFloat(perGratis[0])+parseFloat(perGratis[1]);
				aantalGratis	=	$('#aantal').val()/tot;
				aantalGratis	=	Math.floor(aantalGratis);
			}
			//alert($('#aantal').val()-aantalGratis);
			grr='';
			if(aantalGratis>0)grr=' + '+aantalGratis+' gratis';
			if(parseInt($('#aantal').val())>0){
				prijsTT	=	'<span style="color:#a8235c;font-size:20px;"> = &euro; '+financial(prijs*($('#aantal').val()-aantalGratis))+'</span>';
				$('#berekend').html('<div style="font-size:16px;font-weight:bold;margin-top:5px">'+prijsTT+grr+'</div>');
			} else {
				$('#berekend').html('');
			}
			gezet=1;
		}
		
		if($('#aantalkortingen1').length){
			aantallen=$('#aantalkortingen1').val();
			aantallen=aantallen.split(';');
			prijzen=$('#aantalkortingen2').val();
			prijzen=prijzen.split(';');
			prijs=prijzen[0]
			for(a=0;a<aantallen.length;a++){
				if($('#aantal').val()>(parseInt(aantallen[a-1])-1)){
					prijs=prijzen[a];
				}
			}
			bereKK	=	$('#aantal').val()+' x &euro; '+prijs;
			prijsTT	=	'<span style="color:#a8235c;font-size:20px;"> = &euro; '+financial(prijs*$('#aantal').val())+'</span>';
			if(parseInt($('#aantal').val())>0){
				$('#berekend').html('<div style="font-size:16px;font-weight:bold;margin-top:5px">'+bereKK+prijsTT+'</div>');
			} else {
				$('#berekend').html('');
			}
			gezet=1;
		}
			
		
		if(gezet==0){
			
			prijsTT	=	'<span style="color:#a8235c;font-size:20px;"> = &euro; '+financial(prijs*$('#aantal').val())+'</span>';
			$('#berekend').html('<div style="font-size:16px;font-weight:bold;margin-top:5px">'+prijsTT+'</div>');
		
		}
		
	}
}

function financial(x) {
  return Number.parseFloat(x).toFixed(2);
}

$(document).ready(function() {	
	//LoginForm();
	if($( "#geboortedatum" ).length!=0){
		$(function() {
			$( "#geboortedatum" ).datepicker({
				changeMonth: true,
				changeYear: true,
				yearRange: (new Date().getFullYear()-100)+':'+(new Date().getFullYear()-18),
				dateFormat:'dd/mm/yy'
			});
		});
	}
	$('#aantal').on('input', function() {
		bereken();
	});	
	setLoginForm();
});

function changeCountry(sel){
	working();
	document.location.href="?shippingCountry="+sel.value;
}

function upProduct(id){
	
	btnTxt(id);
	aantal	=	$('#stuksAantal'+id).html();
	aantal++	;
	$('#stuksAantal'+id).html(aantal);
	if(aantal>0){
		$('#stuks'+id).css('color','#3c2160');
		$('#inAddBtn'+id).css('opacity','1');
	} else {
		$('#stuks'+id).css('color','#fff');
		$('#inAddBtn'+id).css('opacity','0');
	}
	if($('#showInCAan'+id).val()==aantal){
		$('#showInC'+id).css('display','inline-block');
	} else {
		$('#showInC'+id).css('display','none');
	}
	bereken();
	
}
function downProduct(id){
	
	btnTxt(id);
	aantal=$('#stuksAantal'+id).html();
	
	if(aantal>0){
		aantal--	;
		$('#stuksAantal'+id).html(aantal);
		if(aantal<1){
			if($('#showInCAan'+id).val()>=1 && aantal==0){
			} else {
				$('#stuks'+id).css('color','#fff');
				$('#inAddBtn'+id).css('opacity','0');
			}
		} else {
			$('#stuks'+id).css('color','#3c2160');
			$('#inAddBtn'+id).css('opacity','1');
		}
	} else {
		if($('#showInCAan'+id).val()>=1 && aantal==1){
			aantal--;
			$('#stuksAantal'+id).html(aantal);
		}
	}
	if($('#showInCAan'+id).val()==aantal && aantal>0){
		$('#showInC'+id).css('display','inline-block');
	} else {
		$('#showInC'+id).css('display','none');
	}
	bereken();
	
}

function btnTxt(prod){
	if($('#inAddBtn'+prod).html()!='toevoegen' && $('#inAddBtn'+prod).html()!='ajouter'){
		if($('#inAddBtn'+prod).html()=='bestellen'){
			$('#inAddBtn'+prod).html(taalswap("toevoegen","ajuster",""));
			$('#inAddBtn'+prod).css('background-color','#a8235c');
			$('#inAddBtn'+prod).attr('href','javascript:addInList('+prod+');');
		} else {
			$('#inAddBtn'+prod).html(taalswap("aanpassen","ajuster",""));
			$('#inAddBtn'+prod).css('background-color','#a8235c');
			$('#inAddBtn'+prod).attr('href','javascript:addInList('+prod+');');
		}
	}
}

function addInList(prod){
	if($('#besteldag').val()==''){
		
		eerstdag('',0,prod);
		
	} else {
		inn=0;
		$('#Wmessage').html('<div style="text-align:center;"><b>LOADING</b><br /><img style="width:200px;" src="'+$('#WB_URL').val()+'/templates/images/loading_ring.gif" /></div>');
		$('#warning').css('display','block');
		
		url=document.mainUrl+'/ajax.php?addInList=1&ailprod='+prod+'&ailaantal='+$('#stuksAantal'+prod).html();
		$.ajax({
		  url: url
		}).done(function(response) {
			$('#showInCAan'+prod).val($('#stuksAantal'+prod).html());
			stuks=parseInt($('#stuksAantal'+prod).html());
			if($('#showInCAanTwee'+prod).length){
				$('#showInCAanTwee'+prod).val($('#stuksAantalTwee'+prod).html());
				stuks+=parseInt($('#stuksAantalTwee'+prod).html());
			}
			$('#inCART'+prod+' span').html(stuks);
			tmp=response.split(';');
			if(tmp[0]!='0'){
				$('#showInC'+prod).css('display','inline-block');
				inn=1;	
			}
			if(tmp[1]!=0){
				$('#showInCTwee'+prod).css('display','inline-block');
				inn=1;
			}
			//INDIEN ER AANTAL>0)
			if(inn==1){
				$('#inCART'+prod).css('display','inline-block');
				$('#imgA'+prod+' img').css('filter','grayscale(0%)');
				$('#mainPic').css('filter','grayscale(0%)');
				if($('#bakkyRec').val()==1){
					$('#inAddBtn'+prod).html(taalswap('in','en','')+' <i class="fas fa-shopping-cart"></i>');
					$('#inAddBtn'+prod).attr('href','javascript:void();');
					$('#inAddBtn'+prod).css("background-color","#3c2160");
				} else {
					$('#inAddBtn'+prod).html(taalswap('naar','vers','')+' <i class="fas fa-shopping-cart"></i> <i class="fas fa-chevron-right"></i>');
					$('#inAddBtn'+prod).attr('href',document.mainUrl+taalswap('','/fr','')+'/winkelmandje');
					$('#inAddBtn'+prod).css("background-color","#3c2160");
				}
				
			} else {
				$('#showInCTwee'+prod).css('display','none');
				$('#stuksAantal'+prod).html('0');
				$('#stuksAantalTwee'+prod).html('0');
				$('#inAddBtn'+prod).html(taalswap("toevoegen","ajouter",""));
				$('#inAddBtn'+prod).attr('href','javascript:addInList('+prod+');');
				$('#inAddBtn'+prod).css("background-color","#a8235c");
				$('#inCART'+prod).css('display','none');
				$('#imgA'+prod+' img').css('filter','grayscale(100%)');
				$('#mainPic').css('filter','grayscale(100%)');
				$('#inAddBtn'+prod).css("opacity","0");
				$('#stuks'+prod).css("color","#fff");
			}
			
			if(tmp[2]>0){
				$('#innn span').css('display','inline-block');
				$('#innn span').html(tmp[2]);
				$('#topHoeveel').html(tmp[2]);
			} else {
				$('#innn span').css('display','none');
			}
			$('#warning').css('display','none');
		});
	}
}

function filter(url){
	str='';
	$(".chks").each(function( index ) {
		if($(this).is(':checked')){
			str+=($(this).attr('nr'))+'-';
		}
	});
	$('#Wmessage').html('<div style="text-align:center;"><b>LOADING</b><br /><img style="width:200px;" src="'+$('#WB_URL').val()+'/templates/images/loading_ring.gif" /></div>');
	$('#warning').css('display','block');
	document.location.href=url+'?filter=-'+str;
}

function herbestelpro(id,error){
	if(realNumber($('#proAantal'+id).val())==false){
		$('#proAantal'+id).css('border','solid 2px #c00');
		$('#proAantal'+id).val('');
		$('#proErr'+id).html(error);
		var t=setTimeout('clearDiv("err")',3500);
	} else {
		$('#proErr'+id).html('');
		$('#proAantal'+id).css('border','solid 1px #ccc');
		prod=id;
		aantal=	$('#proAantal'+id).val();
		$('#addpro'+id).html('<img style="width:200px;" src="'+document.mainUrl+'/templates/images/loading_ring.gif" />');
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal;
		$.ajax({
		  url: url
		}).done(function(response) {
			window.document.location.href=$('#actualLink').val()+'&wat=pro&reconstruct='+id;
		});
	}
}

function orderDay(morgen,wat){
	
	str='';
	/*ALLE DAGEN MOGELIJK*/
	str2='0,1,2,3,4,5,6';
	
	//SPECIFIEKE DAGEN DIE NIET KUNNEN
	if($('#NOORDER').length>0){
		str=$('#NOORDER').val();
	}
	//DAGEN VAN DE WEEK DIE WEL KUNNEN
	if($('#ORDERDAYS').length>0){
		str2=$('#ORDERDAYS').val();
	}
	var array = str.split(";");
	var days= str2.split(",");
	 
	
	$( "#orderDayInline" ).datepicker({
		inline: true,
		changeMonth: true,
		changeYear: false,
		dateFormat:'dd-mm-yy',
		minDate: morgen,
		onSelect: function(dateText) {
		 	$("#orderDay").val($(this).datepicker({ dateFormat: 'yy-mm-dd' }).val());
				getReservationDay($(this).datepicker({ dateFormat: 'yy-mm-dd' }).val());
			},
		  beforeShowDay: function(date) {
			var day = date.getDay();
			var datt = date.getDate();
			var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
			return [days.includes(day.toString()) && array.indexOf(string) == -1 ];
		}
	})
	if(wat!=''){
		$('#orderDayInline').datepicker("setDate", wat );
	}
	
}

function reserveer(dag,dagOk,uur){
	$('#warning').css('display','block');
	tekst='reservatie maken voor <br /><b>'+dagOk+' om '+uur+'u ?</b><br /><br />';
	tekst+='<div id="resLoading"></div>';
	tekst+='<div id="resForm"><input type="hidden" value="'+dag+'" name="resDag" id="resDag" /><input type="hidden" value="'+uur+'" name="resUur" id="resUur" /><input type="hidden" value="'+dagOk+'" name="dagOk" id="dagOk" />';
	tekst+='<div style="margin-bottom:5px;">MAAK KEUZE:<br /><select name="" id="resWat" style="border-color:#000;color:#000;"><option value="1">ik kom een tapijt collectie bekijken</option><option value="2">ik wil informatie over een specifiek tapijt</option><option value="3">ik kom een bestelling afhalen</option></select></div>';
	tekst+='<div class="table">';
	tekst+='<div class="tr"><div class="td">NAAM:</div><div class="td" style="text-align:right;"><input type="" value="" name="resNaam" id="resNaam" /></div></div>';
	tekst+='<div class="tr"><div class="td">TEL:</div><div class="td" style="text-align:right;"><input type="" value="" name="resTel" id="resTel" /></div></div>';
	tekst+='<div class="tr"><div class="td">EMAIL:</div><div class="td" style="text-align:right;"><input type="" value="" name="resEmail" id="resEmail" /></div></div>';
	tekst+='</div>';
	tekst+='<div style="margin-bottom:5px;">OPMERKING:<br /><textarea style="width:100%;height:75px;" id="resOpm"></textarea></div>';
	tekst+='<div ="resErr"></div>';
	tekst+='<a href="javascript:sendReservation();" class="shop_submit">RESERVEER</a> <a href="javascript:clearWarning();" class="shop_submit">ANNULEREN</a></div>';
	$('#Wmessage').html(tekst);
}

function sendReservation(){
	uur		=	$('#resUur').val();
	dag		=	$('#resDag').val();
	naam	=	$('#resNaam').val();
	tel		=	$('#resTel').val();
	email	=	$('#resEmail').val();
	wat		=	$('#resWat').val();
	opm		=	$('#resOpm').val();
	dagOk	=	$('#dagOk').val();
	$('#resForm').css('display','none');
	$('#resLoading').html('<img style="width:200px;" src="'+$('#WB_URL').val()+'/templates/images/loading_ring.gif" />');
	url=''+document.mainUrl+'/ajax.php?rsrvn='+dag+'&uur='+uur+'&naam='+naam+'&tel='+tel+'&email='+email+'&opm='+opm+'&wat='+wat;
	$.ajax({
	  url: url
	}).done(function(response) {
		if(response=='OK'){
			$('#resLoading').html('<i class="fas fa-thumbs-up"></i> Uw reservatie werd verstuurd<br />We kijken uit naar uw bezoek<br /><br /><a href="javascript:clearWarning();" class="shop_submit">OK</a>');
			getReservationDay(dagOk);
		} else {
			$('#resForm').css('display','block');
			$('#resLoading').html(response);
		}
	});
}

function getReservationDay(day){
	url=''+document.mainUrl+'/ajax.php?reservationDay='+day;
	$.ajax({
	  url: url
	}).done(function(response) {
		$('#reservationDay').html(response);
	});
}

function setDatePicker(year,month,day){
	$('#orderDayInline').datepicker("setDate", new Date(year,month,day) );
	getReservationDay($('#orderDayInline').datepicker({ dateFormat: 'yy-mm-dd' }).val());
	$("#orderDay").val($('#orderDayInline').datepicker({ dateFormat: 'dd-mm-yy' }).val());
}

function herbestelref(id,error){
	if(realNumber($('#refAantal'+id).val())==false){
		$('#refAantal'+id).css('border','solid 2px #c00');
		$('#refAantal'+id).val('');
		$('#refErr'+id).html(error);
		var t=setTimeout('clearDiv("err")',3500);
	} else {
		$('#refErr'+id).html('');
		$('#refAantal'+id).css('border','solid 1px #ccc');
		ref=id;
		prod=$('#prodref'+id).val();
		aantal=	$('#refAantal'+id).val();
		$('#addref'+id).html('<img style="width:200px;" src="'+document.mainUrl+'/templates/images/loading_ring.gif" />');
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+'&ref='+ref;
		$.ajax({
		  url: url
		}).done(function(response) {
			window.document.location.href=$('#actualLink').val()+'&wat=ref&reconstruct='+id;
		});
	}
}

function showAllBest(){
	$('#allBest').slideToggle();
}

function showAbout(){
	$('#nivTxt').slideToggle();
}

function shopWarning(wat,tekst2,id){
	$('#warning').css('display','block');
	tekst		=	'';
	if(wat==1){
		tekst	=	tekst2;
		tekst	+=	'<br /><br /><a href="javascript:warningLoading();location.href=\'?act=empty\'" class="shop_submit" id="ok">OK</a> <a href="javascript:clearShopWarning();" class="shop_submit">'+taalswap('annuleren','annuler','cancel')+'</a>';
	}
	if(wat==2){
		tekst	=tekst2;
		tekst	+=	'<br /><br /><a href="javascript:warningLoading();location.href=\'?del='+id+'\'" class="shop_submit" id="ok">OK</a> <a href="javascript:clearShopWarning();" class="shop_submit">'+taalswap('annuleren','annuler','cancel')+'</a>';
	}
	if(wat==3){
		tekst	=	tekst2;
	}
	if(wat==4){
		tekst	=	tekst2;
		tekst	+=	'<br /><br /><a href="javascript:clearShopWarning();" class="shop_submit">OK</a>';
	}
	if(wat==5){
		tekst	=	'<div style="text-align:center;width:100%;"><b>'+tekst2;
		tekst	+=	'</b><img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;;" /></div>';
	}
	if(wat==6){
		tekst	=	'<div style="text-align:center;width:100%;"><b>'+tekst2;
		tekst	+=	'</b><img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;;" /></div>';
	}
	if(wat==7){
		url=''+document.mainUrl+'/ajax.php?transportKost=1';
		$.ajax({
		  url: url
		}).done(function(response) {
			tekst=response;
			$('#Wmessage').html(tekst);
		});
	}
	$('#Wmessage').html(tekst);
	
}

function clearShopWarning(){
	$('#warning').css('display','none');
	$('#Wmessage').html('');
}

function warningLoading(){
	$('#warning').css('display','block');
	$('#Wmessage').html('<div style="text-align:center;"><img style="width:200px;" src="'+document.mainUrl+'/templates/images/loading_ring.gif" /></div>');
}

function showHistory(){
	$('#bestelHist').slideToggle();
}

function topLevel(id){
	for(a=0;a<$('#topAantal').val();a++){
		if(a==id && $('#topLevel'+id).css('display')=='none'){
			$('#topLevel'+id).slideToggle();
			$('#'+id+'span1').css('display','none');
			$('#'+id+'span2').css('display','');
		} else {
			if($('#topLevel'+a).css('display')=='block'){
				$('#topLevel'+a).slideToggle();
				$('#'+a+'span1').css('display','');
				$('#'+a+'span2').css('display','none');
			}
		}
	}
}
function addRef(nr){
	
	
	if(realNumber($('#inpRef'+nr).val())==false){
		$('#inpRef'+nr).css('border','solid 2px #c00');
		$('#refErr'+nr).html(taalswap('Gelieve aantal in te vullen.','Veuillez remplir la quantité.','Please fill in the quantity.'));
	} else {
		$('#refDiv'+nr).html('<img 	src="'+document.mainUrl+'/templates/images/loading_ring.gif" alt="" /><img width="50" 	src="'+document.mainUrl+'/templates/images/loadCircle.gif" alt="" />');
		$('prodShop').html('WORKING');
		prod=$('#refProd'+nr).val();
		aantal=	$('#inpRef'+nr).val();
		ref=nr;
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+'&ref='+nr;
		$.ajax({
		  url: url
		}).done(function(response) {
			//$('#prodPic').html(response);
			window.document.location.href=$('#actualLink').val()+'?ref='+nr;
		});
	}
	
}

function delShop(nr){
	$('#inCartProdDetail').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" />');
	url=''+document.mainUrl+'/ajax.php?delShop='+nr;
	$.ajax({
	  url: url
	}).done(function(response) {
		window.document.location.href=$('#actualLink').val();
	});
}

function delRef(nr){
	$('#refDiv'+nr).html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" /><img width="50" 	src="'+document.mainUrl+'/templates/images/loadCircle.gif" alt="" />');
	url=''+document.mainUrl+'/ajax.php?delRef='+nr;
	$.ajax({
	  url: url
	}).done(function(response) {
		//$('#prodPic').html(response);
		window.document.location.href=$('#actualLink').val()+'?ref='+nr+'&dil='+nr;
	});
}
function setRef(id){
	$('#refSelect').val(id);
	$('.reffers').html('<i class="far fa-square"></i>');
	$('#ref'+id).html('<i class="far fa-check-square"></i>');
	$('#prijs').val($('#refPrijs'+id).val());
	bereken();
}
function setRefMetImages(id){
	
	$('#refSelect').val(id);
	$('.reffers').html('<i class="far fa-square"></i>');
	$('#ref'+id).html('<i class="far fa-check-square"></i>');
	url=''+document.mainUrl+'/ajax.php?refPics='+id;
	$.ajax({
	  url: url
	}).done(function(response) {
		$('#prodPic').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" />');
		if(response!=''){
			$('#prodPic').html(response);
		} else {
			$('#prodPic').html('<img src="'+document.mainUrl+'/media/nopic.jpg" alt="" />');
		}
	});
	
	
}
function addProd2(){
	
	$('#err').html('');
	$('#err').css('display','none');
	$('#aantal').removeClass('inpErr');
	$('#matenSel').removeClass('inpErr');
	endurl='';
	fout=0;
	if(realNumber($('#aantal').val())==false){
		$('#aantal').val(0);
		$('#aantal').addClass('inpErr');
		shopWarning(4,taalswap('Gelieve aantal in te vullen.','Veuillez remplir la quantité.','Please fill in the quantity.'));
		fout=1;
	}
	if($('#maat').length){
		if(realNumber($('#maat').val())==false || $('#maat').val()==0){
			shopWarning(4,taalswap('Gelieve een maat te kiezen.','Choisissez une taille','Chooze a size'));
			fout=1;
		} else{
			endurl="&maat="+$('#maat').val();
		}
	}
	
	if(fout==0) {
		prod=$('#prod_id').val();
		aantal=	$('#aantal').val();
		$('#prodShop').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" />');
		$('html, body').animate({scrollTop: $('#prodShop').offset().top}, 1000);
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+endurl;
		$.ajax({
		  url: url
		}).done(function(response) {
			window.document.location.href=$('#actualLink').val()+'?comeback=1';
		});
	}
}

function addRef2(){
	
	endurl='';
	$('#aantal').css('border','solid 1px #ccc');
	$('#refSelect').css('border','solid 1px #ccc');
	fout=0;
	if(realNumber($('#aantal').val())==false){
		$('#aantal').css('border','solid 2px #c00');
		shopWarning(4,taalswap('Gelieve aantal in te vullen.','Veuillez remplir la quantité.','Please fill in the quantity.'));
		fout=1;
	}
	if($('#maat').length){
		if(realNumber($('#maat').val())==false || $('#maat').val()==0){
			shopWarning(4,taalswap('Gelieve een maat te kiezen.','Choisissez une taille','Chooze a size'));
			fout=1;
		} else{
			endurl+="&maat="+$('#maat').val();
		}
	}
	if($('#boodschap').length){
		endurl+="&boodschap="+$('#boodschap').val();
	}
	if(realNumber($('#refSelect').val())==false || $('#refSelect').val()==0){
		$('#refSelect').css('border','solid 2px #c00');
		shopWarning(4,taalswap('Gelieve een keuze te maken.','Veuillez faire un choix.','Please make a choice.'));
		fout=1;
	}
	
	if(fout==0) {
		prod=$('#prod_id').val();
		aantal=	$('#aantal').val();
		ref=$('#refSelect').val();
		$('#refDiv').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" />');
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+'&ref='+ref+endurl;
		url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+'&ref='+ref+endurl;
		$.ajax({
		  url: url
		}).done(function(response) {
			//$('#prodPic').html(response);
			window.document.location.href=$('#actualLink').val()+'?comeback=1';
		});
	}
	
}

function delRef2(nr){
	$('#refDiv').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" alt="" style="width:200px;" />');
	url=''+document.mainUrl+'/ajax.php?delRef='+nr;
	$.ajax({
	  url: url
	}).done(function(response) {
		//$('#prodPic').html(response);
		window.document.location.href=$('#actualLink').val()+'?comeback=1';
	});
}

function delProd(nr){
	$('#addProd').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" />');
	url=''+document.mainUrl+'/ajax.php?delProd='+nr;
	$.ajax({
	  url: url
	}).done(function(response) {
		window.document.location.href=$('#actualLink').val()+'?comeback=1';
	});
}

function setTxtAdd(showBtw,prijsTxt){
	
	if($('#aantalRef2').val()==''){
		$('#aanPr').html('');
		
		
	} else {
		
		/*if($('#incart'+$('#refSelect').val()).length>0){
			$('#aantalRef2').val($('#incart'+$('#refSelect').val()).html());
			$('#TOEV').html('AANPASSEN');
		} else {
			$('#aantalRef2').val('');
			$('#TOEV').html('TOEVOEGEN');
		}*/
		
		if(($("#refSelect option:selected" ).attr('img'))!=''){
			src=$("#mainPic").attr('src');
			var n = src.lastIndexOf("/");
			src=(src.substr(0,n)+'/'+$("#refSelect option:selected" ).attr('img'));
			$("#mainPic").attr('src',src);
			large=src.replace('pics','xl');
			$("#mainPic").parent().attr('href',large);
		}
		
		//$('#vanaf').css('display','none');
		/*
		num3=$("#refSelect option:selected" ).attr('prijs');
		num3=parseFloat(Math.round(num3 * 100) / 100).toFixed(2);
		num4=$("#refSelect option:selected" ).attr('prijsIncl');
		num4=parseFloat(Math.round(num4 * 100) / 100).toFixed(2);
		
		if(showBtw==1){
			$('#aanPr').html('<div style="font-size:20px;margin-top:15px;">'+prijsTxt+': &euro; '+num3+' <span style="font-size:14px;">'+btwtxtExcl+'</span><br />&euro; '+num4+' <span style="font-size:14px;">'+btwtxtIncl+'</span></div> ');
		} else {
			$('#aanPr').html('<div style="font-size:20px;margin-top:15px;">'+prijsTxt+' &euro; '+num3+' <span style="font-size:14px;">'+btwtxtIncl+'</span></div>');
		}
		*/
	}
}

function setTxtAdd2(ref){
	//alert("ok");
	if($('#incart'+$('#refSelect').val()).length>0){
		$('#aantalRef2').val($('#incart'+$('#refSelect').val()).html());
		$('#TOEV').html('AANPASSEN');
	} else {
		$('#aantalRef2').val('');
		$('#TOEV').html('TOEVOEGEN');
	}
	
	if(($("#refSelect option:selected" ).attr('img'))!=''){
		src=$("#mainPic").attr('src');
		var n = src.lastIndexOf("/");
		src=(src.substr(0,n)+'/'+$("#refSelect option:selected" ).attr('img'));
		$("#mainPic").attr('src',src);
		large=src.replace('pics','xl');
		$("#mainPic").parent().attr('href',large);
	}
	
	$('#vanaf').css('display','none');
	num3=$("#refSelect option:selected" ).attr('prijs');
	num3=parseFloat(Math.round(num3 * 100) / 100).toFixed(2);
	num4=$("#refSelect option:selected" ).attr('prijsIncl');
	num4=parseFloat(Math.round(num4 * 100) / 100).toFixed(2);
	$('#aanPr').html('<div style="font-size:20px;margin-top:15px;">prijs: &euro; '+num3+' <span style="font-size:14px;">excl. btw</span><br />&euro; '+num4+' <span style="font-size:14px;">incl. btw</span></div> ');
	
}

function setAddForm(){
	
	$("#shop").submit(function(event){
			
			event.preventDefault(); //prevent default action 
			var post_url = document.mainUrl+'/ajax.php'; //get form action url
			var request_method = $(this).attr("method"); //get form GET/POST method
			var form_data = $(this).serialize(); //Encode form elements for submission
			$.ajax({
				url : post_url,
				type: request_method,
				data : form_data
			}).done(function(response){ //
				window.document.location.href=$('#parentLnk').val();
			});
		});
}
function showMore(id){
				$('#zoekResult'+id).slideToggle();
				var txt=$('#baseTxt').html();
				if($('#a'+id).html()==txt){
					$('#a'+id).html($('#baseTxt2').html());
					$('#a'+id).css('margin-left','0px');
				} else {
					$('#a'+id).html($('#baseTxt').html());
					$('#a'+id).css('margin-left','20px');
				}
			}

function b2bOptioneel(){
	$('#bedrijf').val('');
	$('#btwnummer').val('');
	$('#btwCountry').val('--');
	$('#bedrijf').css('border','');
	$('#btwnummer').css('border','');
	$('#btwCountry').css('border','');
	$('#factuur .errSpan').html('');
	$('#factuur').slideToggle();
}
	

function showLogin(){
	$('.loginBox').slideToggle('slow');
}

function checkAlgVwdn(){
	fillOpmerkingen();
	if($('#alg').prop('checked')==false){
		$('#algmv').css('border','solid 3px #c00');
		$('#algmv').css('padding','3px');
		$('#algmv').css('color','#c00');
		$('#algmv div').html(taalswap('Gelieve akkoord te gaan met de alg. vwdn.','Veuillez accepter les conditions général.','please agree to the general conditions.'));
		$('#algmv div').css('background-color','#c00');
		$('#algmv div').css('color','#fff');
		$('#algmv div').css('padding','3px');
		var returnVal=false;
	} else {
		var returnVal=true;
	}
	return returnVal;
}

function fillOpmerkingen(){
	$('input[name="opmer"]').val($('#opmerking').val());
}

function showSearch(){
	$('#mobSearch').toggle();
}

function showAccount(){
	$('#loginLnks').toggle();
}

function postforwardShopMaten(txt,txt2){
	$('#aantal').removeClass('inpErr');
	$('#matenSel').removeClass('inpErr');
	posten=1;
	if(realNumber($('#aantal').val())==false){
		posten=0;
		$('#aantal').val('');
		$('#aantal').addClass('inpErr');
		txt=txt2;
	}
	if(realNumber($('#maat').val())==false){
		if($('#maat').val()!="0"){
			$('#matenSel').addClass('inpErr');
			posten=0;
		}
	}
	if(posten==0){
		$('#err').html(txt);
		$('#err').css('display','block');
		var t=setTimeout('clearDiv("err")',3500);
	} else {
		document.forms.shop.submit();
	}
}

function clearMsg(){
	var t=setTimeout("clearDiv('msg')",3500);
}

function postforwardShop(error){
	if(realNumber($('#aantal').val())==false){
		$('#aantal').css('border','solid 2px #c00');
		$('#aantal').val('');
		$('#err').html(error);
		var t=setTimeout('clearDiv("err")',3500);
	} else {
		prod=$('#prod_id').val();
		aantal=	$('#aantal').val();
		$('#addProd').html('<img src="'+document.mainUrl+'/templates/images/loading_ring.gif" style="width:100%;max-width:300px;" alt="" /><img width="50" 	src="'+document.mainUrl+'/templates/images/loadCircle.gif" alt="" />');
		url=document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal;
		$.ajax({
		  url: url
		}).done(function(response) {
			window.document.location.href=$('#actualLink').val()+'?comeback=1';
		});
	}
	
}
function clearDiv(elem){
	$('#'+elem).slideUp();
}
function realNumber(nr){
	ret=true;
	if(nr == "")ret=false;
	if(nr < 1)ret=false;
	if(isNaN(nr))ret=false;
	if(nr.indexOf(".")>0)ret=false;
	if(nr.indexOf(",")>0)ret=false;

	return ret;
}
function setMaat(pos,id,aantal){
	$('.maatDiv').removeClass('selected');
	$('#maat'+pos).addClass('selected');
	$('#maat').val(id);
}
function setMaatSel(){
	$('#maat').val($('#matenSel').val());
}
function checkMaat(tot){
	gevonden=0;
	tmp="";
	for(a=0;a<tot;a++){
		//alert($('#maat'+a).css('background-color'));
		tmp+=$('#maat'+a).css('background-color')+'<br />';
		if($('#maat'+a).css('background-color')=='rgb(245, 183, 121)'){
			gevonden=1;
		} else {//alert ("wit");
		}
	}
	if(gevonden==0){
		document.getElementById('errMaat').innerHTML='gelieve een maat te kiezen';
		return false;
	} else {
		return true;
	}
}


function prdn2(){
	if(document.getElementById("ik").value=="2"){
		if(document.getElementById("deel"))document.getElementById("deel").innerHTML="delen";
		if(document.getElementById("deel2"))document.getElementById("deel2").innerHTML="wij";
		if(document.getElementById("herroep"))document.getElementById("herroep").innerHTML="herroepen";
		if(document.getElementById("part"))document.getElementById("part").innerHTML="soussign&eacute;s notifions";
		if(document.getElementById("part2"))document.getElementById("part2").innerHTML="notre";
		if(document.getElementById("teil"))document.getElementById("teil").innerHTML="widerrufen";
		if(document.getElementById("teil2"))document.getElementById("teil2").innerHTML="uns";
	}
	if(document.getElementById("ik").value=="1"){
		if(document.getElementById("deel"))document.getElementById("deel").innerHTML="deel";
		if(document.getElementById("deel2"))document.getElementById("deel2").innerHTML="ik";
		if(document.getElementById("herroep"))document.getElementById("herroep").innerHTML="herroep";
		if(document.getElementById("part"))document.getElementById("part").innerHTML="soussign&eacute; notifie";
		if(document.getElementById("part2"))document.getElementById("part2").innerHTML="ma";
		if(document.getElementById("teil"))document.getElementById("teil").innerHTML="widerrufe";
		if(document.getElementById("teil2"))document.getElementById("teil2").innerHTML="mir";
	}
}

function prdn(){
	if(document.getElementById("prod").value=="1"){
		if(document.getElementById("het"))document.getElementById("het").innerHTML="het";
	}
	if(document.getElementById("prod").value=="2"){
		if(document.getElementById("het"))document.getElementById("het").innerHTML="de";
	}
}

function postforwardShop2(id){
	if(realNumber2(document.getElementById("aantal"+id).value)==false){
		document.getElementById("aantal"+id).style.border="solid 2px #c00";
		document.getElementById("aantal"+id).value="";
		document.getElementById("err"+id).innerHTML="'.$TXTCAT['ERRORTXT2'].'";
		var t=setTimeout("clearErr2("+id+")",3500);
	} else {
		document.getElementById("err"+id).innerHTML="";
		document.getElementById("form"+id).submit();
		document.getElementById("prodDiv"+id).innerHTML="";
	}
	
}
function clearErr2(id){
	alert(id);document.getElementById("err"+id).innerHTML="";
}
function realNumber2(nr){
	ret=true;
	if(nr == "")ret=false;
	if(nr < 1)ret=false;
	if(isNaN(nr))ret=false;
	
	if(nr.indexOf(".")>0)ret=false;
	if(nr.indexOf(",")>0)ret=false;
	return ret;
}

function emptyFields(chk){
	if(document.getElementById("shipping_voornaam"))document.getElementById("shipping_voornaam").value="";
	if(document.getElementById("shipping_name"))document.getElementById("shipping_name").value="";
	if(document.getElementById("shipping_adres"))document.getElementById("shipping_adres").value="";
	if(document.getElementById("shipping_postcode"))document.getElementById("shipping_postcode").value="";
	if(document.getElementById("shipping_gemeente"))document.getElementById("shipping_gemeente").value="";
	if(document.getElementById("shipping_telefoon"))document.getElementById("shipping_telefoon").value="";
	if(document.getElementById("shipping_land"))document.getElementById("shipping_land").value=0;
	if(document.getElementById("shipping_bedrijf"))document.getElementById("shipping_bedrijf").value="";
	if(document.getElementById("shipping_telefoon"))document.getElementById("shipping_telefoon").value="";
	if(document.getElementById("shipping_adres_2"))document.getElementById("shipping_adres_2").value="";
	
}


function showChoice(){
	$('#showForm').slideUp('slow');
	$('#sChoice').slideDown('slow');
	$('.jouwK2').slideUp('slow');
	$('.jouwK1').slideUp('slow');
	
}

function zonderPasw(){
	$('#showForm').slideDown('slow');
	$('#sChoice').slideUp('slow');
	$('#pswMeld').css("display","none");
	$('.pwd').css("display","none");
	$('.jouwK1').slideDown('slow');
	$('.jouwK2').slideUp('slow');
	$('#make_account').prop('checked', false);
}
function showPwd(chk){
	if(chk){
		if(chk.checked==true){
			$(".pwd").slideDown('slow');
		} else {
			$(".pwd").slideUp('slow');
			$("#paswoord").val('');
			$("#paswoord_2").val('');
			$("#result").html('');
		}
	}
}


function otherDelivery(chk){
	if(chk){
		if(chk.checked==true){
			if($("#div_ship_adres"))$("#div_ship_adres").slideDown('slow');
			if($('#get_inStore'))document.getElementById("get_inStore").checked=false;
			clearStores();
		} else {
			if($("#div_ship_adres"))$("#div_ship_adres").slideUp('slow');
		}
		emptyFields(chk);
	}
	if(document.getElementById('get_inStore').checked==true){
		if($("#div_ship_adres"))$("#div_ship_adres").slideUp('slow');
		if($("#other_delivery_adress"))document.getElementById("other_delivery_adress").checked=true;
		if($("#stores"))$("#stores").css('display','block');
	}
}

function getInStore(chk){
	if(chk){
		if(chk.checked==true){
			if($("#div_ship_adres"))$("#div_ship_adres").slideUp('slow');
			if($("#other_delivery_adress"))document.getElementById("other_delivery_adress").checked=false;
			if($("#stores"))$("#stores").css('display','block');
		} else {
			clearStores();
		}
		emptyFields(chk);
	}
}
function clearStores(){
	if($("#stores"))$("#stores").css('display','none');
	if($("#storeSelect"))$("#storeSelect").val(0);
}
function working(){
	warningLoading();
	if($("#shop_view"))$("#shop_view").css('display',"none");
	if($("#formWrap"))$("#formWrap").css('display',"none");
	if($("#working"))$("#working").css('display',"block");
	if($("#basket_view"))$("#basket_view").css('display',"none");
	
}


function showSelect(id)
{
    //alert(document.getElementById(id));
	document.getElementById('searchField').focus();
    document.getElementById('searchField').select();
}
function searchFor(url){
	document.location.href=url+"?search=**"+$('#complexSearch').val();
}
function searchFor2(url){
	document.location.href=url+"?search=**"+$('#searchField2').val();
}
function searchComplexFor(url){
	url	=	url+"?search="+$('#complexSearch').val();
	document.location.href	=	url;
}

function showCart(url,div){
	document.getElementById(div).style.display='block';
	xmlhttpPost(url,div);
}
function hideCart(div){
	document.getElementById(div).style.display='none';
}
function xmlhttpPost(strURL,div) {
	
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            //alert('found')
            updatepage(self.xmlHttpReq.responseText,div);
        }
        //else{alert('not found')}
    }
    
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    qstr = 'w='
    return qstr;
   
}

function updatepage(str,div){
    document.getElementById(div).innerHTML = str;
}


$(document).ready(function() {

	$('#paswoord').keyup(function(){
		$('#result').html(checkStrength($('#paswoord').val()))
	})	
	
	function checkStrength(password){
		 var strength = 0
		 if (password.length < 6) { 
			$('#result').removeClass()
			$('#result').addClass('short')
			return 'Too short' 
		}
		if (password.length > 7) strength += 1
		if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  strength += 1
		if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  strength += 1 
		if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/))  strength += 1
		if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
		if (strength < 2 ) {
			$('#result').removeClass()
			$('#result').addClass('weak')
			return 'Weak'			
		} else if (strength == 2 ) {
			$('#result').removeClass()
			$('#result').addClass('good')
			return 'Good'		
		} else {
			$('#result').removeClass()
			$('#result').addClass('strong')
			return 'Strong'
		}
	}
});



function toSubb2(){
	$('#subb3').css('display','none');
	$('#subb2 .nivFew').css('font-size','16px');
	$('#subb2 .nivFew').css('background-color','#fff');
	$('#subb2 .nivFew').css('padding','0px 0px 10px 0px');
}

function toSubbZ2(){
	$('#subbZ3').css('display','none');
	$('#subbZ2 .nivFew').css('font-size','16px');
	$('#subbZ2 .nivFew').css('background-color','#fff');
	$('#subbZ2 .nivFew').css('padding','0px 0px 10px 0px');
}
function showCatsy(subsTonen){
	setEscape(0);
	closeNavMob();
	closeSubbZ();
	
	//$('#subb1').css('left','33.333%');
	if($('#PAGE_ID').val()!=1){
		/*$('#top').css('position','fixed');
		$('#top').css('width','100%');
		$('#top').css('background-color','#fff');
		$('#logo').css('display','none');*/
	}
	$('#overlay').css('display','block');
	$('#subb1').slideDown();
	$('#subb2').css('display','none');
	$('#subb3').css('display','none');
	$('#subb1 .nivFew').css('font-size','16px');
	$('#subb1 .nivFew').css('background-color','#fff');
	$('#subb1 .nivFew').css('padding','0px 0px 10px 0px');
	document.mmOpen=1;
	if(isNaN($('#NIV_TOPLEVEL').val())){
	} else {
		//if(subsTonen==1)getSubs($('#NIV_TOPLEVEL').val(),2,$('#NIV_TOPLEVEL').val())
	};	
	//setHeightTop(1);
	
}
function showZoeksy(){
	$('#search').slideToggle();
	$('#searchField').focus();
	closeSubb();
	closeNavMob()
	window.scrollTo(0, 0);
	
}
function getSubs(id,subb,flink){
		
	var d = new Date();
	var n = d.getTime();
	$('#subb'+subb).html('<img src="https://www.llvastgoed.be/templates/images/loading_ring.gif" style="width:100%;">');
	$('#subb'+subb).slideDown();
	if(subb==2){
		$('#subb3').slideUp();
	}
	$('#subb'+(subb-1)+' .nivFew').css('font-size','16px');
	$('#subb'+(subb-1)+' .nivFew').css('background-color','#fff');
	$('#subb'+(subb-1)+' .nivFew').css('padding','0px 0px 10px 0px');
	$('#a'+flink).css('font-size','20px');
	$('#a'+flink).css('background-color','#ddd');
	$('#a'+flink).css('padding','10px 0px 10px 15px');
	if(subb==2){
		url=''+document.mainUrl+'/ajax.php?getSubs='+id+'&div='+subb+'&n='+n;
	} else {
		url=''+document.mainUrl+'/ajax.php?getSubs='+id+'&div='+subb+'&n='+n;
	}
	$.ajax({
	  url: url
	}).done(function(response) {
		$('#subb'+subb).html(response);	
		
	});
		
}
function closeSubb(){
	$('#subb1').css('display','none');
	$('#subb2').css('display','none');
	$('#subb3').css('display','none');
	$('#overlay').css('display','none');
	document.mmOpen=0;
	if($('#PAGE_ID').val()!=1){
		$('#top').css('position','relative');
		$('#top').css('width','100%');
		$('#top').css('background-color','none');
		$('#logo').css('display','block');
	}
	//setHeightTop(1);
}

function getZoekFromPage(){
	$('#zoekF1').val($('#searchField').val());
	$('#subbZ1').slideDown();
	if($('#PAGE_ID').val()!=1){
		$('#top').css('position','fixed');
		$('#top').css('width','100%');
		$('#top').css('background-color','#fff');
		$('#logo').css('display','none');
	}
	getZoeks(0,2,0);
}
function setEscape(actie){
	var array_of_functions = [closeSubb,closeSubbZ];
	$(document).off('keyup');
	$(document).keyup(function (e) {
		if(e.which == 27){
			array_of_functions[actie]();
		}
	});
}
function getZoeks(id,subb,flink){
		
		$('#subbZ'+subb).html('<img src="https://www.llvastgoed.be/templates/images/loading_ring.gif" style="width:100%;">');
		if(subb==2){
			$('#subbZ2').html('<img src="https://www.llvastgoed.be/templates/images/loading_ring.gif" style="width:100%;">');
			$('#subbZ2').slideDown();
			$('#subbZ3').slideUp();
		}
		if(subb==3){
			$('#subbZ3').html('<img src="https://www.llvastgoed.be/templates/images/loading_ring.gif" style="width:100%;">');
			$('#subbZ3').slideDown();
		}
		$('#subbZ'+(subb-1)+' .nivFew').css('font-size','16px');
		$('#subbZ'+(subb-1)+' .nivFew').css('background-color','#fff');
		$('#subbZ'+(subb-1)+' .nivFew').css('padding','0px 0px 10px 0px');
		$('#subbZ'+(subb-1)+' #a'+flink).css('font-size','20px');
		$('#subbZ'+(subb-1)+' #a'+flink).css('background-color','#ddd');
		$('#subbZ'+(subb-1)+' #a'+flink).css('padding','10px 0px 10px 15px');
		url=''+document.mainUrl+'/ajax.php?getZoeks='+$('#zoekF'+(subb-1)).val()+'&sub='+subb+'&nivid='+id;
		//alert(url);
	 	$.ajax({
		  url: url
		}).done(function(response) {
			$('#zoekLoad').html('');
			$('#subbZ'+subb).html(response);	
			$('#subbZ'+subb).slideDown();
		});
		
}


function closeSubbZ(){
	$('#subbZ1').css('display','none');
	$('#subbZ2').css('display','none');
	$('#subbZ3').css('display','none');
	$('#overlay').css('display','none');
	document.mmOpen=0;
	if($('#PAGE_ID').val()!=1){
		$('#top').css('position','relative');
		$('#top').css('width','100%');
		$('#top').css('background-color','none');
		$('#logo').css('display','block');
	}
	//setHeightTop(1);
}