var xmlHttp

function loCation(str,locTyp,nexType)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 



var url="countries.php";
url=url+"?location="+str;
url=url+"&type="+locTyp
url=url+"&sid="+Math.random();



if(nexType=="province")
{
xmlHttp.onreadystatechange=stateChanged;
}
if(nexType=="city")
{
xmlHttp.onreadystatechange=state2Change;
}
if(nexType=="suburb")
{
xmlHttp.onreadystatechange=state3Change;
}



xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById('pname').style.visibility="visible";
document.getElementById("province").innerHTML=xmlHttp.responseText;
}
}
function state2Change() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById('sname').style.visibility="visible";
document.getElementById('cname').style.visibility="visible";
document.getElementById("city").innerHTML=xmlHttp.responseText;
}
}
function state3Change() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("suburb").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

