function resetForm() {
	tform = document.registrationform;
	tform.date.value = getCurrentdate();
	tform.date.style.background = "white";
	tform.name.value = "";
	tform.name.style.background = "white";
	tform.phone.value = "";
	tform.phone2.value = "";
	tform.address1.value = "";
	tform.address1.style.background = "white";
	tform.address2.value = "";
	tform.city.value = "";
	tform.city.style.background = "white";
	tform.state.value = "";
	tform.state.style.background = "white";
	tform.zip.value = "";
	tform.email.value = "";
	tform.email.style.background = "white";
	tform.email3.value = "";
	tform.summary.value = "";
	tform.summary.style.background = "white";
}

function getCurrentdate() {
	tdate=new Date();
	tmonth = tdate.getMonth()+1+ "/";
	if (tdate.getDate() < 10)
		tday = "0"+tdate.getDate()+"/";
	else
		tday = tdate.getDate()+"/";
	tyear = tdate.getFullYear();
	return tmonth+tday+tyear;
}
var time_variable;
 
function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object
 
function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
		top.document.getElementById("message").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
//		location.replace("rates.php?pn="+ratespolicyname);
		resetForm();
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}
 
function ajaxFunction(tform) {
	var getdate = new Date();  //Used to prevent caching during ajax call
	if(xmlhttp) { 
		var tname = tform.name.value;
		var tdate = tform.date.value;
		var address1 = tform.address1.value;
		var address2 = tform.address2.value;
		var city = tform.city.value;
		var state = tform.state.value;
		var zip = tform.zip.value;
		var email = tform.email.value;
		var email3 = tform.email3.value;
		var summary = tform.summary.value;
		var domainname = tform.domainname.value;
		xmlhttp.open("POST","emailnewcontactform.php",true); //calling ratesaction.php using POST method
		xmlhttp.onreadystatechange  = handleServerResponse;
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send("name=" + tname+"&date=" + tdate+"&address1="+ address1+"&address2=" + address2+"&city=" + city+
		"&state=" + state+"&zip=" + zip+"&email=" + email+"&email3=" + email3+
		"&summary=" + summary+"&domainname=" + domainname)
  }
}

function ajaxSearchform(tform) {
	var getdate = new Date();  //Used to prevent caching during ajax call
	if(xmlhttp) { 
		var proctype = tform.proctype.value;
		var selindex = tform.selindex.value;
		var table = tform.tablelist.value;
		xmlhttp.open("POST","buildsearchform.php",true); //calling ratesaction.php using POST method
		xmlhttp.onreadystatechange  = handleDbServerResponse;
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send("proctype=" + proctype+"&proctype="+"&tablelist="+table)
  }
}
function handleDbServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
		document.dbutilityform.searchbtn.disabled = "";
		document.getElementById("search").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}


