 var xmlHttp;
 var shippingbeforetax;
 var shipping;
 function GetXmlHttpObject()
 { 
 var objXMLHttp=null;
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest();
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 return objXMLHttp;
 }   
function showUser()
 { 
	  xmlHttp=GetXmlHttpObject();
	 if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  }	
	 var url="responsexml.php";
	 var strdc=document.getElementById("discount_code").value;
	 url=url+"?q="+strdc;
	 url=url+"&sid="+Math.random();
	 xmlHttp.open("GET",url,true);
	 xmlHttp.onreadystatechange=AssignCity;
	 xmlHttp.send(null);
 
 } 

function AssignCity() 
{ 
	RemoveAllDrpItems();
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	 var CityList=xmlHttp.responseXML.getElementsByTagName("country")[0]; 
	 var code=CityList.childNodes[0];
	 var ele = document.getElementById("discount_code");
	 for(var i=0;i<CityList.childNodes.length;i++)
		 {
			var option=document.createElement('option');
			var rec1=CityList.childNodes[i];    
			var str1=rec1.childNodes[0].nodeValue;
			if(str1==0)
			{
			alert("You have Entered an Invalid Coupon Code");
			}
			else if(str1=="N")
			{
			alert("This Coupon Code Is Already Claimed")
			str1=0;
			}			
			document.getElementById("percent").value = str1;
			str2 = document.getElementById("tot").value;
			str3 = str1*str2;
			document.getElementById("discount_total").value = str3;
			str4 = str2-str3;
			document.getElementById("totalafterdiscount").value = str4;
		 }       
	 }
} 
function abc()
{
x = document.getElementById("city").value;
y = document.getElementById("weight").value;
alert(x);
alert(y);
shipping = x*y;
document.getElementById("shipping").value = shipping;
alert(shipping);
str5 = parseInt(document.getElementById("totalafterdiscount").value);
alert(str5);
grandtotal = parseInt(str5 + shipping);
alert(grandtotal);
document.getElementById("totalaftershipping").value = grandtotal;
}
function RemoveAllDrpItems()    
    {      
		var objDrpList = document.getElementById ('discount_code');
	                       	
		 for(var i=objDrpList.length-1; i>=0; i--)        
		 {          
				objDrpList.options[i] = null;        
		 }    
    }
function showUser1()
 { 
	  xmlHttp=GetXmlHttpObject();
	 if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  }
	
	 var url="responsexmlcity.php";
	 x = document.getElementById("city").value;//unit price
		y = document.getElementById("weight").value;//total weight of the all products
		var shipping1 = x*y;
		var fuelsurcharge = shipping1/2;
		shippingbeforetax=shipping1+fuelsurcharge;
		var tax = 0.1236*shippingbeforetax;
		shipping = shippingbeforetax + tax;
		document.getElementById("shipping").value = shipping;
		str5 = parseInt(document.getElementById("totalafterdiscount").value);		
	 url=url+"?r="+x;
	 url=url+"&sid="+Math.random();
	 xmlHttp.open("GET",url,true);
	 xmlHttp.onreadystatechange=AssignCity1;
	 xmlHttp.send(null);
 
 } 

function AssignCity1() 
{
	RemoveAllDrpItems();
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	 var CityList1=xmlHttp.responseXML.getElementsByTagName("country1")[0];
	 var code=CityList1.childNodes[0];
	 for(var i=0;i<CityList1.childNodes.length;i++)
		 {
			var option=document.createElement('option');
			var rec1=CityList1.childNodes[i];    
			var str1=rec1.childNodes[0].nodeValue;
			octroi = parseInt(str5 * (str1/100));
			document.getElementById("octroi").value = octroi;
			grandtotal = parseInt(str5 + shipping + octroi);
		    document.getElementById("totalaftershipping").value = grandtotal;
		 }       
	 }
}
function shippingfill()
{
document.getElementById("sfirst").value = document.getElementById("bfirst").value;
document.getElementById("slast").value = document.getElementById("blast").value;
document.getElementById("sdob").value = document.getElementById("bdob").value;
document.getElementById("saddress").value = document.getElementById("baddress").value;
document.getElementById("saddress2").value = document.getElementById("baddress2").value;
document.getElementById("scity").value = document.getElementById("bcity").value;
document.getElementById("sstate").value = document.getElementById("bstate").value;
document.getElementById("szip").value = document.getElementById("bzip").value;
document.getElementById("sphone").value = document.getElementById("bphone").value;
document.getElementById("sfax").value = document.getElementById("bfax").value;
} 