// JavaScript Document
function getstate(id)
  {
  var xmlHttp;
  var places = new Array();
  var str="";
  var places="";
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
	
			xmlHttp.onreadystatechange=function()
			  {
			  if(xmlHttp.readyState==4)
				{
				places.length=0;
				
				str = xmlHttp.responseText;
				// sets state  option value to null,
				//document.forms['form1'].state.options[0]=null;
				 //Equivalent code is shown below		
					 var o = document.forms['frm'].state.options;
				  if ((o.length = 0) > 0)
				  {
				 while (o.length > 0)
				  {
				o[0] = null;
				  }
				  }
				 places = str.split("@");
				
				for(i=0; i<places.length; i++) 
				{
						places1=0;
						places1=places[i].split("#");
						document.forms['frm'].state.options[i]=new Option(places1[0],places1[1]);
						
				}
				}
			  }
			 xmlHttp.open("GET", "js/getstate.php?cid=" +id, true);
			
			xmlHttp.send(null);
	
		//	document.getElementById("div_state").className="hidden"; 
	
}
 
 //get shipping state
 function getshipstate(id)
  {
  var xmlHttp;
  var places = new Array();
  var str="";
  places="";
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
			xmlHttp.onreadystatechange=function()
			  {
			  if(xmlHttp.readyState==4)
				{
				places.length=0;
				
				str = xmlHttp.responseText;
				// sets state  option value to null,
				//document.forms['form1'].state.options[0]=null;
				 //Equivalent code is shown below		
					 var o = document.forms['frm'].ship_state.options;
				  if ((o.length = 0) > 0)
				  {
				 while (o.length > 0)
				  {
				o[0] = null;
				  }
				  }
				 places = str.split("@");
				for(i=0; i<places.length; i++) {
						places1=0;
						places1=places[i].split("#");
						document.forms['frm'].ship_state.options[i]=new Option(places1[0],places1[1]);
				}
				}
			  }
			 xmlHttp.open("GET", "js/getstate.php?cid=" +id, true);
			
			xmlHttp.send(null);
		
	
 }
 
 //--get state name--//
 function getStateName(id)
  {
  var xmlHttp;
  var places = new Array();
  var str="";
  var val="";
  places=""; 
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
	
	
		
		xmlHttp.onreadystatechange=function()
		  {
		  if(xmlHttp.readyState==4)
			{
			places.length=0;
			
			 str = xmlHttp.responseText;
			if(str!="")
			{
				document.forms['frm'].ship_state.options[0]=new Option(str,0);
			}
			else
			{
				document.forms['frm'].ship_state.options[0]=new Option("No State Available",0);
			}
			// sets state  option value to null,
			//document.forms['form1'].state.options[0]=null;
			 //Equivalent code is shown below		
			
			}
			
		  }
		  
		 xmlHttp.open("GET", "js/getStateName.php?sid=" +id, true);
		
		xmlHttp.send(null);
		

	 
 }
