﻿function ShowSMS()
{
    $("#txtCellNr").focus();
    document.getElementById("SMS").style.display = '';
}
function CloseSMS()
{
    document.getElementById("SMS").style.display = 'none';
}
function SendSMS()
{
    var url
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    if(wayPoint != "")
    {
        arrTemp = wayPoint.split("$");
        arrFrom = arrTemp[0].split("|");
        arrTo = arrTemp[1].split("|");
        url  = "AjaxSendSMS.aspx?destinationcoords="+arrTo+"&origincoords="+arrFrom+"&Number="+document.getElementById("txtCellNr").value+"&origindescription="+document.getElementById("SelectedPoint").innerHTML+"&destinationdescription="+document.getElementById("SelectedPointDest").innerHTML+"&num="+Math.random();
    }
    else
    {
        var AgCrd = g_map.getCentre()
        url  = "AjaxSendSMS.aspx?destinationcoords=&origincoords="+AgCrd.latitude()+"|"+AgCrd.longitude()+"&Number="+document.getElementById("txtCellNr").value+"&origindescription="+sDescription+"&destinationdescription=&num="+Math.random();
    }
    xmlHttp.onreadystatechange=SendSMSAjax;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    
}
function SendSMSAjax()
{
    if (xmlHttp.readyState==4)
    {
       Result =xmlHttp.responseText;
       document.getElementById("txtCellNr").value = "";
       CloseSMS()
       alert("Message Sent");
    }
}
