	function checkPC() {
		var cart = getCart();
		if (cart) {
			var cartpc = cart.document.getElementById("custpostcode");
			if (cartpc) {
				var tpc = cartpc.value;
				if (tpc == "") {
					centerPop("orderaskpc.php", "askpc", 300, 200);				
					return false;
				} else {
					return true;
				}
			}
		}
		return false;
	}		
	
	function changePC() {
		centerPop("orderaskpc.php", "askpc", 300, 200);
	}

	function askCoupons() {
		centerPop("orderaskcoupons.php", "askpc", 600, 600);
	}

	function centerPop(goal, title, popWidth, popHeight) {
		var props = "width="+popWidth+",height="+popHeight+",top="+((screen.height-popHeight)/2)+",left="+((screen.width-popWidth)/2)		
		window.open(goal, title, props);
	}
	
	function addToChoiceCart(id) {
		if (checkPC()) {
			cart = getCart();
			centerPop("orderaskoptions.php?id="+escape(id), "askoptions", 400, 300);			
		}
		return false;
	}
	
	function addToCart(id) {
		if (checkPC()) {
			cart = getCart();
			cart.location = "ordercart.php?id="+escape(id);	
		}
		return false;	
	}
	
	function getCart() {
		if (top.frames["content"].frames.length == 0) {
			top.frames["content"].location = "index2.php";
		} else if (top.frames["content"].frames["main"].frames["cart"] == "undefined") {
			top.frames["content"].frames["main"].location = "orderframe.php";
		}
		cart = top.frames["content"].frames["main"].frames["cart"];
		return cart;
	}
	function getOpenerCart() {
		if (opener.top.frames["content"].frames.length == 0) {
			opener.top.frames["content"].location = "index2.php";
		} else if (opener.top.frames["content"].frames["main"].frames["cart"] == "undefined") {
			opener.top.frames["content"].frames["main"].location = "orderframe.php";
		}
		cart = opener.top.frames["content"].frames["main"].frames["cart"];
		return cart;
	}	
	function getOpenerMenu() {
		if (opener.top.frames["content"].frames.length == 0) {
			opener.top.frames["content"].location = "index2.php";
		} else if (opener.top.frames["content"].frames["main"].frames["menu"] == "undefined") {
			opener.top.frames["content"].frames["main"].location = "orderframe.php";
		}
		menu = opener.top.frames["content"].frames["main"].frames["menu"];
		return menu;
	}	
	function showMenu() {
		if (top.frames["content"].frames.length == 0) {
			top.frames["content"].location = "index2.php";
		} else if (top.frames["content"].frames["main"].frames["cart"] == "undefined") {
			top.frames["content"].frames["main"].location = "orderframe.php";
		}
		return false;
	}
	
	var connection;
	var active_obj = null;
	var active_content = null;
	
	
	function xmlRequest(page, postvars, destination_id)
	{
		// except IE
		
		if (connection) 
		{			
			delete connection;			
		}
		
		active_content = document.getElementById(destination_id);
	
	
		if(window.XMLHttpRequest) 
		{
		  connection = new XMLHttpRequest();	
		} //IE
		else if(window.ActiveXObject) 
		{
		  try 
		  {
		    connection = new ActiveXObject("Msxml2.XMLHTTP");		
		  } 
		  catch(e) 
		  {
		    connection = new ActiveXObject("Microsoft.XMLHTTP");		
		  }	
		}
	
		if (connection) 
		{        
			connection.open("POST", page, true);
			connection.onreadystatechange = function() 
			{
			        if (connection.readyState != 4)
			        {
			         	var d = document.getElementById(destination_id);
			         	d.innerHTML = '<img src="/images/loading.gif" border="0">';
			          return;			        
			        }
			        eval('callBack(connection.responseText);');
			        delete connection;			      
			}
			connection.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			connection.send(postvars);		
		}	
			
	}	
	
	function callBack(content)
	{
		active_content.innerHTML = content;
	}	
	
	function selSelection(paymentid) 
	{ 		
		xmlRequest('getpaymentdetails.php','method='+paymentid, 'paymentoptions');
		var paymenttext = '&nbsp;';
		if (paymentid == 0 || paymentid=="") paymenttext = 'Je betaalt:';
		else if (paymentid == 3) paymenttext = 'Kies bank:';
		
		document.getElementById('ipaymentlabel').innerHTML = paymenttext;
		
		//if (paymentid==3) xmlRequest2('basket.php','showwithideal=true&orderaction=noremove','basketdiv');
		//else xmlRequest2('basket.php','orderaction=noremove','basketdiv');
	}
