
function get_states(country_id)
{
	if(country_id != "")
	{
    	var url="ajax_scripts/get_states.php";
    	http.open("GET", url + "?country_id=" + escape(country_id) ,true);
    	http.onreadystatechange=response_states;
    	http.send(null);
	}
}

function response_states()
{
     if(http.readyState==4)
     {
      if(http.status==200)
      {
            var results=http.responseText;
            document.getElementById("states_select_area").innerHTML = results;
      }
      else
      {
            //alert("Error: " + http.status);
      }
    }
}

function get_cities(state_id)
{
	document.getElementById("selected_state").value=state_id;
    var url="ajax_scripts/get_cities.php";
    http.open("GET", url + "?state_id=" + escape(state_id) ,true);
    http.onreadystatechange=response_cities;
    http.send(null);			
}

function response_cities()
{
     if(http.readyState==4)
     {
      if(http.status==200)
      {
            var results=http.responseText;
            document.getElementById("cities_select_area").innerHTML = results;
      }
      else
      {
            //alert("Error: " + http.status);
      }
    }
}

function city_func(city_id)
{
	document.getElementById("selected_city").value=city_id;
	var country_id = document.getElementById("country").value;
	var state_id = document.getElementById("selected_state").value;
	
	if(country_id=="" || state_id == "" || city_id == "")
	{
		alert("Please choose a country, state and city first");
	}
	else
	{
    	var url="ajax_scripts/get_localities.php";
    	http.open("GET", url + "?country_id=" + escape(country_id) + "&state_id=" + escape(state_id) + "&city_id=" + escape(city_id) ,true);
    	http.onreadystatechange=response_localities;
    	http.send(null);					
	}
}

function response_localities()
{
     if(http.readyState==4)
     {
      if(http.status==200)
      {
            var results=http.responseText;
            document.getElementById("locality_selected_area").innerHTML = results;
      }
      else
      {
            //alert("Error: " + http.status);
      }
    }
}

function locality_func(locality_id)
{
	document.getElementById("selected_locality").value=locality_id;
}

function get()
{
 var xmlhttp;
 if(window.XMLHttpRequest)
 {
  xmlhttp=new XMLHttpRequest();
 }
 else if(window.ActiveXObject)
 {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if(!xmlhttp)
  {
   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 }
return xmlhttp;
}
var http=get();