
function getXMLHTTPRequest() {
  var reg=false;
  try {
        /* for firefox */
        req = new XMLHttpRequest();
     } catch (err) {
        /* for some versions of ie */
        try {
          req = new ActiveXObject("Msxml12.XMLHTTP");
        } catch (err) {
        try {
            /* for some other versions of ie */
            req = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (err) {
            req = false;
        }
    }
  }
  return req;
}

function sendCustomerSMS() {
    var thePage = 'procCustomerSms.php';
    var myRand = parseInt(Math.random()*999999999999999);
    var name = document.getElementById('customer_name').value;
    var mobile = document.getElementById('customer_mobile').value;
    var theURL = "http://comms-lab.com/actions/" + thePage + "?rand="+myRand + "&name=" + name + "&mobile=" + mobile;
    myReq.open("GET", theURL, true);
    myReq.onreadystatechange = theHTTPResponse;
    myReq.send(null);
}

function customerCall() {
    var thePage = 'procCustomerCall.php';
    var myRand = parseInt(Math.random()*999999999999999);
    var name = document.getElementById('customer_name').value;
    var mobile = document.getElementById('customer_mobile').value;
    var theURL = "http://comms-lab.com/actions/" + thePage + "?rand="+myRand + "&name=" + name + "&mobile=" + mobile;
    myReq.open("GET", theURL, true);
    myReq.onreadystatechange = theHTTPResponse;
    myReq.send(null);
}


function theHTTPResponse() {
    if (myReq.readyState == 4) {
        if (myReq.status == 200) {
            var message = myReq.responseXML.getElementsByTagName("message")[0];
            document.getElementById('call').innerHTML = message.childNodes[0].nodeValue;
            
        }
    }
}

var myReq = getXMLHTTPRequest();
