function getXmlHttpRequestObject() {
 if (window.XMLHttpRequest) {
    return new XMLHttpRequest(); //Mozilla, Safari ...
 } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP"); //IE
 } else {
    //Display our error message
    alert("Your browser doesn't support the XmlHttpRequest object.");
 }
}

//Our XmlHttpRequest object
var receiveReq_emailus = getXmlHttpRequestObject();

//Initiate the AJAX request
function makeRequest_emailus(url,param) {
	
	
//If our readystate is either not started or finished, initiate a new request
 if (receiveReq_emailus.readyState == 4 || receiveReq_emailus.readyState == 0) {
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
   receiveReq_emailus.open("POST", url, true);
   //Set the function that will be called when the XmlHttpRequest objects state changes
   receiveReq_emailus.onreadystatechange = updatePage_emailus; 

   receiveReq_emailus.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  // receiveReq.setRequestHeader("Content-length", param.length);
   receiveReq_emailus.setRequestHeader("Content-length", param.length);
   receiveReq_emailus.setRequestHeader("Connection", "close");

   //Make the request
   receiveReq_emailus.send(param);
   
 }   
  
}

//Called every time our XmlHttpRequest objects state changes
function updatePage_emailus() {
 //Check if our response is ready
 if (receiveReq_emailus.readyState == 4) {
   //Set the content of the DIV element with the response text
   //alert(receiveReq.responseText);
  
  // document.getElementById('result').value = receiveReq.responseText;
   //Get a reference to CAPTCHA image
   img = document.getElementById('imgCaptcha_emailus'); 
   //Change the image
  
   if(receiveReq_emailus.responseText=="true")
   {
   	document.form_emailus.submit()
   }else
   {
	   document.getElementById('result_emailus').innerHTML = "Error! Invalid verification code";
	   img.src = 'create_image_emailus.php?' + Math.random();
   }
   
   
   
 }
}

//Called every time when form is perfomed
function getParam_emailus(theForm) { 
 //Set the URL
 
 var url = 'captcha_emailus.php';
 //Set up the parameters of our AJAX call
 var postStr = theForm.txtCaptcha_emailus.name + "=" + encodeURIComponent( theForm.txtCaptcha_emailus.value );
 //Call the function that initiate the AJAX request
 makeRequest_emailus(url, postStr);

}

<!-- Begin
function checkFields_emailus() { 

missinginfo = "";

if(document.form_emailus.Practice_Location.value == "") {
missinginfo += "\n     -  Practice Location";
}


if(document.form_emailus.Patients_Name.value == "") {
missinginfo += "\n     -  Patients Name";
}

if(document.form_emailus.Email.value == "") {
missinginfo += "\n     -  Email";
}

if(document.form_emailus.Contact_Number.value == "") {
missinginfo += "\n     -  Contact Number";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"Please complete the missing required fields:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}else
{
getParam_emailus(document.form_emailus);


return false;
}
//return true;
}
//  End -->


