var xmlHttp

function process()
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 

for (i=0;i<document.form_special.SubscriptionPeriod.length;i++) {
			if (document.form_special.SubscriptionPeriod[i].checked==true) {
				subsperiod = document.form_special.SubscriptionPeriod[i].value;
			}
}

negara		= document.form_special.RecipientGiftCountry.value;
shipmethod	= document.form_special.ShippingMethod.value;
negaraname  = document.form_special.RecipientGiftCountry.options[document.form_special.RecipientGiftCountry.selectedIndex].text;

 var url="shipping-calculation.php"
 url=url+"?negara="+negara+"&subsperiod="+subsperiod+"&shipmethod="+shipmethod+"&negaraname="+negaraname;
 url=url+"&sid="+Math.random()
 xmlHttp.onreadystatechange=stateChanged 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 }


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
 xmlDoc=xmlHttp.responseXML;
 //document.getElementById("country").innerHTML= xmlDoc.getElementsByTagName("country")[0].childNodes[0].nodeValue;
 //document.getElementById("method").innerHTML= xmlDoc.getElementsByTagName("method")[0].childNodes[0].nodeValue;
 document.getElementById("curr").innerHTML= xmlDoc.getElementsByTagName("curr")[0].childNodes[0].nodeValue;
 document.getElementById("charges").innerHTML= xmlDoc.getElementsByTagName("charges")[0].childNodes[0].nodeValue;
 
 }
} 

function GetXmlHttpObject()
 { 
 var objXMLHttp=null
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest()
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp
 }


function getCountry(strURL){         
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if (xmlHttp) {
		xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4) { //data is retrieved from server
			         
					document.getElementById('countrydiv').innerHTML=xmlHttp.responseText;
				
			}            
		}        
		xmlHttp.open("GET", strURL, true); //open url using get method
		xmlHttp.send(null);
	}
}

function resetShipping(str) {

	var subsperiod;
	for (i=0;i<document.form_special.SubscriptionPeriod.length;i++) {
			if (document.form_special.SubscriptionPeriod[i].checked==true) {
				subsperiod = document.form_special.SubscriptionPeriod[i].value;
			}
	}
	
	
	if (typeof(subsperiod) == "undefined")
	{
		alert("You have to select Subscription Period first");
		return false;
	}

	//document.form_special.ShippingMethod.value = "0";
	if (str=="")
			  {
			  document.getElementById("txtCharges").innerHTML="";
			  return;
			  }
			if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.onreadystatechange=function()
			  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("txtCharges").innerHTML=xmlhttp.responseText;
				}
			  }
			xmlhttp.open("GET","getcharges.php?q="+str+"&p="+subsperiod,true);
			xmlhttp.send();
	
}

function clearAll() {
	document.form_special.ShippingMethod.value = "0";
	document.getElementById("charges").innerHTML = " ";
	document.getElementById("curr").innerHTML = " ";
}

function fillCountry() {
	document.form_special.countryname.value = document.form_special.RecipientGiftCountry.options[document.form_special.RecipientGiftCountry.selectedIndex].text;
}
