﻿
function submitContactUs()
{
    var xmlhttp;
    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("contactform").innerHTML=xmlhttp.responseText;
      }
    }
    var name=encodeURIComponent(document.getElementById("name").value);
    var email=encodeURIComponent(document.getElementById("email").value);
    var phone=encodeURIComponent(document.getElementById("phone").value);
    var message=encodeURIComponent(document.getElementById("message").value);
    
    var radioObj = document.forms['contact-us'].elements['interestedin'];
    var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			checkedValued = radioObj.value;
		else
			checkedValued = "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			checkedValued = radioObj[i].value;
		}
	}
    var interestedin=encodeURIComponent(checkedValued);

    var parameters="name="+name+"&email="+email+"&phone="+phone+"&message="+message+"&interestedin="+interestedin;
    xmlhttp.open("POST","wp-contactus.php",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send(parameters);
}
