function showLayer(whichdiv){
	if (document.getElementById(whichdiv.id+"_ov").style.display == ''){
		document.getElementById(whichdiv.id+"_ov").style.display = 'none';
	}else {
		document.getElementById(whichdiv.id+"_ov").style.display = '';
	}
	
}
function checkForm(){
	tel=0;
	var color= '#AA0000';
	var normalcolor='#656565';
	if (document.getElementById("mailrequest").checked && document.getElementById("postrequest").checked){
		//both request
		if (document.getElementById("voornaam").value =='') {				
			tel++;		
			document.getElementById("voornaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("voornaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("achternaam").value =='') {				
			tel++;		
			document.getElementById("achternaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("achternaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("bedrijf").value =='') {				
			tel++;		
			document.getElementById("bedrijf").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("bedrijf").className = 'txtInputLargeContact';
		}
		if (document.getElementById("functie").value =='') {				
			tel++;		
			document.getElementById("functie").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("functie").className = 'txtInputLargeContact';
		}
		if (document.getElementById("afdeling").value =='') {				
			tel++;		
			document.getElementById("afdeling").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("afdeling").className = 'txtInputLargeContact';
		}
		if (document.getElementById("adres1").value =='') {				
			tel++;		
			document.getElementById("adres1").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("adres1").className = 'txtInputLargeContact';
		}
		if (document.getElementById("adres2").value =='') {				
			tel++;		
			document.getElementById("adres2").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("adres2").className = 'txtInputLargeContact';
		}
		if (document.getElementById("postcode").value =='') {				
			tel++;		
			document.getElementById("postcode").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("postcode").className = 'txtInputLargeContact';
		}
		if (document.getElementById("email").value =='' || !checkEmail(document.getElementById("email").value)) {
			tel++;		
			document.getElementById("email").className = 'txtInputLargeContactWrong';		
		} else	{ 
			document.getElementById("email").className = 'txtInputLargeContact';
		}
	} else if (document.getElementById("mailrequest").checked)	{
		// only mailrequest
		document.getElementById("postcode").className = 'txtInputLargeContact';
		document.getElementById("adres1").className = 'txtInputLargeContact';
		document.getElementById("adres2").className = 'txtInputLargeContact';
		document.getElementById("afdeling").className = 'txtInputLargeContact';
		document.getElementById("functie").className = 'txtInputLargeContact';
		document.getElementById("bedrijf").className = 'txtInputLargeContact';
		if (document.getElementById("voornaam").value =='') {				
			tel++;		
			document.getElementById("voornaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("voornaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("achternaam").value =='') {				
			tel++;		
			document.getElementById("achternaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("achternaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("email").value =='' || !checkEmail(document.getElementById("email").value)) {
			tel++;		
			document.getElementById("email").className = 'txtInputLargeContactWrong';		
		} else	{ 
			document.getElementById("email").className = 'txtInputLargeContact';
		}
	} else if (document.getElementById("postrequest").checked) {
		//only post
		document.getElementById("email").className = 'txtInputLargeContact';
		if (document.getElementById("voornaam").value =='') {				
			tel++;		
			document.getElementById("voornaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("voornaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("achternaam").value =='') {				
			tel++;		
			document.getElementById("achternaam").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("achternaam").className = 'txtInputLargeContact';
		}
		if (document.getElementById("bedrijf").value =='') {				
			tel++;		
			document.getElementById("bedrijf").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("bedrijf").className = 'txtInputLargeContact';
		}
		if (document.getElementById("functie").value =='') {				
			tel++;		
			document.getElementById("functie").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("functie").className = 'txtInputLargeContact';
		}
		if (document.getElementById("afdeling").value =='') {				
			tel++;		
			document.getElementById("afdeling").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("afdeling").className = 'txtInputLargeContact';
		}
		if (document.getElementById("adres1").value =='') {				
			tel++;		
			document.getElementById("adres1").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("adres1").className = 'txtInputLargeContact';
		}
		if (document.getElementById("adres2").value =='') {				
			tel++;		
			document.getElementById("adres2").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("adres2").className = 'txtInputLargeContact';
		}
		if (document.getElementById("postcode").value =='') {				
			tel++;		
			document.getElementById("postcode").className = 'txtInputLargeContactWrong';
		} else	{ 
			document.getElementById("postcode").className = 'txtInputLargeContact';
		}
	} else {
		//no request
		document.getElementById("formMelding").innerHTML = '<b>Please specify a contact method.</b>';
		return false;
	}
	if(tel==0){					
		return true;
	} else {
		document.getElementById("formMelding").innerHTML = '<b>* Please fill out all required fields [' + tel + ']</b>';
		document.getElementById("formMelding").style.display = '';
		return false;
	}	
}
function checkEmail(str){
	var testresults = false;
	//uitleg filter: minimaal 1 letter voor @ ; min 1 max 66 letters na @ ; min 2 max 6 letters na punt.
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)){
		testresults=true;
	}else{
		testresults=false;
	}
	return (testresults);
}	
function switchIt(what){
	document.getElementById('digital').style.display='none';
	document.getElementById('solTable').style.display='none';
	document.getElementById(what).style.display='';
}

function setPageSize(){
	var yScroll;	
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
	}
	var windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	// 72 is de hoogte van de footer
	if((yScroll+35) < windowHeight){
		pageHeight = windowHeight-35;
	} else { 
		pageHeight = yScroll;
	}
	//alert(windowHeight + " en " + pageHeight);
	//alert(document.getElementById("wrapFt").style.height);
	document.getElementById("wrapBg").style.height = pageHeight + 'px';
	//document.getElementById("wrapFt").style.position = 'absolute';
	//document.getElementById("wrapFt").style.display = '';
}

function openMenu(divId) {
		cancelClose();
		closeAll();
		document.getElementById(divId).style.display='';	
}

function closeAll(){
		document.getElementById('companyMenu').style.display='none';
		document.getElementById('newsMenu').style.display='none';
		document.getElementById('contactMenu').style.display='none';
}
function closeMenu(divId){
	t = setTimeout(function(){closeAll()},600);
}

function cancelClose(){
	if(typeof(t) != "undefined") {
	clearTimeout(t);
	}
}
function openGroupPage(group){
	window.location= siteurl + "uk/distributors/" + group + "/";
}
function startSearch(variable){
	if(typeof(variable) != "undefined") {
		select = document.getElementById('selectsearch');
		window.location= siteurl + "uk/search/" + URLEncode(document.getElementById(variable).value) + "/" + select.options[select.selectedIndex].value +"/";
	} else {
		window.location= siteurl + "uk/search/" + URLEncode(document.getElementById("search").value) + "/";
	}

}
function checkNieuwsbrief(){
	tel=0;
	if (document.getElementById("voornaam").value =='') {				
		tel++;		
		document.getElementById("voornaam").className = 'txtInputLargeContactWrong';
	} else	{ 
		document.getElementById("voornaam").className = 'txtInputLargeContact';
	}
	if (document.getElementById("achternaam").value =='') {				
		tel++;		
		document.getElementById("achternaam").className = 'txtInputLargeContactWrong';
	} else	{ 
		document.getElementById("achternaam").className = 'txtInputLargeContact';
	}
	if (document.getElementById("mailadres").value =='' || !checkEmail(document.getElementById("mailadres").value)) {
		tel++;		
		document.getElementById("mailadres").className = 'txtInputLargeContactWrong';		
	} else	{ 
		document.getElementById("mailadres").className = 'txtInputLargeContact';
	}
	if(tel==0){					
		return true;
	} else {
		document.getElementById("formMelding").innerHTML = '<b>* Please fill out all Required Fields [' + tel + ']</b>';
		document.getElementById("formMelding").style.display = '';
		return false;
	}	
}
function checkNieuwsbriefAfmelden(){
	tel=0;
	if (document.getElementById("mailadres").value =='' || !checkEmail(document.getElementById("mailadres").value)) {
		tel++;		
		document.getElementById("mailadres").className = 'txtInputLargeContactWrong';		
	} else	{ 
		document.getElementById("mailadres").className = 'txtInputLargeContact';
	}
	if(tel==0){					
		return true;
	} else {
		document.getElementById("formMelding").innerHTML = '<b>* Please fill out all Required Fields [' + tel + ']</b>';
		document.getElementById("formMelding").style.display = '';
		return false;
	}	
}
function checkInput(input, was, wordt){
	if(input.value==was){
		input.value=wordt;
	}
}
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' '){
        output += '-';
	  }
      x++;
    }
  }
  return output;
}

function aanmeldSubmit(){ // Voor nieuwsbrief aanmeldform naar MuskitoMail
	tel=0;
	if (document.getElementById("first_name").value =='') {				
		tel++;		
		document.getElementById("first_name").className = 'txtInputLargeContactWrong';
	} else	{ 
		document.getElementById("first_name").className = 'txtInputLargeContact';
	}
	if (document.getElementById("last_name").value =='') {				
		tel++;		
		document.getElementById("last_name").className = 'txtInputLargeContactWrong';
	} else	{ 
		document.getElementById("last_name").className = 'txtInputLargeContact';
	}
	if (document.getElementById("email").value =='' || !checkEmail(document.getElementById("email").value)) {
		tel++;		
		document.getElementById("email").className = 'txtInputLargeContactWrong';		
	} else	{ 
		document.getElementById("email").className = 'txtInputLargeContact';
	}
	if(tel==0){
		return true;
	} else {
		document.getElementById("formMelding").innerHTML = '<b>* Please fill out all Required Fields [' + tel + ']</b>';
		document.getElementById("formMelding").style.display = '';
		return false;
	}	
}