var xmlHttp;
function GetXmlHttpObject() {
   xmlHttp=null;
   try{
       // Firefox, Opera 8.0+, Safari
       xmlHttp=new XMLHttpRequest();
   }
   catch(e){
       //IE
           try{
               xmlHttp=new ActiveXObject("Msxml2.xmlHttp");
           }
           catch(e){
               xmlHttp=new ActiveXObject("Microsoft.xmlHttp");
           }
       }
   if (xmlHttp == null){
       alert("Your Browser does not support AJAX!");
       return;
   }
   return xmlHttp;
}
function submitForm(){
   xmlHttp=GetXmlHttpObject();
   var dd = document;
   var d = document.theForm;
   var fname = d.Contact0FirstName.value;
   var lname = d.Contact0LastName.value;
   var email = d.Contact0Email.value;
   var phone = dd.getElementById("phone").value;
   var state = dd.getElementById("state").value;
   var zip   = dd.getElementById("zip").value;
   
   var confEmail = d.confEmail.value;
   if (confEmail.length > 0) {
		if (confEmail.toUpperCase() != email.toUpperCase()) {
			alert("Email and Confirm Email do not match");
			return false;
		}
   } else {
		alert("Please Confirm your Email");
		return false;   
   }
   
   var url="addclient.php";
   url += "?name="+fname+" "+lname;
   url += "&email="+email;
   url += "&phone="+phone;
   url += "&state="+state;
   url += "&zip="+zip;
   xmlHttp.onreadystatechange=StateChanged;
   xmlHttp.open("Get",url,true);
   xmlHttp.send(null);
   document.getElementById("form").className = "hideForm";
}
function StateChanged(){
   if (xmlHttp.readyState==4){
   	   window.setTimeout('complete()',3000);
   }
}
function complete() {
	document.getElementById("form").className = "orderForm";
	if (xmlHttp.responseText.toUpperCase() == "TRUE") {
		document.theForm.submit();
	}
}