var xmlHttp;
var opt;
var global_c3;
var root_url = getServerName();
document.domain=window.location.hostname;

function getServerName()
{
    var str = window.location.protocol + '//' + window.location.hostname;
    return str;
}

function showCity(country)
{ 
opt = 1;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert("Your browser doesn't support AJAX.");
 return false;
 }

 var url=root_url + "/ajax_search/includes/ajax_browse.php";
 url=url + "?c=" + country;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function showCity2(country,con)
{ 
opt = 2;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert("Your browser doesn't support AJAX.");
 return false;
 }


 var url=root_url + "/ajax_search/includes/ajax_browse.php";
 url=url + "?c2=" + country;
 url=url + "&c3=" + con;
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
if(opt == 1){
document.getElementById("browse_results").innerHTML=xmlHttp.responseText;
//showCountry2(document.f1.country1.value);
//showCity2(document.f1.country2.value,document.f1.city1.value);
}
if(opt == 2){
document.getElementById("browse_results2").innerHTML=xmlHttp.responseText;

if(xmlHttp.responseText.length > 1){
document.f1.search.style.display = 'block';
//document.f1.search_alert.style.display = 'none';
document.getElementById("search_alert").style.display = 'none';

}else{
document.f1.search.style.display = 'none';
document.getElementById("search_alert").style.display = 'block';
//document.f1.search_alert.style.display = 'block';
}

}
if(opt == 3){
document.getElementById("browse_results3").innerHTML=xmlHttp.responseText;
//showCity2(document.f1.country2.value,document.f1.city1.value);
//showCity2(document.f2.country1.value,document.f1.city1.value);
//showCity(document.f1.country1.value);
}

 } 
}


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;
}