var this_selectcity1_selected;
var this_selectcity2_selected;

function load_travelmarg_add_at_top()
{
//alert("ok2");
var adds = ["top_travelmarg_add_1","top_travelmarg_add_2"]
var add_id = adds[Math.floor(Math.random()*adds.length)];
document.getElementById(add_id).style.display="inline";
document.getElementById("top_travelmarg_add_load").style.display="none";
}

function get_cities(selectcity1_selected,selectcity2_selected)
{
//alert("ok1");
this_selectcity1_selected=selectcity1_selected;
this_selectcity2_selected=selectcity2_selected;

//alert("ok");
xmlHttp=GetXmlHttpObject();
	
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/get_cities.jsp";
//url += "?sid="+Math.random();

xmlHttp.onreadystatechange=get_citiesChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send(null);
}

function get_citiesChanged() 
{ 

if (xmlHttp.readyState==4)
{
var res=xmlHttp.responseText;
//alert("res:"+res);

updateCities(res,this_selectcity1_selected,this_selectcity1_selected);


load_travelmarg_add_at_top();
//setTimeout("updateCities("+res+","+this_selectcity1_selected+","+this_selectcity1_selected+")",1000);
}

}

function updateCities(res,selectcity1_selected,selectcity2_selected)
{
//alert("ok");
pathArray = window.location.pathname.split( '/' );
//alert("pathArray.length:"+pathArray.length);
//newPathname = "";
//for ( i = 0; i<pathArray.length; i++ ) {

//newPathname += pathArray[i];
//}
var selectcity1_selected=null;
var selectcity2_selected=null;

if(pathArray.length==3)
selectcity1_selected=pathArray[2];

if(pathArray.length==4)
{
selectcity1_selected=pathArray[1];
selectcity2_selected=pathArray[3];
}

if(pathArray.length==5)
{
selectcity1_selected=pathArray[2];
selectcity2_selected=pathArray[4];
}
//alert("selectcity1_selected:"+selectcity1_selected);
//alert("selectcity2_selected:"+selectcity2_selected);
//alert("ok");
var selectcity1=document.getElementById("selectcity1");
var selectcity2=document.getElementById("selectcity2");

selectcity1.remove(0);
selectcity2.remove(0);
var splitCities = res.split("&&");

var optn1_select = document.createElement("OPTION");
optn1_select.text = "   --- Select a city ---   ";
optn1_select.value = "Select";

var optn2_select = document.createElement("OPTION");
optn2_select.text = "   --- Select a city ---   ";
optn2_select.value = "Select";

selectcity1.options.add(optn1_select);
selectcity2.options.add(optn2_select);

for(i = 0; i < splitCities.length; i++){
{
var city=splitCities[i];
var splitCity=city.split("##");

var value=splitCity[0];
var text=splitCity[1];

var optn1 = document.createElement("OPTION");
optn1.text = text;
optn1.value = value;

var optn2 = document.createElement("OPTION");
optn2.text = text;
optn2.value = value;

selectcity1.options.add(optn1);
selectcity2.options.add(optn2);

if(selectcity1_selected==value)
{
selectcity1.options.selectedIndex=selectcity1.length-1;
}

if(selectcity2_selected==value)
{
selectcity2.options.selectedIndex=selectcity2.length-1;
}

}
}




}




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;
}



