function showExtras(id){
	
	url=document.mainUrl+'/ajax.php?extras='+id+'&chozen='+$('#chozen').val()+'&item='+$('#PRO_ID').val();
	$.ajax({
		 url: url
	}).done(function(response) {
		shopWarning(6,response);
	});
	
}

function showExtrasBuild(id){
	
	url=document.mainUrl+'/ajax.php?extras='+id+'&chozen='+$('#chozen').val()+'&build=1&item='+$('#PRO_ID').val();
	$.ajax({
		 url: url
	}).done(function(response) {
		shopWarning(6,response);
	});
	
}

function berekenPrijs(){
	
	total		=	0;
	id			=	$('#refSelect').val();
	prijs		=	parseFloat($('#prijs'+id).val());
	
	str2		=	$('#chozenPrice').val();
	arr2		=	str2.split(';');
	str3		=	$('#chozen').val();
	arr3		=	str3.split(';');
	str7		=	$('#chozenSoort').val();
	arr7		=	str7.split(';');
	
	
	if($('#buildYourOwn').val()==1){
		
		
		gevondenArr	=	Array();
		groenten	=	0;
		
		for(a=0;a<arr2.length-1;a++){
			//EXTRAS WORDEN PAS BIJGEZET INDIEN DE SOORT ER NOG NIET INZIT
			ditIsEenExtra=0;
			if(inArray(arr7[a],gevondenArr)){
				if(arr7[a]==4){
					groenten++;
					if(groenten>3)ditIsEenExtra=1;
				} else {
					ditIsEenExtra=1;
				}
			}
			if(ditIsEenExtra==1){
				
				total	+=	parseFloat(arr2[a]);
				
				
			} else {
				gevondenArr.push(arr7[a]);
			}
		}
		if(inArray(4,arr3)){
			total	+=	1;
		}
		
	} else {
		
		for(a=0;a<arr2.length-1;a++){
			total	+=	parseFloat(arr2[a]);
		}
		
		
	
	}
	
	if(total>0){
		$('#extraDiv').css('display','block');
	} else {
		$('#extraDiv').css('display','none');
	}
		
	total	=	prijs+total;
	$('#keuzeDiv').html('PRIJS: <b><span style="font-size:25px;color:#f60;">'+total.toFixed(2)+'</span></b>');
	
}

function delExtra(id){
	
	chozen		=	'';
	chozenSoort	=	'';
	chozenPrice	=	'';
	chozenTiet	=	'';
	str1		=	$('#chozen').val();
	str2		=	$('#chozenPrice').val();
	str3		=	$('#chozenTiet').val();
	str7		=	$('#chozenSoort').val();
	arr1		=	str1.split(';');
	arr2		=	str2.split(';');
	arr3		=	str3.split(';');
	arr7		=	str7.split(';');
	for(a=0;a<arr1.length-1;a++){
		if(arr1[a]!=id){
			chozen			+=	arr1[a]	+	';';
			chozenSoort		+=	arr7[a]	+	';';
			chozenPrice		+=	arr2[a]	+	';';
			chozenTiet		+=	arr3[a]	+	';';
		}
	}
	$('#chozen').val(chozen);
	$('#chozenSoort').val(chozenSoort);
	$('#chozenPrice').val(chozenPrice);
	$('#chozenTiet').val(chozenTiet);
	setExtraTxt();
	
}


function setExtraTxt(){
	
	total	=	0;
	str		=	'';
	str1	=	$('#chozen').val();
	str2	=	$('#chozenPrice').val();
	str3	=	$('#chozenTiet').val();
	str7	=	$('#chozenSoort').val();
	arr1	=	str1.split(';');
	arr2	=	str2.split(';');
	arr3	=	str3.split(';');
	arr7	=	str7.split(';');
	zalmAdded	=	0;
	
	if($('#buildYourOwn').val()==1){
		
		gevondenArr	=	Array();
		groenten	=	0;
		for(a=1;a<7;a++){
			$('#sooTit'+a).html('');
			$('#soo'+a).html('<i class="far fa-square"></i>');
		}
		str='';
		$('#extrasTxt').html('');
		$('#extraDiv').css('display','none');
		
		for(a=0;a<arr1.length-1;a++){
			//EXTRAS WORDEN PAS BIJGEZET INDIEN DE SOORT ER NOG NIET INZIT
			ditIsEenExtra=0;
			if(inArray(arr7[a],gevondenArr)){
				if(arr7[a]==4){
					groenten++;
					if(groenten>3)ditIsEenExtra=1;
				} else {
					ditIsEenExtra=1;
				}
			}
			if(ditIsEenExtra==1){
				
				delLnk	=	'<a href="javascript:delExtra('+arr1[a]+')" style="color:#c00;font-weight:bold;text-decoration:none;">X</a>';
				str		+=	arr3[a]	+	' (&euro; '	+	arr2[a]	+	')'+delLnk+'<br />';
				total	+=	parseFloat(arr2[a]);
				$('#extrasTxt').html(str);
				$('#chozenPriceTotal').val(total.toFixed(2))
				
			} else {
				
				if(arr7[a]==4){
					if((groenten+1)<4){
						$('#soo'+arr7[a]).html('<b>'+(groenten+1) +'X</b>'+ '<i class="far fa-check-square" style="color:#f60;"></i>');
					} else {
						$('#soo'+arr7[a]).html('<b>'+(groenten+1) +'X</b>'+ '<i class="far fa-check-square" style="color:#0c0;"></i>');
					}
				} else {
					$('#soo'+arr7[a]).html('<b>1X</b><i class="far fa-check-square" style="color:#0c0;"></i>');
				}
				
				if($('#sooTit'+arr7[a]).html()==''){
					delLnk	=	'<a href="javascript:delExtra('+arr1[a]+')" style="color:#c00;font-weight:bold;text-decoration:none;">X</a>';
					$('#sooTit'+arr7[a]).html(arr3[a]+delLnk);
				} else {
					strJ=$('#sooTit'+arr7[a]).html();
					delLnk	=	'<a href="javascript:delExtra('+arr1[a]+')" style="color:#c00;font-weight:bold;text-decoration:none;">X</a>';
					$('#sooTit'+arr7[a]).html(strJ+'<br />'+arr3[a]+delLnk);
				}
				gevondenArr.push(arr7[a]);
				if(inArray(4,arr1) && zalmAdded!=1){
					zalmAdded=1;
					str	+= "zalm +&euro;1.00<br />";
				}
				$('#extrasTxt').html(str);
			}
		}
		//alert(gevondenArr.length);
	} else {
		
		for(a=0;a<arr1.length-1;a++){
			delLnk	=	'<a href="javascript:delExtra('+arr1[a]+')" style="color:#c00;font-weight:bold;text-decoration:none;">X</a>';
			str		+=	arr3[a]	+	' (&euro; '	+	arr2[a]	+	')'+delLnk+'<br />';
			total	+=	parseFloat(arr2[a]);
		}
		$('#extrasTxt').html(str);
		$('#chozenPriceTotal').val(total.toFixed(2))
		
	}
	
	berekenPrijs();
	
}


function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(haystack[i] == needle) return true;
    }
    return false;
}

function setExtra(id,soort){
	
	itemStr	=	$('#extrT_'+id).html()+' ('+$('#extrP_'+id).html()+')'+' '+'<br>';
	
	if($('#extrH_'+id).val()==0){
		
		prix	=	$('#prrrr'+id).val()+';';
		$('#chozen').val($('#chozen').val()+id+';');
		$('#chozenSoort').val($('#chozenSoort').val()+soort+';');
		$('#chozenPrice').val($('#chozenPrice').val()+prix);
		$('#chozenTiet').val($('#chozenTiet').val()+$('#extrT_'+id).html()+';');
		$('#ext'+id).html('<i class="far fa-check-square"></i>');
		$('#extrH_'+id).val(1);
		setExtraTxt();
		
	} else {
		
		$('#ext'+id).html('<i class="far fa-square"></i>');
		$('#extrH_'+id).val(0);
		delExtra(id)
		
	}
}

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');
				}
			}
		}
	}
}

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);
				}
			}
		}
	}
}

$(document).ready(function() {	
	if($( "#geboortedatum" ).length!=0){
		$(function() {
			$( "#geboortedatum" ).datepicker({
				changeMonth: true,
				changeYear: true,
				yearRange: (new Date().getFullYear()-100)+':'+(new Date().getFullYear()-18),
				dateFormat:'dd/mm/yy'
			});
		});
	}
});

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($('#showInCAan'+id).val()==aantal){
		$('#showInC'+id).css('display','inline-block');
	} else {
		$('#showInC'+id).css('display','none');
	}
	
}
function downProduct(id){
	
	btnTxt(id);
	aantal=$('#stuksAantal'+id).html();
	if(aantal>1){
		aantal--;
		$('#stuksAantal'+id).html(aantal);
	} else {
		if($('#showInCAan'+id).val()>=1 && aantal==1){
			aantal--;
			$('#stuksAantal'+id).html(aantal);
		}
	}
	if($('#showInCAan'+id).val()==aantal){
		$('#showInC'+id).css('display','inline-block');
	} else {
		$('#showInC'+id).css('display','none');
	}
	
}

function btnTxt(prod){
	if($('#inAddBtn'+prod).html()!='toevoegen' && $('#inAddBtn'+prod).html()!='ajouter'){
		$('#inAddBtn'+prod).html(taalswap("aanpassen","ajuster",""));
		$('#inAddBtn'+prod).css('background-color','#c00');
		$('#inAddBtn'+prod).attr('href','javascript:addInList('+prod+');');
	}
}

function addInList(prod){
	if($('#besteldag').val()==''){
		
		eerstdag('',0,prod);
		
	} else {
		alert("pp");
		inn=0;
		$('#Wmessage').html('<div style="text-align:center;"><b>LOADING</b><br /><img style="width:200px;" src="'+$('#WB_URL').val()+'/templates/images/spinner.gif" /></div>');
		$('#warning').css('display','flex');
		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;
			}
			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","#000");
				} 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","#000");
				}
				
			} 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","#ad6a43");
				$('#inCART'+prod).css('display','none');
				$('#imgA'+prod+' img').css('filter','grayscale(100%)');
				$('#mainPic').css('filter','grayscale(100%)');
			}
			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/spinner.gif" /></div>');
	$('#warning').css('display','flex');
	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_icon.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 reserveer(dag,dagOk,uur){
	$('#warning').css('display','flex');
	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/spinner.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_icon.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','flex');
	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=tekst2;
		tekst+='<br /><br /><img src="'+document.mainUrl+'/templates/images/spinner.gif" style="width:100%;" />';
	}
	if(wat==6){
		tekst=tekst2;
		tekst+='<a href="javascript:clearShopWarning();" class="shop_submit">OK</a>';
	}
	if(wat==7){
		tekst='De tijd te bestellen om te laten leveren is verstreken<br />Gelieve een uur van afhalen te kiezen<br /><br />';
		tekst+='<a href="javascript:clearShopWarning();" class="shop_submit">OK</a>';
	}
	$('#Wmessage').html(tekst);
}

function clearShopWarning(){
	$('#warning').css('display','none');
	$('#Wmessage').html('');
}

function warningLoading(){
	$('#warning').css('display','flex');
	$('#Wmessage').html('<div style="text-align:center;"><img style="width:200px;" src="'+document.mainUrl+'/templates/images/Loading_icon.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_icon.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) {
			window.document.location.href=$('#actualLink').val()+'?ref='+nr;
		});
	}
	
}

function setUUU(){
	uur		=	$('#uur').val();
	minuut	=	$('#minuut').val();
	$('#minuut').css("display","inline-block");
	$('#U0').hide();
	if(uur==9){
		if($('#minuut').val()<30){
			$('#minuut').val('30');
		}
		$('#m0').hide();
		$('#m5').hide();
		$('#m10').hide();
		$('#m15').hide();
		$('#m20').hide();
		$('#m25').hide();
	} else {
		$('#m0').show();
		$('#m5').show();
		$('#m10').show();
		$('#m15').show();
		$('#m20').show();
		$('#m25').show();
	}
}

function delShop(nr){
	$('#inCartProdDetail').html('<img src="'+document.mainUrl+'/templates/images/Loading_icon.gif" 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_icon.gif" 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) {
		
		window.document.location.href=$('#actualLink').val()+'?ref='+nr+'&dil='+nr;
	
	});
}

function setRef(id,come){
	$('#refSelect').val(id);
	prijs=$('#prijs'+id).val();
	$('.reffers').html('<i class="far fa-square"></i>');
	$('#ref'+id).html('<i class="far fa-check-square" style="color:#f60;"></i>');
	berekenPrijs();
	if(come==1)toDiv('comeBack');
}

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_icon.gif" alt="" />');
		if(response!='')$('#prodPic').html(response);
	});
	
	
}
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(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_icon.gif" alt="" /><img width="50" 	src="'+document.mainUrl+'/templates/images/loadCircle.gif" 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(prod){
	
	if($('#besteldag').val()==''){
		
		eerstdag('',0,prod);
		
	} else {
		
		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($('#chozen').length){
			endurl+='&chozen='+$('#chozen').val();
		}
		if(fout==0) {
			
			prod	=	$('#prod_id').val();
			aantal	=	$('#aantal').val();
			ref		=	$('#refSelect').val();
			opm		=	'';
			if($('#refOpm').length){
				opm		=	$('#refOpm').val();
			}
			
			$('#refDiv').html('<img src="'+document.mainUrl+'/templates/images/Loading_icon.gif" alt="" /><img width="50" src="'+document.mainUrl+'/templates/images/loadCircle.gif" alt="" />');
			url=''+document.mainUrl+'/ajax.php?prod='+prod+'&aantal='+aantal+'&ref='+ref+endurl+'&opm='+opm;
			$.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_icon.gif" 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()+'?comeback=1';
	});
}

function delProd(nr){
	$('#addProd').html('<img src="'+document.mainUrl+'/templates/images/Loading_icon.gif" alt="" /><img width="50" src="'+document.mainUrl+'/templates/images/loadCircle.gif" 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(){
	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 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_icon.gif" 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="+document.getElementById('searchField').value;
}
function searchFor2(url){
	document.location.href=url+"?search="+document.getElementById('searchField2').value;
}

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){
    
	//initial strength
    var strength = 0
	
    //if the password length is less than 6, return message.
    if (password.length < 6) { 
		$('#result').removeClass()
		$('#result').addClass('short')
		return 'Too short' 
	}
    
    //length is ok, lets continue.
	
	//if length is 8 characters or more, increase strength value
	if (password.length > 7) strength += 1
	
	//if password contains both lower and uppercase characters, increase strength value
	if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))  strength += 1
	
	//if it has numbers and characters, increase strength value
	if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/))  strength += 1 
	
	//if it has one special character, increase strength value
    if (password.match(/([!,%,&,@,#,$,^,*,?,_,~])/))  strength += 1
	
	//if it has two special characters, increase strength value
    if (password.match(/(.*[!,%,&,@,#,$,^,*,?,_,~].*[!,%,&,@,#,$,^,*,?,_,~])/)) strength += 1
	
	//now we have calculated strength value, we can return messages
	
	//if value is less than 2
	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/spinner.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/spinner.gif" style="width:100%;">');
		if(subb==2){
			$('#subbZ2').html('<img src="https://www.llvastgoed.be/templates/images/spinner.gif" style="width:100%;">');
			$('#subbZ2').slideDown();
			$('#subbZ3').slideUp();
		}
		if(subb==3){
			$('#subbZ3').html('<img src="https://www.llvastgoed.be/templates/images/spinner.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);
}