function setBetaalwijze(waarde)	{
		f = document.getElementById('shoppingcart');
		f.action.value="setBetaalwijze";
		f.submit();
	}
	
	function updateQuantity(f)	{
		aantallen = window.confirm('Heeft u aantallen gewijzigd?\nKlik op OK.\nDe totaalprijs wordt dan opnieuw berekend.');
		if (aantallen)	{
			f.submit();
		}
	}
	
	function clearCart()	{
		f = document.getElementById('shoppingcart');
		f.action.value="clearCart";
		f.submit();
	}
	function clearBetaalwijze()	{
		f = document.getElementById('shoppingcart');
		f.action.value="setBetaalwijze";
		f.submit();
	}
	
	function toggleVerzenden(value)	{
		k = document.getElementById('kantoor');
		if(value)	{
			k.style.display = "";
		}
		else	{
			k.style.display = "none";
		}
	}
	
	function showSubmenu(submenu)	{
		if(typeof curMenuNode != "undefined")	{
			curMenuNode.style.display = "none";
		}
		else	{
			document.getElementById('submenuRubrieken').style.display = "none";
		}
		curMenuNode = document.getElementById(submenu);
		curMenuNode.style.display = "";
	}
	
	function login(f)	{

		email = document.getElementById('email').value;
		wachtwoord = document.getElementById('wachtwoord').value;
		get = "xml_shop_login.php?e="+email+"&w="+wachtwoord;
		loadXMLDoc(get, fillNaw);
	}
	
	function fillNaw()	{
		
		if ((req.readyState == 4) && (req.status == 200)) {
			aKlant = req.responseXML.getElementsByTagName("klant");
			for(var i = 0; i < aKlant.length; i++)	{
				for (var j = 0; j < aKlant[i].childNodes.length; j++) {
					//probeer de matchende input te vinden
					if(document.getElementById(aKlant[i].childNodes[j].tagName))	{
						if(aKlant[i].childNodes[j].firstChild)	{
							document.getElementById(aKlant[i].childNodes[j].tagName).value = aKlant[i].childNodes[j].firstChild.data;
						}
					}
				}
			}
			if(aKlant.length==0)	{
				alert("helaas, deze inloggegevens zijn onjuist!");
			}
		}
	}

function copyAdres(fId)	{
	document.getElementById('afleveradres').value = document.getElementById('adres').value;
	document.getElementById('afleverpostcode').value = document.getElementById('postcode').value;
	document.getElementById('afleverwoonplaats').value = document.getElementById('woonplaats').value;
}


function getSelect3viaAjax()	{
	this.form.submit();
}

function setupSelect3()	{
	alert("deze functie gaat subonderdelen tonen (select 3)");
}

//wereldcadeaus, algemene gift
/*	niet (meer) gebruikt
function updateAlgGift(checkboxChecked)	{
	algGiftChecked	= document.getElementById("algGiftChecked");
	inputBedrag = document.getElementById("algGift");
	txtBedrag	= document.getElementById("txtBedrag");
	txtSubtotal	= document.getElementById("txtSubtotal");
	orgSubtotal	= document.getElementById("orgSubtotal");
	if(checkboxChecked)	{
		txtBedrag.firstChild.data = inputBedrag.value;
		algGiftChecked.checked = true;
	}	else	{
		txtBedrag.firstChild.data = "??";
		inputBedrag.value = 0;
		txtSubtotal.firstChild.data = parseInt(orgSubtotal.value);
	}
	
	if( (inputBedrag.value == 0) && (algGiftChecked==false) )	{
		txtBedrag.firstChild.data = "??";
		algGiftChecked.checked = false;
	}
	
	txtSubtotal.firstChild.data = parseInt(orgSubtotal.value) + parseInt(inputBedrag.value) + ",00";
	
}
*/
function parseQuantityUpdate(artikelId,selectbox)  {
	aantal = selectbox.options[selectbox.selectedIndex].value;
	
	// als er meer dan x wordt gekozen, de selectbox wijzigen naar een input type=text
	if(aantal=="meer")  {
		inputMeer = document.createElement("input");
		inputMeer.id = selectbox.id;
		inputMeer.type = "text";
		inputMeer.name = "quantity";
		inputMeer.size = 1;
		inputMeer.maxLength = 2;
		inputMeer.value = 6;

	
		inputMeer.onblur = function() { parseQuantityUpdateTextInput(artikelId,this);	}
//		inputMeer.onkeyup = function() { parseQuantityUpdateTextInput(artikelId,this);	}   //werkt dit wel in IE 6?

		//alert("doet ie nog mee? nee zeker? Ja toch! het heeft met de bovenstaande te maken?");
		parento = selectbox.parentNode;
		parento.replaceChild(inputMeer, selectbox);
		parseQuantityUpdateTextInput(artikelId, document.getElementById(selectbox.id));
		
	}   else    {
        get = "xml_shop_save_formdata.php?updateArtikel="+artikelId+"&aantal="+aantal;
		loadXMLDoc(get, callbackParseQuantityUpdate);
	}
}
function parseQuantityUpdateTextInput(artikelId,textinputobject) {

	var maxAantal = 5;
	aantal = textinputobject.value;
	if(aantal<=maxAantal)    {
		parento = textinputobject.parentNode;
		selectboxAantal =  document.createElement("select");
		selectboxAantal.id  = textinputobject.id;
		inputMeer.name = "quantity";
		for(i=0;i<5;i++)    {
			optionNode = document.createElement("option");
			optionNode.value = (i+1);
			textWaarde = document.createTextNode(i+1);
			if(aantal == (i+1)) {
				optionNode.selected = true;
			}
			optionNode.appendChild(textWaarde);
			selectboxAantal.appendChild(optionNode);
		}
        optionNodeMeer = document.createElement("option");
        optionNodeMeer.value = "meer";
        textWaardeMeer = document.createTextNode("> "+i);
        optionNodeMeer.appendChild(textWaardeMeer);
        selectboxAantal.appendChild(optionNodeMeer);
        selectboxAantal.onchange = function()   {	parseQuantityUpdate(artikelId,this);	}
		parento.replaceChild(selectboxAantal, textinputobject);
		parseQuantityUpdate(artikelId,document.getElementById(textinputobject.id));
	}   else    {
		get = "xml_shop_save_formdata.php?updateArtikel="+artikelId+"&aantal="+aantal;
		loadXMLDoc(get, callbackParseQuantityUpdate);
	}
}



function callbackParseQuantityUpdate()    {
	if ((req.readyState == 4) && (req.status == 200)) {
        artikelId = req.responseXML.getElementsByTagName("artikelId")[0].firstChild.data;
        artikelSubtotaal = req.responseXML.getElementsByTagName("artikelSubtotaal")[0].firstChild;
        subtotaal = req.responseXML.getElementsByTagName("subtotaal")[0].firstChild;
        oPrijsSpan = document.getElementById('prijsSpan_'+artikelId);
   		artikelSubtotaalTextNode = document.createTextNode(artikelSubtotaal.data);
        oPrijsSpan.replaceChild(artikelSubtotaalTextNode,oPrijsSpan.firstChild);

   
        subtotaal = req.responseXML.getElementsByTagName("subtotaal")[0].firstChild;
        oSubtotalSpan = document.getElementById('subTotalSpan');
        oSubtotalSpan.replaceChild(document.createTextNode(subtotaal.data),oSubtotalSpan.firstChild);
        
		shippingcosts = req.responseXML.getElementsByTagName("shippingcosts")[0].firstChild;
		oShippingCostsSpan = document.getElementById("shippingSpan");
		oShippingCostsSpan.replaceChild(document.createTextNode(shippingcosts.data),oShippingCostsSpan.firstChild);
		
        grandtotal = req.responseXML.getElementsByTagName("grandtotal")[0].firstChild;
        oGrandtotalSpan = document.getElementById("grandtotalSpan");
		oGrandtotalSpan.replaceChild(document.createTextNode(grandtotal.data),oGrandtotalSpan.firstChild);
	
	}
}
function checkVoorraad(voorraad,aantalInputElement)   {
	if(voorraad < aantalInputElement.value)   {
        document.getElementById(aantalInputElement.id).value = voorraad;
	}
}


function parseAlgemeneGift(selectbox)	{
	giftBedrag = selectbox.options[selectbox.selectedIndex].value;
	get = "xml_shop_save_formdata.php?wc_gift="+giftBedrag;
	loadXMLDoc(get, callbackParseAlgemeneGift);
}
function callbackParseAlgemeneGift()    {
	if ((req.readyState == 4) && (req.status == 200)) {
		
		//gift
        gift = req.responseXML.getElementsByTagName("gift")[0].firstChild;
        oGiftSpan = document.getElementById('giftSpan');
        oGiftSpan.replaceChild(document.createTextNode(gift.data),oGiftSpan.firstChild);
        //subtotaal:
        subtotaal = req.responseXML.getElementsByTagName("subtotaal")[0].firstChild;
        oSubtotalSpan = document.getElementById('subTotalSpan');
        oSubtotalSpan.replaceChild(document.createTextNode(subtotaal.data),oSubtotalSpan.firstChild);
        //grandtotal:
        grandtotal = req.responseXML.getElementsByTagName("grandtotal")[0].firstChild;
        oGrandtotalSpan = document.getElementById('grandtotalSpan');
        oGrandtotalSpan.replaceChild(document.createTextNode(grandtotal.data),oGrandtotalSpan.firstChild);
	}
}
function cartNextStep(nextStep) {
	f = document.getElementById("form_cart");
	f.nextStep.value = nextStep;
	if(nextStep == 4)   {
		f.actie.value = "setOrder";
	}
	if(fc.check()) {
		f.submit();
	}
}

function controleerBoekCheckbox(element, slachtofferId) {
//	als 'element' gechecked is, wordt het element met slachtofferid ge-un-checked
	slachtofferElement = document.getElementById(slachtofferId);
	if(element.checked) {
        slachtofferElement.checked = false;
	}
	if(slachtofferId=="fc_donateurWorden")  {
		//dan ook het bedragveld leeg maken
		document.getElementById("fc_donateurBedrag").value = "";
	}
}


/*	tell a friend	*/
function tellafriend(toggle)	{
	if(toggle)	{
		document.getElementById("introBannerMailafriendForm").style.display = "block";
	}	else	{
		document.getElementById("introBannerMailafriendForm").style.display = "none";
	}	
}

function  submitTellafriend(productId)	{
		
	senderName		= document.getElementById("fc_senderName").value;
	senderEmail		= document.getElementById("fc_senderEmail").value;
	receiverName	= document.getElementById("fc_receiverName").value;
	receiverEmail	= document.getElementById("fc_receiverEmail").value;

	get = "xml_shop_taf.php?productId="+productId+"&sn="+senderName+"&se="+senderEmail+"&rn="+receiverName+"&re="+receiverEmail;
	loadXMLDoc(get, callbackTellafriend);
}
function callbackTellafriend()	{
	if ((req.readyState == 4) && (req.status == 200)) {
       tellafriend(0);
       document.getElementById("fc_senderName").value = "";
       document.getElementById("fc_senderEmail").value = "";
       document.getElementById("fc_receiverName").value = "";
       document.getElementById("fc_receiverEmail").value = "";
	}
}

function mailReactie(toggle)	{
	if(toggle)	{
		document.getElementById("mailReactie").style.display = "block";
	}	else	{
		document.getElementById("mailReactie").style.display = "none";
	}		
}

function submitMailReactie()	{	
	senderName		= document.getElementById("mr_senderName").value;
	senderEmail		= document.getElementById("mr_senderEmail").value;
	senderMessage	= encodeURIComponent(document.getElementById("mr_senderMessage").value);
	get = "xml_shop_mailreactie.php?sn="+senderName+"&se="+senderEmail+"&sm="+senderMessage;
	loadXMLDoc(get, callbackMailReactie);
}
function callbackMailReactie()	{
	if ((req.readyState == 4) && (req.status == 200)) {
       mailReactie(0);
       document.getElementById("mr_senderName").value = "";
       document.getElementById("mr_senderEmail").value = "";
       document.getElementById("mr_senderMessage").value = "";
	}
}
