function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] 
 if (window.ActiveXObject){ 
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}
function sendComment() {
var mypostrequest=new ajaxRequest();

mypostrequest.onreadystatechange=function(){
 if (mypostrequest.readyState==4){
  if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){

	var resp = mypostrequest.responseText;
	var errChk = new RegExp("ERROR");

	alert(resp);
	if (!resp.match(errChk)){
			document.sendComm.reset();
			} 	
	
  }
  else{
   alert("An error has occured making the request")
  }
 }
}

var emailValue=encodeURIComponent(document.getElementById("email").value);
var catValue=encodeURIComponent(document.getElementById("cat").value);
var firstNameValue=encodeURIComponent(document.getElementById("firstName").value);
var lastNameValue=encodeURIComponent(document.getElementById("lastName").value);
var commentAreaValue=encodeURIComponent(document.getElementById("comment").value);
var parameters="cat="+catValue+"&email="+emailValue+"&firstName="+firstNameValue+"&lastName="+lastNameValue+"&commentArea="+commentAreaValue
mypostrequest.open("POST", "/reg/contact", true);
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
mypostrequest.send(parameters)

}
