function ajaxFunction(){
var xmlHttp;
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
}
catch (e)
{
	// Internet Explorer
	try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			alert("Your browser does not support AJAX!");
			return false;
		}
	}
}
return xmlHttp;
}

function checkName(name, spanID){
	var xmlHttp = ajaxFunction();
	xmlHttp.open("GET","validate.php?name=" + name, true);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(spanID).innerHTML = xmlHttp.responseText;
			disableSubmit();
		}
	}
	xmlHttp.send(null);
}

function checkZip(zip, spanID){
	var xmlHttp = ajaxFunction();
	xmlHttp.open("GET","validate.php?zip=" + zip, true);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(spanID).innerHTML = xmlHttp.responseText;
			disableSubmit();
		}
	}
	xmlHttp.send(null);
}

function checkPhone(phone, spanID){
	var xmlHttp = ajaxFunction();
	xmlHttp.open("GET","validate.php?phone=" + phone, true);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(spanID).innerHTML = xmlHttp.responseText;
			disableSubmit();
		}
	}
	xmlHttp.send(null);
}

function checkEmail(email, spanID){
	var xmlHttp = ajaxFunction();
	xmlHttp.open("GET","validate.php?email=" + email, true);
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById(spanID).innerHTML = xmlHttp.responseText;
			disableSubmit();
		}
	}
	xmlHttp.send(null);
}

function disableSubmit() {
	if(document.getElementById('vFName').innerHTML != "" || 
	document.getElementById('vLName').innerHTML != "" || 
	document.getElementById('vZipCode').innerHTML != "" ||
	document.getElementById('vEmail').innerHTML != "")	{
		
		document.inquire.submit.disabled = true;
	} else {
		document.inquire.submit.disabled = false;
	}
}

function checkForm(inquire)
 {
 	inquire.onsubmit = function() // attach the function to onsubmit event
 	{
 		if(inquire.elements['firstName'].value.length<1){
 			alert("You cannot leave the FIRST NAME field empty");
			inquire.elements['firstName'].focus()
 			return false;
 		}
		if(inquire.elements['lastName'].value.length<1){
 			alert("You cannot leave the LAST NAME field empty");
			inquire.elements['lastName'].focus()
 			return false;
 		}
		if(inquire.elements['addressOne'].value.length<1){
 			alert("You cannot leave the ADDRESS field empty");
			inquire.elements['addressOne'].focus()
 			return false;
 		}
		if(inquire.elements['city'].value.length<1){
 			alert("You cannot leave the CITY field empty");
			inquire.elements['city'].focus()
 			return false;
 		}
		if(inquire.elements['state'].value.length<1){
 			alert("You cannot leave the STATE field empty");
			inquire.elements['state'].focus()
 			return false;
 		}
		if(inquire.elements['zipCode'].value.length<1){
 			alert("You cannot leave the ZIP CODE field empty");
			inquire.elements['zipCode'].focus()
 			return false;
 		}
		if(inquire.elements['homePhone'].value.length<1){
 			alert("You cannot leave the HOME PHONE field empty");
			inquire.elements['homePhone'].focus()
 			return false;
 		}
		if(inquire.elements['email'].value.length<1){
 			alert("You cannot leave the EMAIL field empty");
			inquire.elements['email'].focus()
 			return false;
 		}
 		return true;
 	}
 }