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

function GetXmlHttpObject()
{
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;}
}

if(!xmlhttp && typeof ActiveXObject != "undefined"){
   try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
   if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){xmlhttp=false;}
  }

return xmlhttp;
}



function update_search()
{
v1 = document.getElementById('town_select').options[document.getElementById('town_select').selectedIndex].value;
v2 = document.getElementById('location_select').options[document.getElementById('location_select').selectedIndex].value;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/ajax/getroad.php"+"?v1="+v1+"&v2="+v2+"&rnd="+Math.random();
xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged1() 
{ 
if (xmlHttp.readyState==4)
{ 
eval(xmlHttp.responseText);
update_search2();
}
}

function update_search2()
{
v1 = document.getElementById('town_select').options[document.getElementById('town_select').selectedIndex].value;
v2 = document.getElementById('location_select').options[document.getElementById('location_select').selectedIndex].value;
v3 = document.getElementById('road_select').options[document.getElementById('road_select').selectedIndex].value;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/ajax/getref.php"+"?v1="+v1+"&v2="+v2+"&v3="+v3+"&rnd="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged2() 
{ 
if (xmlHttp.readyState==4)
{ 
eval(xmlHttp.responseText);
}
}

function clear_options(elt)
{
  elt = document.getElementById(elt);for (i = elt.length-1;i>=0;i--) {elt.remove(i);};
}

function add_option(elt,oval,otxt)
{
  elt = document.getElementById(elt);
  opt = document.createElement('option');opt.value=oval;opt.text=otxt;try {elt.add(opt,null)}catch(ex){elt.add(opt);};
}
