function city_func(city_id)
{
	document.getElementById("selected_city").value=city_id;
	var country_id = 88;
	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("locality_id").value=locality_id;
}

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_search;
    http.send(null);			
}

function response_cities_search()
{
     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 get_city_tabs(city_id)
{
    var url="ajax_scripts/get_front_cities.php";
    http.open("GET", url + "?city_id=" + escape(city_id) ,true);
    http.onreadystatechange=response_cities;
    http.send(null);			
}

function response_cities()
{
    if(http.readyState == 1)
    {
  		//document.getElementById("city_tabs_area").innerHTML ="<div align='center'><img src='images/loading.gif' /></div>";
    }
    else
    {	
     if(http.readyState==4)
     {
      if(http.status==200)
      {
            var results=http.responseText;
            document.getElementById("city_tabs_area").innerHTML = results;
      }
      else
      {
            //alert("Error: " + http.status);
      }
    }
  }
}

function get_pg_search()
{
    var url="ajax_scripts/index_page_search_pg.php";
    http.open("GET", url ,true);
    http.onreadystatechange=response_search_listings;
    http.send(null);			
}

function get_pgr_search()
{
    var url="ajax_scripts/index_page_search_pgr.php";
    http.open("GET", url ,true);
    http.onreadystatechange=response_search_listings;
    http.send(null);			
}

function response_search_listings()
{
    if(http.readyState == 1)
    {
  		//document.getElementById("search_area").innerHTML ="<div align='center'><img src='images/loading.gif' /></div>";
    }
    else
    {	
     if(http.readyState==4)
     {
      if(http.status==200)
      {
            var results=http.responseText;
            document.getElementById("search_area").innerHTML = results;
      }
      else
      {
            //alert("Error: " + http.status);
      }
    }
  }
}

function load_everything(val_city)
{
	setTimeout("get_city_tabs(" + escape(val_city) + ");", 400); 	
	setTimeout("get_states(88);", 1500);
}

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();