function SwitchTaal(taal) {
	if (document.location.pathname == "/order.asp") {
		
	} else
	{
	var pagina
	var positie
	var taalindex
	var taal_oud
	pagina = location.href;
	positie = pagina.indexOf("lang=") + 5;
	taalindex = pagina.substr(positie);
	taal_oud = "lang=" + taalindex;
	taal = "lang=" + taal;
	pagina = pagina.replace(taal_oud, taal);
	window.location.replace(pagina);
	}
}

function SwitchRelated() {
	var pagina
	pagina = document.location.href;
	if (document.getElementById('boolshowpackages').checked==true) {
		pagina = pagina.replace("&showpackages=0", "&showpackages=1");		
		window.location.replace(pagina);
	} else {
		pagina = pagina.replace("&showpackages=1", "&showpackages=0");
		window.location.replace(pagina);
	}
}

function switch_div (divId, vorigedivId, positie) {
	var divteller = 0;
	if (divId == 0) {
		while (divteller <= 1000) {
			if (document.getElementById(divteller)) {

				document.getElementById(divteller).style.visibility = 'hidden';
			}
		divteller = divteller + 1;
		}
		
	} 
	else {
		//var mijnId = document.getElementById(divId).id;
		while (divteller <=1000) {
			if (document.getElementById(divteller)) {
				if (document.getElementById(divteller).id == divId) {
				document.getElementById(divteller).style.visibility = "visible";
				} 
				else if (document.getElementById(divteller).id == vorigedivId) {
				document.getElementById(divteller).style.visibility = "visible";
				}
				else {
				document.getElementById(divteller).style.visibility = "hidden";
				}
			}
		divteller = divteller + 1;
		}
	}
	divId = 0;
	vorigedivId = 0;
}



function ToggleVisibility(div_id) {
	
	if (document.getElementById(div_id).style.visibility == "visible") {
		document.getElementById(div_id).style.visibility="hidden";
	} else {		
		document.getElementById(div_id).style.visibility="visible";
	}
}

function switchCustomerType(div1, div2) {
	
	var div_id1
	var div_id2
	div_id1 = 'div_' + div1
	div_id2 = 'div_' + div2
	document.getElementById(div_id1).style.visibility='visible';
	document.getElementById(div_id1).style.position='relative';
	if (div_id1 == 'div_new') {
		document.getElementById(div_id1).style.top='-120px';
	} else { }
	document.getElementById(div_id2).style.visibility='hidden';
	
}

function checkFormNumberEntry(veldnaam) {
	if (isNaN(document.getElementById(veldnaam).value)) {
		var pagina;
		var taalindex;
		var positie;
		var boodschap;
		pagina = location.href;
		positie = pagina.indexOf("lang=") + 5;
		taalindex = pagina.substr(positie);
		if (taalindex == 'N') {
			boodschap = "Geen geldige waarde ingegeven";
		} 
		else if (taalindex == 'F') {
			boodschap = "Valeur non-numérique";
		}
		else {
			boodschap = "Invalid form entry";
		}
		
		window.alert(boodschap);
		document.getElementById(veldnaam).focus;
		document.getElementById("submit").disabled = true;
	} else {
		document.getElementById("submit").disabled = false;
	}
}

function validateLoginForm()  {
	var fout;
	fout = 0;
	var pagina;
		var taalindex;
		var positie;
		var msg_email;
		var msg_btw
		pagina = location.href;
		positie = pagina.indexOf("lang=") + 5;
		taalindex = pagina.substr(positie);
		if (taalindex == 'N') {
			msg_email = "Geen geldig e-mailadres ingegeven.";
			msg_btw = "Geen btw-nummer ingegeven.";
		} 
		else if (taalindex == 'F') {
			msg_email = "Invalid e-mail address.";
			msg_btw = "VAT number missing.";
		}
		else {
			msg_email = "Invalid e-mail address.";
			msg_btw = "VAT number missing.";
		}
	
	if (document.customerform.txtemail.value == "") {
		alert(msg_email)
		fout = 1;
		document.customerform.txtemail.focus();
		
		return false;
	}
	if (document.customerform.txtemail.value.indexOf("@")<=0||(document.customerform.txtemail.value.lastIndexOf(".") <document.customerform.txtemail.value.indexOf("@"))) {
		alert(msg_email)
		fout = 1;
		document.customerform.txtemail.focus();
		
		return false;
		
	}
	
	if (document.customerform.txtbtwnr.value == "") {
		alert(msg_btw)
		fout = 1;
		document.customerform.txtbtwnr.focus();
		
		return false;
	}
	
	if (fout == 1) {
		return false;
		} else {
		return true;
		}
	
}

function recalcUnits(aantaleenh, ean) {
	var strveld;
	strveld = 'units_' + ean;
	document.getElementById(strveld).value = (document.getElementById(ean).value*aantaleenh + ' ex.');
	document.getElementById("btnupdate").focus();
}

function setImageSize() {
	if (document.getElementById("productimg").width < 300)
		{
		} else {
			document.getElementById("productimg").width = 300;
		}
}


