<!--
// enter numbers only in this field
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;
}
// move to the next field if this one has been filled
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();
    }
}
// validate the data on the form
function validateForm(theForm)
{
	// validate First Name
	if (isName(theForm.fn.value)) { theForm.fn.className = "cool"; }else{ theForm.fn.className = "alert"; alert('Please enter a First Name'); theForm.fn.focus(); return false;}
	// validate Last Name
	if (isName(theForm.ln.value)) { theForm.ln.className = "cool"; }else{ theForm.ln.className = "alert"; alert('Please enter a Last Name'); theForm.ln.focus(); return false;}
	// validate Your HOA
	if (isNum(theForm.hoa.value)) { theForm.hoa.className = "cool"; }else{ theForm.hoa.className = "alert"; alert('Please enter Your HOA '); theForm.hoa.focus(); return false;}
	// validate Your Unit
	if (isNotBlank(theForm.u.value)) { theForm.u.className = "cool"; }else{ theForm.u.className = "alert"; alert('Please enter Your Unit'); theForm.u.focus(); return false;}

	// clear everything
	theForm.dpa.className = "cool";
	theForm.dpp.className = "cool";
	theForm.dpn.className = "cool";
	theForm.epa.className = "cool";
	theForm.epp.className = "cool";
	theForm.epn.className = "cool";

	// if the evening phone is not blank and the day is blank
	if( isEveningPhoneNotBlank(theForm) && !isDayPhoneNotBlank(theForm))
	{
		// evening must be evaluated
		if (!isEveningPhone(theForm)) { return false; }
	}else{
		// day must be evaluated
		if (!isDayPhone(theForm)) { return false; }
		
		// if any part of the evening phone isNotBlank
		if (isEveningPhoneNotBlank(theForm))
		{
			// evening must be evaluated
			if (!isEveningPhone(theForm)) { return false; }
		}
	}
	// validate Best time to call
	if (isNotBlank(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 E-mail
	if (isEmailAddress(theForm.em.value)) { theForm.em.className = "cool"; }else{ theForm.em.className = "alert"; alert('Please enter an E-mail Address'); theForm.em.focus(); return false;}
	// validate Where to Direct concerns to
	if (isNotBlank(theForm.dt.value)) { theForm.dt.className = "cool"; }else{ theForm.dt.className = "alert"; alert('Please enter Where to Direct concerns to'); theForm.dt.focus(); return false;}
	// validate Comments, Concerns, Or Requests
	if (isNotBlank(theForm.com.value)) { theForm.com.className = "cool"; }else{ theForm.com.className = "alert"; alert('Please enter your Comments, Concerns, Or Requests'); theForm.com.focus(); return false;}

	// form is valid enough to submit
	return true;
}
//determine if any part of the day phone's fields have data entered
function isDayPhoneNotBlank (theForm)
{
	return ( (theForm.dpa.value + theForm.dpp.value + theForm.dpn.value) != "");
}
// validate Day Phone
function isDayPhone (theForm)
{
	// validate Day Phone Area Code
	if (isPhoneAreaCode(theForm.dpa.value)) { theForm.dpa.className = "cool"; }else{ theForm.dpa.className = "alert"; alert('Please enter a Day Phone Area Code'); theForm.dpa.focus(); return false;}
	// validate Day Phone Prefix
	if (isPhonePrefix(theForm.dpp.value)) { theForm.dpp.className = "cool"; }else{ theForm.dpp.className = "alert"; alert('Please enter a Day Phone Prefix'); theForm.dpp.focus(); return false;}
	// validate Day Phone Number
	if (isPhoneNumber(theForm.dpn.value)) { theForm.dpn.className = "cool"; }else{ theForm.dpn.className = "alert"; alert('Please enter a Day Phone Number'); theForm.dpn.focus(); return false;}
	// validate Day Phone Extension
	//if (isNum(theForm.dpx.value)) { theForm.dpx.className = "cool"; }else{ theForm.dpx.className = "alert"; alert('Please enter a Day Phone Extension'); theForm.dpx.focus(); return false;}
	return true;
}
//determine if any part of the evening phone's fields have data entered
function isEveningPhoneNotBlank (theForm)
{
	return ((theForm.epa.value + theForm.epp.value + theForm.epn.value) != "");
}
//validate Evening Phone
function isEveningPhone (theForm)
{
	// validate Evening Phone Area Code
	if (isPhoneAreaCode(theForm.epa.value)) { theForm.epa.className = "cool"; }else{ theForm.epa.className = "alert"; alert('Please enter an Evening Phone Area Code'); theForm.epa.focus(); return false;}
	// validate Evening Phone Prefix
	if (isPhonePrefix(theForm.epp.value)) { theForm.epp.className = "cool"; }else{ theForm.epp.className = "alert"; alert('Please enter an Evening Phone Prefix'); theForm.epp.focus(); return false;}
	// validate Evening Phone Number
	if (isPhoneNumber(theForm.epn.value)) { theForm.epn.className = "cool"; }else{ theForm.epn.className = "alert"; alert('Please enter an Evening Phone Number'); theForm.epn.focus(); return false;}
	// validate Evening Phone Extension
	//if (isNum(theForm.epx.value)) { theForm.epx.className = "cool"; }else{ theForm.epx.className = "alert"; alert('Please enter an Evening Phone Extension'); theForm.epx.focus(); return false;}
	return true;
}
// 
function isNotBlank (string)
{
	return (string != "");
}
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);
}

//-->

