// JavaScript Document

// JavaScript Document

function getHTTPObject() {
var xmlhttp;

    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			xmlhttp = new XMLHttpRequest();
        } catch(e) {
			xmlhttp = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		xmlhttp = false;
        	}
		}
    }
  return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object



function handleHttpResponse() {
  if (http.readyState == 4) {
    
	if (http.responseText.indexOf('invalid') == -1) {

      // Split the comma delimited response into an array
      results = http.responseText;

      document.getElementById('ContactFormDiv').innerHTML = results
      
		isWorking = false;
 
	}

  }
}

function sendEmailFromPosting(name, email, subject, comments ) {

	var arg;
	arg = "name="+name+"&email="+email+"&subject="+subject+"&comments="+comments;
	http.open("POST", "actions/sendMessageAjax.php", true);
	http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-Length", arg.length);
	http.setRequestHeader('Connection','close');
	http.send(arg);
	http.onreadystatechange = handleHttpResponse; 



 }

function xmlHttpPOST(xmlhttp, url, arg) {
  xmlhttp.open('POST', url, true);
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  xmlhttp.setRequestHeader("Content-Length", arg.length);
  xmlhttp.setRequestHeader('Connection','close');
  xmlhttp.send(arg);	  
}
