
function updateSMSState() {
  if (http.readyState == 4) {
       // Use the XML DOM to unpack the city and state data 
         var result = http.responseText; 
         if (result =='ok') {
         document.getElementById('SMSStatus').value = 'Sent';
      }
      else {
         document.getElementById('SMSStatus').value = 'Failed to send';
      }    
      isWorking = false;
  }
}

var isWorking = false;

function sendSMS() {
  if (!isWorking && http) {
    var name = document.getElementById("SMSname").value;
    var text = document.getElementById("SMStext").value;
    http.open("GET", 'text2person.xql?name=' + escape(name) + '&text=' + escape(text), true);
    http.onreadystatechange = updateSMSState;  
          // this sets the calls back function to be invoked when a response from the HTTP request is returned
    isWorking = true;
    http.send(null);
  }
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object


