// AJAX WITH POST METHOD

function showHint( ) {  // This function does the AJAX request

  //  Set our destination PHP page "ajaxpost.php"…
  http.open("POST", "email.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
var params="name="+encodeURI(document.getElementById("name").value)+
		   "&company=" + encodeURI(document.getElementById("company").value)+
		   "&email=" + encodeURI(document.getElementById("email").value)+
		   "&phone=" + encodeURI(document.getElementById("phone").value)+
		   "&country=" + encodeURI(document.getElementById("country").options[contactForm.elements["country"].selectedIndex].text)+
		  "&interest=" + encodeURI(document.getElementById("interest").options[contactForm.elements["interest"].selectedIndex].text);

  // Set our POST header correctly…
  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);
  contactForm.reset();

}

function getHttpRes( ) {
  if (http.readyState == 4 && http.status == 200) { 
    res = http.responseText;  // These following lines get the response and update the page
    document.getElementById('ajaxDiv').innerHTML = res;
  }
}

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
}

var http = getXHTTP(); // This executes when the page first loads.




// AJAX WITH GET METHOD


/*function showHint()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText;
    }
  }
  	var name = document.getElementById('name').value;
	var company = document.getElementById('company').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	var country = document.getElementById('country').options[contactForm.elements["country"].selectedIndex].text;
	var interest = document.getElementById('interest').options[contactForm.elements["interest"].selectedIndex].text;
	
	var queryString = "?name=" + name + 
					  "&company=" + company + 
					  "&email=" + email + 
					  "&phone=" + phone + 
					  "&phone=" + phone + 
					  "&country=" + country + 
					  "&interest=" + interest; 
					  
					  
					  
xmlhttp.open("POST", "email.php" + queryString, true);

xmlhttp.send(null);
}*/
