function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Enter numerals only in this field.");
        return false;
    }
    return true;
}
function autofocus(field, limit, next, evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && field.value.length == limit) {
        field.form.elements[next].focus();
    }
}
function validateForm(theForm)
{
	// validate Association Name
	if (isNotBlank(theForm.an.value)) { theForm.an.className = "cool"; }else{ theForm.an.className = "alert"; alert('Please enter Your Association Name'); theForm.an.focus(); return false;}
	// validate Contact Name
	if (isName(theForm.cn.value)) { theForm.cn.className = "cool"; }else{ theForm.cn.className = "alert"; alert('Please enter a Contact Name'); theForm.cn.focus(); return false;}
	// validate Contact Title
	if (isName(theForm.ct.value)) { theForm.ct.className = "cool"; }else{ theForm.ct.className = "alert"; alert('Please enter a Contact Title'); theForm.ct.focus(); return false;}
	// validate Contact Phone Area Code
	if (isPhoneAreaCode(theForm.cpa.value)) { theForm.cpa.className = "cool"; }else{ theForm.cpa.className = "alert"; alert('Please enter a Contact Phone Area Code'); theForm.cpa.focus(); return false;}
	// validate Contact Phone Prefix
	if (isPhonePrefix(theForm.cpp.value)) { theForm.cpp.className = "cool"; }else{ theForm.cpp.className = "alert"; alert('Please enter a Contact Phone Prefix'); theForm.cpp.focus(); return false;}
	// validate Contact Phone Number
	if (isPhoneNumber(theForm.cpn.value)) { theForm.cpn.className = "cool"; }else{ theForm.cpn.className = "alert"; alert('Please enter a Contact Phone Number'); theForm.cpn.focus(); return false;}
	// validate Contact Phone Extension
	// if (isName(theForm.cpx.value)) { theForm.cpx.className = "cool"; }else{ theForm.cpx.className = "alert"; alert('Please enter a Contact Phone Extension'); theForm.cpx.focus(); return false;}
	// validate Best time to call
	//if (isNum(theForm.bt.value)) { theForm.bt.className = "cool"; }else{ theForm.bt.className = "alert"; alert('Please enter a Best time to call'); theForm.bt.focus(); return false;}
	// validate Contact E-mail
	if (isEmailAddress(theForm.em.value)) { theForm.em.className = "cool"; }else{ theForm.em.className = "alert"; alert('Please enter a Contact E-mail'); theForm.em.focus(); return false;}
	// validate Mailing Address
	if (isNotBlank(theForm.ma.value)) { theForm.ma.className = "cool"; }else{ theForm.ma.className = "alert"; alert('Please enter a Mailing Address'); theForm.ma.focus(); return false;}
	// validate Mailing City
	if (isName(theForm.mc.value)) { theForm.mc.className = "cool"; }else{ theForm.mc.className = "alert"; alert('Please enter a Mailing City'); theForm.mc.focus(); return false;}
	// validate Mailing Zip
	if (isZipCode(theForm.mzc.value)) { theForm.mzc.className = "cool"; }else{ theForm.mzc.className = "alert"; alert('Please enter a Mailing Zip'); theForm.mzc.focus(); return false;}
	// validate Mailing Zip Plus Code
	if (isNotBlank(theForm.mzp.value)){
		if (isZipPlus(theForm.mzp.value)) { theForm.mzp.className = "cool"; }else{ theForm.mzp.className = "alert"; alert('Please enter a Mailing Zip Plus Code'); theForm.mzp.focus(); return false;}
	}else{ theForm.mzp.className = "cool"; }
	// validate The of Units in HOA
	if (isNum(theForm.nu.value)) { theForm.nu.className = "cool"; }else{ theForm.nu.className = "alert"; alert('Please enter the Number of Units in HOA'); theForm.nu.focus(); return false;}
	// validate Your Comments or Request
	if (theForm.bt.value == "3"){
		if (isNotBlank(theForm.com.value)) { theForm.com.className = "cool"; }else{ theForm.com.className = "alert"; alert('Please enter your Comments or Request'); theForm.com.focus(); return false;}
	}else{ theForm.com.className = "cool"; }
	// form is valid enough to submit
	return true;
}
// 
function isNotBlank (str)
{
	return (str != "");
}
function isNum (string)
{ 
	var namePattern = /[0-9]+/;
	return namePattern.test(string);
}
// validate name
function isName (string)
{
	var namePattern = /[A-Za-z ]+/;
	return namePattern.test(string);
}
// validate zip code
function isZipCode (string)
{
	if ( string.length == 5 )
	{
		var zipPattern = /\d{5}/;
		return zipPattern.test(string);
	}
	return false;
}
// validate zip code plus
function isZipPlus (string)
{
	if ( string.length == 4 )
	{
		var zipPattern = /\d{4}/;
		return zipPattern.test(string);
	}
	return false;
}
// validate Phone Number Area Code
function isPhoneAreaCode (string)
{
	if ( string.length == 3 )
	{
		var areaCodePattern = /\d{3}/;
		return areaCodePattern.test(string);
	}
	return false;
}
// validate Phone Number Prefix
function isPhonePrefix (string)
{
	if ( string.length == 3 )
	{
		var prefixPattern = /\d{3}/;
		return prefixPattern.test(string);
	}
	return false;
}
// validate Phone Number
function isPhoneNumber (string)
{
	if ( string.length == 4 )
	{
		var phonePattern = /\d{4}/;
		return phonePattern.test(string);
	}
	return false;
}
function isEmailAddress (string)
{
	var addressPattern =/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return addressPattern.test(string);
}

//-->

