var xmlHttp
var tdiv
var loc

function popdiv(url,cont)
{ 
tdiv = cont
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return }
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null) }

function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { tdiv.innerHTML=xmlHttp.responseText; } } 

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 { xmlHttp=new XMLHttpRequest(); }
catch (e)
 {
 try
  { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
 catch (e)
  { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
 }
return xmlHttp; }


function ajaxstops(lat,lng,dead,labels)
{ 

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return }
xmlHttp.onreadystatechange=stopstateChanged
xmlHttp.open("GET","ajaxstops.php?lat="+lat+"&lng="+lng+"&dead="+dead,true)
xmlHttp.send(null) }

function stopstateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 

if ( xmlHttp.responseText!="\n" ) {

  var stops = xmlHttp.responseText.split(";;;;");
  var stopdata = new Array();

  for ( var i in stops ) { 
  //  alert(stops[i]);
    stopdata = stops[i].split(";;"); 

    var pin = new VEShape(VEShapeType.Pushpin, new VELatLong(stopdata[0], stopdata[1]));
    if ( labels == "on" ) { pin.SetCustomIcon("<div class='stoplabel'><img src='stopicons/"+stopdata[2]+"' class='pins'>&nbsp;&nbsp;<div><b>"+stopdata[4]+" "+stopdata[3]+" ("+stopdata[8]+")</b></div></div>"); }
    else { pin.SetCustomIcon("<img src='stopicons/"+stopdata[2]+"' class='pins'>"); }
    pin.SetTitle(stopdata[3]);
    pin.SetDescription(stopdata[4]);
    pin.SetMoreInfoURL(stopdata[5]);
    pin.SetPhotoURL(stopdata[6]+"|"+stopdata[7]);
    pin.SetMinZoomLevel(15);
    map.AddShape(pin); }

} 
document.getElementById("info").innerHTML="";
}
}

function ajaxsearch(locality)
{ 
loc = locality
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return }
xmlHttp.onreadystatechange=searchstateChanged
xmlHttp.open("GET","ajaxsearch.php?locality="+locality,true)
xmlHttp.send(null) }

function searchstateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 

  if ( xmlHttp.responseText != "failed" ) {
    var sdata = xmlHttp.responseText.split(";");
    newloc = new VELatLong(sdata[0],sdata[1]);
    map.SetCenterAndZoom(newloc, 16);
    checknewstops(); }
  else { document.getElementById("info").innerHTML="Could not find "+loc; }
}
}


function ajaxrclick(lat,lng)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return }
xmlHttp.onreadystatechange=rclickstateChanged
xmlHttp.open("GET","ajaxrclick.php?lat="+lat+"&lng="+lng,true)
xmlHttp.send(null) }

function rclickstateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 

  document.getElementById("info").innerHTML=xmlHttp.responseText; 
}
}

