function raiseValue(elem){
	var obj = document.getElementById(elem);
	var objvalue = parseInt(obj.value);
	if(isNaN(objvalue))
	{
		obj.value = '1';
	}
	else
	{
		var objnewvalue = objvalue + 1;
		obj.value = objnewvalue + '';
	}
}

function decreaseValue(elem){
	var obj = document.getElementById(elem);
	var objvalue = parseInt(obj.value);
	if(objvalue > 0){
		var objnewvalue = objvalue - 1;
		obj.value = objnewvalue + '';
	}
	else
	{
		obj.value='0';
	}
}

function matchHeight()
{
	var divs,contDivs,maxHeight,divHeight,d;
	// get all <div> elements in the document
	divs=document.getElementsByTagName('div');
	contDivs=[];
	// initialize maximum height value
	maxHeight=0;
	// iterate over all <div> elements in the document
	for(var i=0;i<divs.length;i++)
	{
		// make collection with <div> elements with class attribute 'column'
		if(/\bcolumn\b/.test(divs[i].className))
		{
			d=divs[i];
			contDivs[contDivs.length]=d;
			// determine height for <div> element
			if(d.offsetHeight)
			{
				divHeight=d.offsetHeight;
			}
			else
			{
				if(d.style.pixelHeight)
				{
					divHeight=d.style.pixelHeight;
				}
			}
			// calculate maximum height
			maxHeight=Math.max(maxHeight,divHeight);
		}
	}
	// assign maximum height value to all of container <div> elements
	for(var i=0;i<contDivs.length;i++)
	{
		contDivs[i].style.height=maxHeight+'px';
	}
}

function buttonsIE() {
	if (typeof(window.rounded_elements) == 'undefined') { return(false); }

	for (var i in window.rounded_elements)
	{
		var el = window.rounded_elements[i];

		var strokeWeight = 0;
		if(el.currentStyle)
		{
			strokeWeight = parseInt(el.currentStyle.borderWidth);

			if (isNaN(strokeWeight)) { strokeWeight = 0; }

			if(el.vml && el.vml.parentNode)
			{
				var parent_pos = findPositionJS(el.vml.parentNode);
				var pos = findPositionJS(el);
				pos.y = pos.y + (0.5 * strokeWeight) - parent_pos.y;
				pos.x = pos.x + (0.5 * strokeWeight) - parent_pos.x;

				el.vml.style.top = pos.y +'px';
				el.vml.style.left = pos.x +'px';
				el.vml.style.width = el.offsetWidth +'px';
				el.vml.style.height = el.offsetHeight +'px';
			}
		}
	}
}

function findPositionJS(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}

	return({
	'x': curleft,
	'y': curtop
	});
}

function logincheckoutenter(e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if(keycode==13)
	{
		CheckPasswordAccount(document.getElementById('email2').value,document.getElementById('password').value,'true');
		return false;
	}
	else
	{
		return true;
	}
}

function newsletterenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
	{
		subscribe();
		return false;
	}
	else
	{
		return true;
	}
}

function loginenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
	{
		login();
		return false;
	}
	else
	{
		return true;
	}
}


function UpdatePrice(articleno, priceno, optionno)
{

	var keeper = new sack();
	keeper.requestFile="/updateprice.php?articleno="+articleno+"&priceno="+priceno;
	keeper.onCompletion = function()
	{
		if(keeper.response!="0")
		{
			eval("var data = "+ keeper.response);
			if(document.getElementById('priceid'+articleno+"_"+optionno))
			{
				//var oldinnerhtml=document.getElementById('priceid'+articleno+"_"+optionno).innerHTML;
				if(data.specialoffer=='Y')
				{
					document.getElementById('priceid'+articleno+"_"+optionno).innerHTML="<span class='oldprice'>&euro;&nbsp;"+data.price+"<\/span>&nbsp;&nbsp;<span class='price'>&euro;&nbsp;"+data.specialprice+"<\/span>";
				}
				else
				{
					document.getElementById('priceid'+articleno+"_"+optionno).innerHTML="<span class='price'>&euro;&nbsp;"+data.price+"<\/span>";
				}
			}

			if(document.getElementById('deliveryid'+articleno+"_"+optionno))
			{
				//var oldinnerhtml=document.getElementById('priceid'+articleno+"_"+optionno).innerHTML;
				document.getElementById('deliveryid'+articleno+"_"+optionno).innerHTML=data.deliverytime;
			}
		}
	};
	keeper.runAJAX();
}

/*
function chkForm()
{
var frm = document.getElementById('checkout');
var company = trim(frm.companyname.value);
var firstname = trim(frm.firstname.value);
var lastname = trim(frm.lastname.value);
var address = trim(frm.address.value);
var zipcode = trim(frm.zipcode.value);
var city = trim(frm.city.value);
var email = trim(frm.email.value);
var delivfirstname = trim(frm.delivfirstname.value);
var delivlastname = trim(frm.delivlastname.value);
var delivaddress = trim(frm.delivaddress.value);
var delivzipcode = trim(frm.delivzipcode.value);
var delivcity = trim(frm.delivcity.value);
var delivemail = trim(frm.delivemail.value);
var vatpr = trim(frm.vatpr.value);
var vatnr = trim(frm.vatpr.value);


if (firstname=="" || lastname=="" || address=="" || zipcode=="" || city=="" || email=="")
{
alert("<?php echo $js_verplicht;?>");
return false;
}

if (frm.email.value!="")
{
if (frm.email.value.indexOf("@")==-1 || frm.email.value.indexOf(".")==-1 || frm.email.value.indexOf(" ")!=-1 || frm.email.value.length<6)
{
alert("<?php echo $js_email;?>");
frm.email.focus();
return false;
}
}


if (frm.chkdelivery[1].checked)
{
if (delivfirstname=="" || delivlastname=="" || delivaddress=="" || delivzipcode=="" || delivcity=="" || delivemail=="")
{
alert("<?php echo $js_verplichtlevering;?>");
return false;
}

if (frm.delivemail.value!="")
{
if (frm.delivemail.value.indexOf("@")==-1 || frm.delivemail.value.indexOf(".")==-1 || frm.delivemail.value.indexOf(" ")!=-1 || frm.delivemail.value.length<6)
{
alert("<?php echo $js_emaillevering;?>");
frm.email.focus();
return false;
}
}
}

frm.submit();
}
*/

function CheckOutController(id)
{
	$('checkoutproclogin').hide();
	$('checkoutprocinvoice').hide();
	$('checkoutprocdelivery').hide();
	$('checkoutprocpayment').hide();
	$('checkoutprocoverview').hide();
	$('checkoutprocconfirmation').hide();
	switch(id)
	{
		case 1:
		CheckPasswordAccount($('email').value, $('password').value,'true');
		break;
		case 2:
		CheckFacData();
		break;
		case 3:
		CheckDelData()
		break;
		case 4:
		SetPaymentSub();
		GetProcOverview();
		break;
	}
	buttonsIE();
}

function CheckFacData()
{
	var empty = "no";

	if(!CheckForEmpty($('inv_lastname').value, $('error-invoice'), 'inv_lastname'))
	{
		empty = "yes";
	}
	if(!CheckForEmpty($('inv_firstname').value, $('error-invoice'), 'inv_firstname'))
	{
		empty = "yes";
	}
	if(!CheckForEmpty($('inv_address').value, $('error-invoice'), 'inv_address'))
	{
		empty = "yes";
	}
	if(!CheckForEmpty($('inv_zipcode').value, $('error-invoice'), 'inv_zipcode'))
	{
		empty = "yes";
	}
	if(!CheckForEmpty($('inv_city').value, $('error-invoice'), 'inv_city'))
	{
		empty = "yes";
	}

	if($('inv_vattype_comp').checked==true)
	{
		if(!CheckForEmpty($('inv_companyname').value, $('error-invoice'), 'inv_companyname'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('inv_vatpr').value, $('error-invoice'), 'inv_vatpr'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('inv_vatnr').value, $('error-invoice'), 'inv_vatnr'))
		{
			empty = "yes";
		}
		else
		{
			if(CheckBTWnr($('inv_vatpr').value, $('inv_vatnr').value)>1)
			{
				empty = "yes";
				$('error-invoice').style.display = 'block';
				$('inv_vatpr').className = 'inputformerror';
				$('inv_vatnr').className = 'inputformerror';
			}
			else
			{
				$('inv_vatpr').className = 'inputfield';
				$('inv_vatnr').className = 'inputfield';
			}
		}

	}
	if(empty == "no")
	{
		$('error-invoice').style.display = 'none';
		$('checkoutprocdelivery').show();
		document.getElementById("chkdeliveryon").focus();

		var pageTracker = _gat._getTracker("UA-16503597-1");
		pageTracker._trackPageview("/checkout/deliveryinfo");

		$('tabinvoice').className = 'checkoutproctab';
		$('tabdelivery').className = 'checkoutproctabsel';
	}
	else
	{
		$('checkoutprocinvoice').show();
	}
}

function CheckDelData()
{
	if(document.getElementById('chkdeliveryon').checked)
	{
		// facturatiegegevens zijn zelfde als transportgegevens
		$('delivcountrycode').value = $('inv_countrycode').value
		$('delivcompanyname').value = $('inv_companyname').value
		$('delivfirstname').value = $('inv_firstname').value
		$('delivlastname').value = $('inv_lastname').value
		$('delivaddress').value = $('inv_address').value
		$('delivaddress2').value = $('inv_address2').value
		$('delivcity').value = $('inv_city').value
		$('delivzipcode').value = $('inv_zipcode').value
		$('delivphone').value = $('inv_phone').value
		$('delivmobile').value = $('inv_mobile').value
		$('checkoutprocpayment').show();
		document.getElementById("pay1").focus();
		var pageTracker = _gat._getTracker("UA-16503597-1");
		pageTracker._trackPageview("/checkout/paymentinfo");

		$('tabdelivery').className = 'checkoutproctab';
		$('tabpayment').className = 'checkoutproctabsel';
	}
	else
	{
		var empty = "no";

		if(!CheckForEmpty($('delivlastname').value, $('error-delivery'), 'delivlastname'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('delivfirstname').value, $('error-delivery'), 'delivfirstname'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('delivaddress').value, $('error-delivery'), 'delivaddress'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('delivzipcode').value, $('error-delivery'), 'delivzipcode'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('delivcity').value, $('error-delivery'), 'delivcity'))
		{
			empty = "yes";
		}
		if(!CheckForEmpty($('delivemail').value, $('error-delivery'), 'delivemail'))
		{
			empty = "yes";
		}
		if(empty == "no")
		{
			$('checkoutprocpayment').show();
			var pageTracker = _gat._getTracker("UA-16503597-1");
			pageTracker._trackPageview("/checkout/paymentinfo");

			$('tabdelivery').className = 'checkoutproctab';
			$('tabpayment').className = 'checkoutproctabsel';
		}
		else
		{
			$('checkoutprocdelivery').show();
		}
	}
}

function GetProcOverview()
{
	// facturatiegegevens tonen
	if($('inv_companyname').value>"")
	$('ovw_companyname').innerHTML = $('inv_companyname').value;
	else
	$('tr_companyname').style.display = "none";
	$('ovw_firstname').innerHTML = $('inv_firstname').value;
	$('ovw_lastname').innerHTML = $('inv_lastname').value;
	$('ovw_address').innerHTML = $('inv_address').value;
	if($('inv_address2').value>"")
	$('ovw_address2').innerHTML = $('inv_address2').value;
	else
	$('tr_address2').style.display = "none";
	$('ovw_city').innerHTML = $('inv_city').value;
	GetCountry($('inv_countrycode').value,$('ovw_country'));
	$('ovw_zipcode').innerHTML = $('inv_zipcode').value;
	if($('inv_phone').value>"")
	$('ovw_phone').innerHTML = $('inv_phone').value;
	else
	$('tr_phone').style.display = "none";
	if($('inv_fax').value>"")
	$('ovw_fax').innerHTML = $('inv_fax').value;
	else
	$('tr_fax').style.display = "none";
	if($('inv_mobile').value>"")
	$('ovw_mobile').innerHTML = $('inv_mobile').value;
	else
	$('tr_mobile').style.display = "none";
	if($('inv_vatnr').value>"")
	$('ovw_vat').innerHTML = $('inv_vatpr').value+'-'+$('inv_vatnr').value;
	else
	$('tr_vat').style.display = "none";

	// leveringsgegevens tonen
	if($('delivcompanyname').value>"")
	$('ovw_del_companyname').innerHTML = $('delivcompanyname').value;
	else
	$('tr_del_companyname').style.display = "none";

	$('ovw_del_firstname').innerHTML = $('delivfirstname').value;
	$('ovw_del_lastname').innerHTML = $('delivlastname').value;
	$('ovw_del_address').innerHTML = $('delivaddress').value;
	if($('delivaddress2').value>"")
	$('ovw_del_address2').innerHTML = $('delivaddress2').value;
	else
	$('tr_del_address2').style.display = "none";
	$('ovw_del_city').innerHTML = $('delivcity').value;
	$('ovw_del_zipcode').innerHTML = $('delivzipcode').value;

	GetCountry($('delivcountrycode').value,$('ovw_del_country'));

	if($('delivphone').value>"")
	$('ovw_del_phone').innerHTML = $('delivphone').value;
	else
	$('tr_del_phone').style.display = "none";
	if($('delivmobile').value>"")
	$('ovw_del_mobile').innerHTML = $('delivmobile').value;
	else
	$('tr_del_mobile').style.display = "none";
	if($('delivemail').value>"")
	{
		$('ovw_del_email').innerHTML = $('delivemail').value;
	}
	else
	{
		$('tr_del_email').style.display="none";
	}

	// remarks tonen
	if(document.getElementById('remarks').value>"")
	{
		$('ovw_remarks').innerHTML = document.getElementById('remarks').value.replace(/\n/g,'<br>');
	}
	else
	{
		$('tbl_remarks').style.display="none";
	}
	$('checkoutprocoverview').show();
	var pageTracker = _gat._getTracker("UA-16503597-1");
	pageTracker._trackPageview("/checkout/overview");
}

function CheckForEmpty(valuestr, element, obj)
{
	if(valuestr == "")
	{
		if(obj != "")
		{
			$(obj).className = 'inputformerror';
			$(element).style.display = 'block';
		}
		return false;
	}
	else
	{
		if(obj != "")
		{
			$(obj).className = 'inputfield';
		}
		return true;
	}
}

function IsNumeric(strString)
{
	var strValidChars="0123456789,-";
	var strChar;
	var blnResult=true;

	if (strString.length == 0) return false;

	//  test strString consists of valid characters listed above
	for (i=0; i < strString.length && blnResult == true; i++)
	{
		strChar=strString.charAt(i);
		if(strValidChars.indexOf(strChar) == -1)
		{
			blnResult=false;
		}
	}
	return blnResult;
}

function CheckBTWnr(vatpr, vatnr)
{
	if(vatpr == 'BE')
	{
		if(IsNumeric(vatnr))
		{
			if (vatnr.length == 9)
			{
				vatnr=0+vatnr;
			}
			else if (vatnr.length == 10)
			{
				if (vatnr.charAt(0)!=0)
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
		if(parseFloat(vatnr.substr(0, 8))<=0)
		{
			return false;
		}

		if (parseFloat(vatnr.substr(8, 2)) == (97 - (parseFloat(vatnr.substr(1,7))%97)))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return true;
	}
}

function SetPaymentDesc(id,max)
{
	for(i=1;i<=max;i++)
	{
		if(i==id)
		{
			$('paymentdesc'+i).show();
		}
		else
		{
			$('paymentdesc'+i).hide();
		}
	}
	buttonsIE();
}

function SetPaymentRadio(id,max)
{
	for(i=1;i<=max;i++)
	{
		if(i==id)
		{
			document.getElementById('payimg'+i).className = 'paymentimgsel';
			document.getElementById('pay'+i).checked = true;
		}
		else
		{
			document.getElementById('payimg'+i).className = 'paymentimg';
			document.getElementById('pay'+i).checked = false;
		}
	}
}

function SetPayment(id,max)
{
	for(i=1;i<=max;i++)
	{
		if(i==id)
		{
			document.getElementById('payimg'+i).className = 'paymentimgsel';
			$('paymentdesc'+i).show();
		}
		else
		{
			document.getElementById('payimg'+i).className = 'paymentimg';
			$('paymentdesc'+i).hide();
		}
	}
}

function ChangeCountryLanguage(script,qry,cur_country,cur_lang, itemid)
{
	if(script.indexOf("cart.php")>-1)
	{
		var newcountry = document.getElementById(itemid).value;
		var newlocation = script+'?'+qry;
		newlocation = newlocation.replace('transcountry='+cur_country,'transcountry='+newcountry);
		document.location=newlocation;
	}
	else
	{
		if(script.indexOf("checkout.php")>-1)
		{
			var newcountry = document.getElementById(itemid).value;
			var newlocation = script+'?'+qry;
			newlocation = newlocation.replace('transcountry='+cur_country,'transcountry='+newcountry);
			document.location=newlocation;
		}
	}
}

function html_entity_decode(str)
{
	var ta = document.createElement("textarea");
	ta.innerHTML = str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
	return ta.value;
}

function fctCheckout(lang,country,action,stars)
{
	switch (action)
	{
		case "recalculate":
		document.getElementById('subaction').value="recalculate";
		document.getElementById('basket').action="/cart.php?subaction=recalculate&lang="+lang+"&transcountry="+country;
		document.getElementById('basket').submit()
		break;

		case "checkout":
		document.getElementById('subaction').value="checkout";
		document.getElementById('basket').action="/checkout.php?lang="+lang+"&transcountry="+country;
		document.getElementById('basket').submit()
		break;
	}
}

//AJAX FUNCTIONS
function getCart(lang, transcountry)
{
	$$('#cartbody .smallbutton').each(function(item){
		if(item.vml)
		{
			item.vml.style.display='none';
		}
	});

	var keeper = new sack();
	keeper.requestFile = "/ajax_getcart.php?lang="+lang+"&transcountry="+transcountry;
	keeper.onCompletion = function()
	{
		if(keeper.response!="")
		{
			$('cartbody').innerHTML=keeper.response;
		}
	};
	keeper.runAJAX();
	return true;
}

function CalculateTransport(invcountry,country)
{
	var keeper = new sack();
	keeper.requestFile = "/ajax_calculatetransport.php?invcountry="+invcountry+"&country="+country;
	keeper.onCompletion = function()
	{
		eval("var response = "+ keeper.response);
		// transport kosten aanpassen
		if(response.transportfree=='N')
		{
			$('transport').innerHTML = '&euro; '+response.totalglobal;
			$('totalprice').innerHTML = '&euro; '+response.total;
		}
		else
		{
			$('transport').innerHTML = response.transportfreedesc;
			$('totalprice').innerHTML = '&euro; '+response.total;
		}
	};
	keeper.runAJAX();
	return true;
}

function GetShopcart(lang,country,clear)
{
	var keeper = new sack();
	keeper.requestFile = "/ajax_getshopcart.php?lang="+lang+"&country="+country+"&clear="+clear;
	keeper.onCompletion = function()
	{
		$('checkoutcart').innerHTML = html_entity_decode(keeper.response);
		if(CalculateTransport(country,country))
		{
			if(CalculateDiscountChk())
			{
				if(clear=='Y')
				{
					var keeper2 = new sack();
					keeper2.requestFile = "/ajax_clearshopcart.php";
					keeper2.onCompletion = function()
					{};
					keeper2.runAJAX();
				}
			}
		}
	};
	keeper.runAJAX();
}

function SetPaymentSub()
{
	var keeper = new sack();
	keeper.requestFile = "/ajax_getpaymentmethod.php";
	for (var i=1; i<=document.forms["frmcheckout"].paymentmethod.length;i++)
	{
		if($("pay"+i).checked)
		{
			var paymentno =	$("pay"+i).value;
		}
	}
	keeper.setVar("paymentno",paymentno);
	keeper.onCompletion = function()
	{
		eval("var response = "+ keeper.response);
		if(response.status)
		{
			$('ovw_paymentmethod').innerHTML = response.methoddesc;
			$('tabpayment').className = 'checkoutproctab';
			$('taboverview').className = 'checkoutproctabsel';
			if(paymentno==3)
			{
				$('ovw_paymentmethodamount').innerHTML = "&euro; 10,00";
			}
		}
	};
	keeper.runAJAX();
}

function GetCountry(country,field)
{
	var keeper = new sack();
	keeper.requestFile = "/ajax_getcountry.php?country="+country;
	keeper.onCompletion = function()
	{
		field.innerHTML = keeper.response;
	};
	keeper.runAJAX();
}


function CalculateDiscountChk()
{
	$$('#checkoutcart .smallbutton').each(function(item){
		if(item.vml)
		{
			item.vml.style.display='none';
		}
	});
	var continuecode = "N";
	if(document.getElementById('discountcode'))
	{
		if(document.getElementById('discountcode').value!='')
		{
			continuecode = "YC"
		}
	}
	else
	{
		continuecode = "Y";
	}
	if(continuecode!="N")
	{
		var keeper = new sack();
		if(document.getElementById('chkdeliveryon').checked == true)
		{
			var country = document.getElementById('inv_countrycode').value;
		}
		else
		{
			var country = document.getElementById('delivcountrycode').value;
		}
		if(continuecode=='YC')
		{
			keeper.requestFile="/ajax_calculatediscount.php?discountcode="+document.getElementById('discountcode').value;
		}
		else
		{
			keeper.requestFile="/ajax_calculatediscount.php?country="+country;
		}

		keeper.onCompletion = function()
		{
			eval("var ajax_response = "+ keeper.response);
			if(ajax_response.discountamount!='0,00000' || ajax_response.discountartname!='')
			{
				if(document.getElementById('trdiscounterror'))
				{
					document.getElementById('trdiscounterror').style.display='none';
					document.getElementById('trdiscounterror').style.visibility='hidden';
				}
				if(document.getElementById('trdiscountcode'))
				{
					var discountamount=ajax_response.discountamount;
					var discountvat=ajax_response.discountvat;
					discountamount=parseFloat(discountamount.replace(",","."));
					discountvat=parseFloat(discountvat.replace(",","."));
					discounttot=parseFloat(discountamount+(discountamount*discountvat/100));
					discounttot=Math.round(discounttot*100)/100;
					discounttot=discounttot.toFixed(2);
					discounttot=discounttot+'';
					discounttot=discounttot.replace(".",",");

					while (document.getElementById('trdiscountcode').firstChild)
					{
						//The list is LIVE so it will re-index each call
						document.getElementById('trdiscountcode').removeChild(document.getElementById('trdiscountcode').firstChild);
					}

					var kolom0 = document.createElement('td');
					kolom0.align='right';
					document.getElementById('trdiscountcode').appendChild(kolom0);

					var kolom1 = document.createElement('td');
					kolom1.align = 'left';
					kolom1.innerHTML = ajax_response.discountdesc;
					document.getElementById('trdiscountcode').appendChild(kolom1);

					var kolom2 = document.createElement('td');
					kolom2.align = 'right';
					if(ajax_response.discountartname!='')
					{
						kolom2.innerHTML = '<span class=\'discount\'>'+ajax_response.discountartname+'<\/span>';
					}
					else
					{
						kolom2.innerHTML = '<span class=\'discount\'>-&nbsp;&euro;&nbsp;'+discounttot+'<\/span>';
					}
					document.getElementById('trdiscountcode').appendChild(kolom2);

				}
				if(document.getElementById('trdiscountremove'))
				{

					while (document.getElementById('trdiscountremove').firstChild)
					{
						//The list is LIVE so it will re-index each call
						document.getElementById('trdiscountremove').removeChild(document.getElementById('trdiscountremove').firstChild);
					}

					var kolom1 = document.createElement('td');
					kolom1.colSpan=3;
					kolom1.align = 'right';
					kolom1.innerHTML = 	ajax_response.discountremove;
					document.getElementById('trdiscountremove').appendChild(kolom1);

					document.getElementById('trdiscountremove').style.display='';
					document.getElementById('trdiscountremove').style.visibility='visible';
				}

				if(document.getElementById('chkdeliveryon').checked == true)
				{
					CalculateTransport(document.getElementById('inv_countrycode').value,document.getElementById('inv_countrycode').value);
				}
				else
				{
					CalculateTransport(document.getElementById('inv_countrycode').value,document.getElementById('delivcountrycode').value);
				}
			}
			else
			{
				if(document.getElementById('trdiscounterror'))
				{
					while (document.getElementById('trdiscounterror').firstChild)
					{
						//The list is LIVE so it will re-index each call
						document.getElementById('trdiscounterror').removeChild(document.getElementById('trdiscounterror').firstChild);
					}
					var kolom1 = document.createElement('td');
					kolom1.colSpan=3;
					kolom1.align = 'right';
					kolom1.className = 'checkout_error';
					kolom1.innerHTML = 	ajax_response.discounterror;


					document.getElementById('trdiscounterror').appendChild(kolom1);

					document.getElementById('trdiscounterror').style.display='';
					document.getElementById('trdiscounterror').style.visibility='visible';
				}

				if(document.getElementById('trdiscountremove'))
				{

					while (document.getElementById('trdiscountremove').firstChild)
					{
						//The list is LIVE so it will re-index each call
						document.getElementById('trdiscountremove').removeChild(document.getElementById('trdiscountremove').firstChild);
					}

					var kolom1 = document.createElement('td');
					kolom1.colSpan=3;
					kolom1.align = 'right';
					kolom1.innerHTML = 	ajax_response.discountremove;
					document.getElementById('trdiscountremove').appendChild(kolom1);

					document.getElementById('trdiscountremove').style.display='';
					document.getElementById('trdiscountremove').style.visibility='visible';
				}
			}
		};
		keeper.runAJAX();
	}
}

function ResetDiscount()
{
	var keeper = new sack();
	//keeper.requestFile="/ajax_resetdiscount.php?transcountry="+document.getElementById('transcountry').value;
	keeper.requestFile="/ajax_resetdiscount.php";
	keeper.onCompletion = function()
	{
		if(document.getElementById('trdiscountcode'))
		{
			while (document.getElementById('trdiscountcode').firstChild)
			{
				//The list is LIVE so it will re-index each call
				document.getElementById('trdiscountcode').removeChild(document.getElementById('trdiscountcode').firstChild);
			}

			eval(keeper.response);

			if(document.getElementById('trdiscountremove'))
			{
				while (document.getElementById('trdiscountremove').firstChild)
				{
					//The list is LIVE so it will re-index each call
					document.getElementById('trdiscountremove').removeChild(document.getElementById('trdiscountremove').firstChild);
				}

				document.getElementById('trdiscountremove').style.display='none';
				document.getElementById('trdiscountremove').style.visibility='hidden';
			}

			if(document.getElementById('trdiscounterror'))
			{
				while (document.getElementById('trdiscounterror').firstChild)
				{
					document.getElementById('trdiscounterror').removeChild(document.getElementById('trdiscounterror').firstChild);
				}
				document.getElementById('trdiscounterror').style.display='none';
				document.getElementById('trdiscounterror').style.visibility='hidden';
			}

			if(document.getElementById('chkdeliveryon').checked == true)
			{
				CalculateTransport(document.getElementById('inv_countrycode').value,document.getElementById('inv_countrycode').value);
			}
			else
			{
				CalculateTransport(document.getElementById('inv_countrycode').value,document.getElementById('delivcountrycode').value);
			}
		}
		else
		{
			while (document.getElementById('cartdiscountcode').firstChild)
			{
				//The list is LIVE so it will re-index each call
				document.getElementById('cartdiscountcode').removeChild(document.getElementById('cartdiscountcode').firstChild);
			}

			eval(keeper.response);

			if(document.getElementById('cartdiscountremove'))
			{
				while (document.getElementById('cartdiscountremove').firstChild)
				{
					//The list is LIVE so it will re-index each call
					document.getElementById('cartdiscountremove').removeChild(document.getElementById('cartdiscountremove').firstChild);
				}

				document.getElementById('cartdiscountremove').style.display='none';
				document.getElementById('cartdiscountremove').style.visibility='hidden';
			}

			CalculateTransport(document.getElementById('countryselecttransport').value,document.getElementById('countryselecttransport').value);
		}
	};
	keeper.runAJAX();
}

//Links target_blank opvangen
function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}

/**
* This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
*/

function writeFlash(p) {
	writeEmbed(
	'D27CDB6E-AE6D-11cf-96B8-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
	'application/x-shockwave-flash',
	p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
	p
	);
}

function writeQuickTime(p) {
	writeEmbed(
	'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
	'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
	'video/quicktime',
	p
	);
}

function writeRealMedia(p) {
	writeEmbed(
	'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
	'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
	'audio/x-pn-realaudio-plugin',
	p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
	'6BF52A52-394A-11D3-B153-00C04F79FAA6',
	'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
	'application/x-mplayer2',
	p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
	h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
	h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}

