function costExtraCountry(countryId){
if(countryId == 1){return 2.97;} 
if(countryId == 2){return 21.69;} 
if(countryId == 3){return 20.85;} 
if(countryId == 4){return 2.97;} 
if(countryId == 5){return 25.44;} 
if(countryId == 6){return 11.32;} 
if(countryId == 7){return 12.3;} 
if(countryId == 8){return 7.63;} 
if(countryId == 9){return 11.32;} 
if(countryId == 10){return 30.48;} 
if(countryId == 11){return 8.91;} 
if(countryId == 12){return 11.32;} 
if(countryId == 13){return 25.48;} 
if(countryId == 14){return 25.48;} 
if(countryId == 15){return 5.93;} 
if(countryId == 16){return 10.88;} 
if(countryId == 17){return 11.32;} 
if(countryId == 19){return 8.05;} 
if(countryId == 20){return 10.88;} 
if(countryId == 21){return 29.86;} 
if(countryId == 22){return 21.69;} 
if(countryId == 23){return 10.88;} 
if(countryId == 24){return 10.88;} 
if(countryId == 25){return 13;} 
if(countryId == 26){return 8.91;} 
if(countryId == 27){return 11.32;} 
if(countryId == 28){return 7.63;} 
if(countryId == 29){return 7.63;} 
return 0 ;}
function costExtraCountryKg(countryId){
if(countryId == 1){return 0.49 ;} 
if(countryId == 2){return 0.83 ;} 
if(countryId == 3){return 1.5 ;} 
if(countryId == 4){return 0.49 ;} 
if(countryId == 5){return 0.83 ;} 
if(countryId == 6){return 1.63 ;} 
if(countryId == 7){return 0.55 ;} 
if(countryId == 8){return 0.55 ;} 
if(countryId == 9){return 1.63 ;} 
if(countryId == 10){return 0.83 ;} 
if(countryId == 11){return 0.55 ;} 
if(countryId == 12){return 1.63 ;} 
if(countryId == 13){return 0.83 ;} 
if(countryId == 14){return 0.83 ;} 
if(countryId == 15){return 0.55 ;} 
if(countryId == 16){return 0.83 ;} 
if(countryId == 17){return 1.63 ;} 
if(countryId == 19){return 0.55 ;} 
if(countryId == 20){return 0.83 ;} 
if(countryId == 21){return 0.83 ;} 
if(countryId == 22){return 0.83 ;} 
if(countryId == 23){return 0.83 ;} 
if(countryId == 24){return 0.83 ;} 
if(countryId == 25){return 0.83 ;} 
if(countryId == 26){return 0.55 ;} 
if(countryId == 27){return 1.63 ;} 
if(countryId == 28){return 0.55 ;} 
if(countryId == 29){return 0.55 ;} 
return 0.2 ;}
function getObject(name)
{
	var obj;
	if (document.getElementById)
	{
		obj = document.getElementById(name);
	}
	else if (document.all)
	{
		obj = document.all[name];
	}
	else if (document.layers)
	{
		obj = document.layers[name];
	}
	return obj;
}
function fixUrlName(name){
    return name.replace("&", "%26");
}
function showHideByHeight(item){
	var show = getObject(item);
	if(show.style.height == "0px"){
		show.style.height = "auto";
		show.style.visibility="visible";
		show.style.position='static';
	}
	else {
		show.style.height = "0px";
		show.style.visibility="hidden";
		show.style.position='absolute';
	}
}
function setExtra(form){
    try{
    	var extra = getObject("extra");
    	var size = getObject("size");
    	var color = getObject("color");
    	var comment = getObject("comment");
    	extra.value ="";
    	if(size != null)
    		extra.value += (" [Maat: " + size.value + "]");
    	if(color != null)
    		extra.value += (" [Kleur: " + color.value + "]");
        return true;
    }catch(e){ alert('Error: Please contact Europe Web Company...'); return false;}
}
function generalCheck(name){
	var errorField = getObject('error');
	var field = getObject(name).value;
	if (field == "" ){
		errorField.innerHTML = "In het invoerveld bevindt zich geen informatie.";
		scroll(0,0);
		return false;
	}
	else {
		return true;
	}
}
function validGoldcard(form){
	var fieldEmail = form.gebruikersnaam.value;
	var fieldPassword = form.password.value;
	var fieldCode = form.code.value;
	var errorField = getObject('error');
    if (fieldEmail.indexOf('@') < 1 ) {
    	errorField.innerHTML = "Dit emailadres is onjuist.";
    	scroll(0,0);
    	return false;
    } if (fieldEmail.indexOf(' ') > 1) {
    	errorField.innerHTML = "Email is niet juist. Er bevindt zich een spatie in het adres";
    	scroll(0,0);
    	return false;
    } if (fieldPassword.length == 0) {
    	errorField.innerHTML = "U moet wel een wachtwoord invullen (min. 3 karakters).";
    	scroll(0,0);
    	return false;
    } if (fieldCode.length != 10) {
    	errorField.innerHTML = "U moet wel een goldcard nummer invullen van 10 karakters.";
    	scroll(0,0);
    	return false;
    }
}
function payNow(txt){
    var coupon = getObject('coupon').value;
    var totalPrice = getObject('totalPrice').innerHTML.replace(/<[^>]+>/g,"");
    if(getObject('totalPriceIncl') != null) // B2B
        totalPrice = getObject('totalPriceIncl').innerHTML;
    var payMethode = getObject('payMethode').value;
    var pickUp = "false";
    if(getObject('pickUp') != null) // pickup
        pickUp = getObject('pickUp').checked;
    var byMail = "false";
    if(getObject('bymail') != null) // bymail
        byMail = getObject('bymail').checked;
    var payUrl = 'shoppingcart_placeOrder.php?totalPrice='+ totalPrice +'&coupon='+ coupon +'&delivery='+ pickUp +'&bymail='+ byMail +'&pm='+  payMethode + txt;
    if(payMethode == 2){
        scroll(0,0);
        getObject("blindIt").style.height = "300%";
        showFadedObject("blindIt");
        setTimeout("showPayNowIframe('"+payUrl+"')", 400);
    }
    else{
        getObject("paynowform").action = payUrl;
        getObject("paynowform").submit();
    }
}
function showPayNowIframe(payUrl){
    visibility('div_iframe', 'visible');
    getObject("PPLink").innerHTML = "Klik hier als u niet automatisch wordt doorgeschakeld  
";
  	mywindow=open(payUrl,'PayPal','resizable=yes,scrollbars=1,width=800,height=600');
}
function setShippingcost(checkbox){
    var totalPrice = getObject('totalPrice').innerHTML.replace(/<[^>]+>/g,"");
    if(checkbox.checked){
        if(getObject('bymail') != null) // bymail
            getObject('bymail').disabled = true;
        var shippingCost = getObject('shippingCost').innerHTML;
        getObject('shippingCost').innerHTML = "0.00";
        getObject('totalPrice').innerHTML = (totalPrice - shippingCost).toFixed(2);
        if(getObject('totalPriceIncl') != null){ // B2B
            var inclTotal = 0;
            var incl = getObject('incl_1');  //skip shippingcost
            var counter = 1; //skip shippingcost
            while (incl != null){
                inclTotal += (incl.value *100);
                counter++;
                incl = getObject('incl_' + counter);
            }
            inclTotal = inclTotal / 100; // do it like this... because there is a bug in parseInt etc
            getObject('totalPriceIncl').innerHTML = (inclTotal).toFixed(2);
        }
    }
    else {
        if(getObject('bymail') != null) // bymail
            getObject('bymail').disabled = false;
        var oriShippingcost = getObject('oriShippingcost').value;
        getObject('shippingCost').innerHTML = oriShippingcost;
        getObject('totalPrice').innerHTML = ((totalPrice * 1) + (oriShippingcost *1)).toFixed(2);
        if(getObject('totalPriceIncl') != null){ // B2B
            var inclTotal = 0;
            var incl = getObject('incl_0');
            var counter = 0;
            while (incl != null){
                inclTotal += incl.value *100;
                counter++;
                incl = getObject('incl_' + counter);
            }
            inclTotal = inclTotal / 100; // do it like this... because there is a bug in parseInt etc
            getObject('totalPriceIncl').innerHTML = (inclTotal).toFixed(2);
        }
    }
}
function validateEmailProduct(object) {
	if ((object.toaddress.value.length < 1) || (object.toaddress.value.indexOf("@") < 1)  || (object.toaddress.value.lastIndexOf(".") <= object.toaddress.value.indexOf("@")) || (object.toaddress.value.indexOf("@") == object.toaddress.value.length) || (object.toaddress.value.indexOf(".") == object.toaddress.value.length)){
		alert("Ontvanger e-mail adres is niet (juist) ingevuld
");
		object.toaddress.focus();
		return false;
	} else if ((object.fromaddress.value.length < 1) || (object.fromaddress.value.indexOf("@") < 1)  || (object.fromaddress.value.lastIndexOf(".") <= object.fromaddress.value.indexOf("@")) || (object.fromaddress.value.indexOf("@") == object.fromaddress.value.length) || (object.fromaddress.value.indexOf(".") == object.fromaddress.value.length)){
		alert("Zender e-mail adres is niet (juist) ingevuld
");
		object.fromaddress.focus();
		return false;
	}
	return true;
}
function setOrderTotal(){
    var total = 0;
    for (var x = 1; x < 200; x++){
        if(getObject('amount_'+x) != null){
            var aantal = getObject('amount_'+x).value;
            var prijs = getObject('pricepp_'+x).innerHTML;
            var lineprijs = (aantal * prijs);
            getObject('price_'+x).innerHTML = lineprijs.toFixed(2);
            total += (aantal * prijs);
        }
    }
    getObject('total').innerHTML = total.toFixed(2);
}
function openVerenigingPopup(){
	mywindow=open('chooseVereniging.php','EWC','resizable=yes,scrollbars=1,width=600,height=400');
	if (mywindow.opener == null)
		mywindow.opener = self;
}
function delVereniging(){
	var VerenigingId = getObject("verenigingID");
	var VerenigingName = getObject("verenigingName");
	VerenigingId.value = 0;
	VerenigingName.value = "";
}
function setPopupVerenigingValues(id, name){
	window.opener.setVereniging(id, name);
	window.close();
}
function setVereniging(id, name){
	var VerenigingId = getObject("verenigingID");
	var VerenigingName = getObject("verenigingName");
	VerenigingId.value = id;
	VerenigingName.value = name;
}
function validRegister(form) {
	var fieldPassword = form.password.value;
	var fieldPassword2 = form.password2.value;
	var errorField = getObject('error');
    if (fieldPassword == "" || fieldPassword.length < 2){
		errorField.innerHTML = "U moet wel een wachtwoord invullen (min. 3 karakters).";
		scroll(0,0);
		return false;
	}
	else if (fieldPassword != fieldPassword2 ){
		errorField.innerHTML = "De wachtwoorden komen niet overeen";
		scroll(0,0);
		return false;
	}
    // must be below Password!
	var fieldAdres = form.adres.value;
	var fieldPostcode = form.postcode.value;
	var fieldPlaats = form.plaats.value;
	var fieldNaam = form.naam.value;
	var fieldGeboortedatumY = form.geboortedatum_Y.value;
    var fieldGeboortedatumM = form.geboortedatum_M.value;
    var fieldGeboortedatumD = form.geboortedatum_D.value;
	var fieldEmail = form.email.value;
	var fieldHousenr = form.huisnr.value;
    try{
        var myDate=new Date();
        myDate.setFullYear(fieldGeboortedatumY,fieldGeboortedatumM-1,fieldGeboortedatumD);
        if(myDate.getDate() != fieldGeboortedatumD){
    		errorField.innerHTML = "U moet wel een geboortedatum invullen.";
    		scroll(0,0);
    		return false;
        }
    }catch(e){}
    if (fieldEmail.indexOf(' ') > 1 || fieldEmail.indexOf('@') < 1 ){
		errorField.innerHTML = "Dit emailadres is onjuist.";
		scroll(0,0);
		return false;
	}
	else if (fieldNaam == "" ){
		errorField.innerHTML = "U moet wel een naam invullen.";
		scroll(0,0);
		return false;
	}
	else if (fieldPostcode == "" ){
		errorField.innerHTML = "U moet wel een postcode opgeven.";
		scroll(0,0);
		return false;
	}
	else if (fieldPlaats == "" ){
		errorField.innerHTML = "U moet wel een woonplaats opgeven.";
		scroll(0,0);
		return false;
	}
	else if (fieldAdres == "" ){
		errorField.innerHTML = "U moet wel een adres opgeven.";
		scroll(0,0);
		return false;
	}
	else if (isNaN(fieldHousenr) || fieldHousenr == ""){
		errorField.innerHTML = "Het huisnummer is geen getal.";
		scroll(0,0);
		return false;
	}
	else {
		return true;
	}
}
function showDiv(nameObj, theText){
	var obj = getObject(nameObj);
	obj.innerHTML = theText;
}
function hideDiv(nameObj){
	var obj = getObject(nameObj);
	obj.innerHTML = "";
}
function showHideByDisplay(nameObj){
	var obj = getObject(nameObj);
    if(obj.style.display == "inline")
        obj.style.display = "none";
    else
        obj.style.display = "inline";
}
function PopupPic(id) {
	window.open("showPicture.php?ID=" + id,"","width=400,height=400,resizable,scrollbars=no,status=0");
}
function PopupPic2(id) {
	window.open("showPicture.php?p=2&ID=" + id,"","width=400,height=400,resizable,scrollbars=no,status=0");
}
function PopupPic3(id) {
	window.open("showPicture.php?p=3&ID=" + id,"","width=400,height=400,resizable,scrollbars=no,status=0");
}
function PopupPicFirma(id) {
	window.open("showPictureFirma.php?ID=" + id,"","width=400,height=400,resizable,scrollbars=no,status=0");
}
function PopupPicFirma2(id) {
	window.open("images/email_neutral/getPicEmailFirma.php?ID=" + id,"","width=400,height=400,resizable,scrollbars=no,status=0");
}
function startLoadingText(){
	var obj = getObject("loadingText");
	if (obj.style.MozOpacity && obj.style.MozOpacity<1.0){
		obj.style.MozOpacity= Math.min(parseFloat(obj.style.MozOpacity)+0.1, 0.99)
		setTimeout("startLoadingText()", 100);
	}
	else if (obj.filters && obj.filters.alpha.opacity<100){
		obj.filters.alpha.opacity+=10
		setTimeout("startLoadingText()", 100);
	}
}
var hideCountryMenuCounter = 3;
var hideCountryMenuStatus = 0; 		// 0 = false 1 = true
function visibility(id, style){
	getObject(id).style.visibility = style;
}
function showCountryMenuStart(){
	hideCountryMenuStatus = 0;
	hideCountryMenuCounter = 3;
	showCountryMenu();
}
function showCountryMenu(){
	var obj = getObject("CountryMenu");
	visibility("CountryMenu", "visible");
	if (obj.style.MozOpacity && obj.style.MozOpacity<0.99){
		obj.style.MozOpacity= Math.min(parseFloat(obj.style.MozOpacity)+0.1, 0.99)
		setTimeout("showCountryMenu()", 100);
	}
	else if (obj.filters && obj.filters.alpha.opacity<100){
		obj.filters.alpha.opacity+=10
		setTimeout("showCountryMenu()", 100);
	}
}
function hideCountryMenu(){
	if (hideCountryMenuCounter == 0){
		var obj = getObject("CountryMenu");
		if (obj.style.MozOpacity && obj.style.MozOpacity>0.3){
			obj.style.MozOpacity= Math.min(parseFloat(obj.style.MozOpacity)-0.1, 0.99)
			setTimeout("hideCountryMenu()", 100);
			if(obj.style.MozOpacity==0)
				visibility("CountryMenu", "hidden");
		}
		else if (obj.filters && obj.filters.alpha.opacity>30){
			obj.filters.alpha.opacity-=10
			setTimeout("hideCountryMenu()", 100);
			if(obj.filters.alpha.opacity==0)
				visibility("CountryMenu", "hidden");
		}
	}
}
function hideCountryMenuCountdown(){
	if (hideCountryMenuStatus == 1){
		if (hideCountryMenuCounter > 0){
			setTimeout("hideCountryMenuCountdown()", 1000);
			hideCountryMenuCounter = hideCountryMenuCounter-1;
		}
		else if (hideCountryMenuCounter == 0){
			hideCountryMenu();
		}
	}
}
function hideCountryMenuCountdownStart(){
	hideCountryMenuStatus = 1;
	hideCountryMenuCounter = 3;
	hideCountryMenuCountdown();
}
function stopCountryMenuCount(){
	showCountryMenuStart();
}
function startCountryMenuCount(){
	hideCountryMenuCounter = 5;
	hideCountryMenuCountdownStart();
}
function showHideTabpanel(id, numOfpanels){
    for(var i=0; i < numOfpanels; i++){
        // hide all bodys
    	var obj = getObject('tabbody_'+i);
        obj.style.display = "none";
        // fade all headers
        obj = getObject('tabheader_'+i);
		if (obj.style.MozOpacity)
			obj.style.MozOpacity= Math.min(0.6, 0.99)
        else if (obj.filters)
			obj.filters.alpha.opacity=60;
    }
    // display chosen body
    var obj = getObject('tabbody_'+id);
    obj.style.display = "inline";
    // show header
    obj = getObject('tabheader_'+id);
    if (obj.style.MozOpacity)
        obj.style.MozOpacity= Math.min(0.99, 0.99)
    else if (obj.filters)
        obj.filters.alpha.opacity=100;
}
function removeItem(item) {
	var answer = confirm ('Weet je zeker dat je dit product wilt verwijderen?')
	if (answer)
		window.location="shoppingcart_delItem.php?item=" + item;
}
function removeCart() {
	var answer = confirm ('Weet je zeker dat je de winkelwagen wilt leeghalen?')
	if (answer)
		window.location="shoppingcart_delAll.php";
}
function copySelection(container){
    var CopiedTxt = container.createTextRange();
    CopiedTxt.execCommand("Copy");
}