var http = getXHTTP(); // This executes when the page first loads.

function doHttpRequest() {  // This function does the AJAX request
 
  
 
 
  http.open("POST", "http://www.talatpasatip.com/wp-content/themes/talatpasatip/sendmail.php", true);
  http.onreadystatechange = getHttpRes;
  
  // Make our POST parameters string…
  var params = "";
  //var whereclouse = document.getElementById("WhereClouse");
  //var keyword = document.getElementById("KeyWord");
  var EmailAddress = document.getElementById("EmailAddress");
  var Name = document.getElementById("Name");
  var Phone = document.getElementById("Phone");
  var Subject = document.getElementById("Subject");
  var Message = document.getElementById("Message");
  var Captcha = document.getElementById("Captcha");

  if (EmailAddress.value != "") {params = "EmailAddress=" + encodeURI(EmailAddress.value);}
  if (Name.value != "") {params = params + "&Name=" + encodeURI(Name.value);}
  if (Phone.value != "") {params = params + "&Phone=" + encodeURI(Phone.value);}
  if (Subject.value != "") {params = params + "&Subject=" + encodeURI(Subject.value);}	
  if (Message.value != "") {params = params + "&Message=" + encodeURI(Message.value);}
  if (Captcha.value != "") {params = params + "&Captcha=" + encodeURI(Captcha.value);}

  // Set our POST header correctly…
  
  //alert (params);
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);

}

function getHttpRes() {
	  if (http.readyState == 4 && http.status == 200) { 
		  document.getElementById("formresult").innerHTML=http.responseText;
	  }
}

function getXHTTP( ) {
	  var xhttp;
	   try {   // The following "try" blocks get the XMLHTTP object for various browsers…
	      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	      try {
	        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
	      } catch (e2) {
	 		 // This block handles Mozilla/Firefox browsers...
		    try {
		      xhttp = new XMLHttpRequest();
		    } catch (e3) {
		      xhttp = false;
		    }
	      }
	    }
	  return xhttp; // Return the XMLHTTP object
	}





