if(window.XMLHttpRequest){
	var xmlHttpReq = new XMLHttpRequest(); // native object //
} else {
	if(window.ActiveXObject){
		var xmlHttpReq = new ActiveXObject('Microsoft.XMLHTTP'); // activex control ie5/6 //
	}
}


function payment(){
	
	var queryStr = 't=1'; // this is a URL variable to the php //
	var strURL = 'ajax/payment.php';

	xmlHttpReq.open('GET', strURL, false);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.send(null);
	var ajaxresponse = xmlHttpReq.responseText;
	
	if(ajaxresponse == 0){
		alert("Internal Error");
		return false;
	} else {
		return true;
	}
	

}





function confirmation(){
	
	var queryStr = 't=1'; // this is a URL variable to the php //
	var strURL = 'ajax/confirmation.php';

	xmlHttpReq.open('GET', strURL, false);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.send(null);
	var ajaxresponse = xmlHttpReq.responseText;
	
	if(ajaxresponse == 0){
		alert("Internal Error");
		return false;
	} else {
		return true;
	}
	

}




function postage(from, imgl, divl, divp, total){

	var pcode = document.forms['shopping_cart'].pcodecheck.value;
	var queryStr = 'type=' + escape(from) + '&pcode=' +pcode; // this is a URL variable to the php //
	var strURL = 'ajax/postage.php?' + queryStr;
	
	xmlHttpReq.open('GET', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.send(null);
	
	xmlHttpReq.onreadystatechange =
	
		function(){
		
			document.getElementById(imgl).style.display = "none";
			document.getElementById(divl).innerHTML = "";
			document.getElementById(divp).innerHTML = "";

			if(xmlHttpReq.readyState == 4){
			
				var response = xmlHttpReq.responseText;
				if(response == 0){
					var total_inc_post = parseFloat(total) + parseFloat(response);				
					document.getElementById(divl).innerHTML = "$0.00 <span class='text_red'>(FREE)</span>";
					document.getElementById(divp).innerHTML = "$"+Math.round(total_inc_post*100)/100+" AU";
				} else {
					var total_inc_post = parseFloat(total) + parseFloat(response);				
					document.getElementById(divl).innerHTML = "$"+response;
					document.getElementById(divp).innerHTML = "$"+Math.round(total_inc_post*100)/100+" AU";
				}
			
			} else {
				document.getElementById(imgl).style.display = "block";
			}
		  
		}
		
}

// on the postage page, we need to pass the pcode to the next page //
function pcode_url(){
	document.getElementById('checkout_link').href = 'cart_checkout.php?pcodecheck=' + document.shopping_cart.pcodecheck.value;
	return;
}
