

<!-- //





////////////////////////////////////////////////////////////////////////////////////////////////
// name: sendTextMessage
// purpose: Just a place holder function so we can get the value of the email entered into
//          the text box on the HTML page
////////////////////////////////////////////////////////////////////////////////////////////////
function sendTextMessage()
{
	sendTextMessage_private(document.getElementById('phone').value 
							+ '@' + 
							document.getElementById('domain').value,
							document.getElementById('subject').value,
							document.getElementById('message').value);
}

////////////////////////////////////////////////////////////////////////////////////////////////
// name: sendTextMessage_private
// purpose: Calls the PHP script that sends a text message via email.  
//          The callback funciton below will parse any
//          response, success or error from the PHP script's XML output
////////////////////////////////////////////////////////////////////////////////////////////////
function sendTextMessage_private(email, subject, message) 
{
	//var req;
	
	var url = 'scripts/sendTextMessage.php?email=' + email + '&subject=' + subject + '&message=' + message;
	
	//alert(url);
	
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = sendTextMessage_callback;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
		
		req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = sendTextMessage_callback;
            req.open("GET", url, true);
            req.send();
        }
    } 

}


////////////////////////////////////////////////////////////////////////////////////////////////
// name: sendTextMessage_callback
// purpose: this is the callback function, it takes the results from the XML output of the PHP 
//          script and parses the elements in order to write the success or error message
//          directly to the original HTML page
////////////////////////////////////////////////////////////////////////////////////////////////
function sendTextMessage_callback() 
{
	//alert('got here');
	var mdiv = document.getElementById("the_message");
	mdiv.innerHTML = "<font color=blue>Sending...</font>"
	
    // only if req shows "complete"
    if (req.readyState == 4) {
      // only if "OK" 
	  //alert('got here');
	  
      if (req.status == 200) {
			
	  //alert('got here NOW');
      response  = req.responseXML.documentElement;

      error_code    = response.getElementsByTagName('error_code')[0].firstChild.data;
      message    = response.getElementsByTagName('message')[0].firstChild.data;
	  
	  //alert('message: ' + message);
	  mdiv.innerHTML = message;

        } else {
            //alert("There was a problem retrieving the XML data:\n" + message);
        }
    }
}


// -->

