// UPDATE ECART ON TOP MENU
var xmlhttp;

function ecartmini(url){

popup('loading');

xmlhttp=ecartmini_GetXmlHttpObject();
xmlhttp.onreadystatechange=ecartmini_stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function ecartmini_stateChanged(){

				 if(xmlhttp.readyState==4){
				 
				 xmlDoc=xmlhttp.responseXML;
				 document.getElementById("items").innerHTML=xmlDoc.getElementsByTagName("items")[0].childNodes[0].nodeValue;
				 document.getElementById("total").innerHTML=xmlDoc.getElementsByTagName("total")[0].childNodes[0].nodeValue;
				 toggle('loading');
				 toggle('ecart_mini');
				 
				 }

}

function ecartmini_GetXmlHttpObject(){

	 // code for IE7+, Firefox, Chrome, Opera, Safari
	 if (window.XMLHttpRequest){
  
	 return new XMLHttpRequest();

	 }
	 
	 // code for IE6, IE5
	 if (window.ActiveXObject){
  
	 return new ActiveXObject("Microsoft.XMLHTTP");

	 }

return null;

}
// END UPDATE ECART ON TOP MENU

// UPDATE SHIPPING COSTS

function calculate_shipping(url){

popup('loading');

xmlhttp=ecartmini_GetXmlHttpObject();
xmlhttp.onreadystatechange=calculate_shipping_stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function calculate_shipping_stateChanged(){

				 if(xmlhttp.readyState==4){
				 
				 xmlDoc=xmlhttp.responseXML;
				 document.getElementById("ecart_shipping_cost").innerHTML=xmlDoc.getElementsByTagName("shipping")[0].childNodes[0].nodeValue;
				 document.getElementById("ecart_total_cost").innerHTML=xmlDoc.getElementsByTagName("total")[0].childNodes[0].nodeValue;
				 document.getElementById("total").innerHTML=xmlDoc.getElementsByTagName("total")[0].childNodes[0].nodeValue;
				 document.getElementById("ecart_terms").style.visibility='visible';
				 popup('loading');
				 
				 }

}
// END UPDATE SHIPPING COSTS

// SHOW EXPRESS CHECKOUT
function checkoutshow(id) {

				 if(id == 1) {
				 
				 document.getElementById('express_checkout').style.visibility = "visible";
				 
				 } else {
				 
				 document.getElementById('express_checkout').style.visibility = "hidden";
				 
				 }

}
// END SHOW EXPRESS CHECKOUT

// CHECK COUPON CODE

function check_coupon(url, coupon){

var x = url + "=" + coupon;

xmlhttp=ecartmini_GetXmlHttpObject();
xmlhttp.onreadystatechange=check_coupon_stateChanged;
xmlhttp.open("GET",x,true);
xmlhttp.send(null);

}

function check_coupon_stateChanged(){

				 if(xmlhttp.readyState==4){
				 
				 xmlDoc=xmlhttp.responseXML;
				 document.getElementById("ecart_shipping_cost").innerHTML=xmlDoc.getElementsByTagName("shipping")[0].childNodes[0].nodeValue;
				 document.getElementById("ecart_total_cost").innerHTML=xmlDoc.getElementsByTagName("total")[0].childNodes[0].nodeValue;
				 document.getElementById("ecart_referral_code").innerHTML=xmlDoc.getElementsByTagName("referral")[0].childNodes[0].nodeValue;
				 document.getElementById("total").innerHTML=xmlDoc.getElementsByTagName("total")[0].childNodes[0].nodeValue;
				 
				 }

}
// END CHECK COUPON CODE
