
function ShowLocate()
{

    document.getElementById("Locate").style.display = '';
}
function CloseLocate()
{
    document.getElementById("Locate").style.display = 'none';
}
var sNumber = "";
function LocateMe()
{
    CloseLocate();
    sNumber = document.getElementById("txtLocateNum").value;
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 


    var url = "AJAXLocateMe.aspx?Number="+sNumber + "&User=" + document.getElementById("txtuser").value + "&Pwd=" + document.getElementById("txtpass").value;
    xmlHttp.onreadystatechange=receiveLocation;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    document.getElementById("txtLocateNum").value = '';  
    document.getElementById("txtuser").value = '';  
    document.getElementById("txtpass").value = '';  
 }
function receiveLocation()
{
    if (xmlHttp.readyState==4)
    {
        var arr_received = xmlHttp.responseText;
        if(arr_received == "DENIED")
        {
            alert('Invalid credentials');
        }
        else if (arr_received == "NONE")
        {
            alert('Number could not be located');
        }
        else
        {
          var Coord = arr_received.split("|");
          //g_map.AddPoint("Images/Pin_Red_32x32_24bit.png", "1locate", parseFloat(Coord[0]),parseFloat(Coord[1]),-5,-32,"Location Result",sNumber);
          var oLatLng = new AGCoord(parseFloat(Coord[0]),parseFloat(Coord[1]));
          var oIcon = new AGIcon();
          oIcon.image = "Images/Pin_Red_32x32_24bit.png";
          //oIcon.iconSize = new AGSize(31, 32);


        imgObj=document.createElement("div");
        imgObj.innerHTML = "<img style='cursor:pointer' src ='images/Pin_Red_32x32_24bit.png' title='"+sNumber+"'/>";
        var myHTMLOptions = new AGHTMLOverlayOptions(new AGPoint(-5, -32));
        var myHTMLOverlay = new AGHTMLOverlay(imgObj, new AGCoord(parseFloat(oLatLng.latitude()), parseFloat(oLatLng.longitude()),myHTMLOptions));
        g_map.addOverlay(myHTMLOverlay, "Point");    
          
          g_map.centreAndScale(oLatLng, 18);
        }
        xmlHttp = null
    }
}
