// text area counter

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

// email validating functions for entire site (they are called by the form/page specific functions below)

function CheckEmailField(theField,alertMsg) {
    if (theField.value == "" ) {
        alert(alertMsg)
        theField.focus();
        return 0;
    }
    if (theField.value.indexOf ('@',0) == -1 ||
        theField.value.indexOf ('.',0) == -1) {
        alert("An Email field requires a \"@\" and a \".\" to be used. \n Please re-enter the Email Address.")
        theField.select();
        theField.focus();
        return 0;
    }
    return 1;
}
function CheckField(theField,alertMsg) {
    if (theField.value == "" ) {
        alert(alertMsg)
        theField.focus();
        return 0;
    }
	    return 1;
}

function CheckHowFound(theField,alertMsg) {
    if (theField.value == "Select" ) {
        alert(alertMsg)
        theField.focus();
        return 0;
    }
	    return 1;
}


// email validator for contact_body.html, membership_body.html
function CheckForm(theForm) {
	if (!CheckField(theForm.firstName,"Please enter your name.")) {return false;}
    if (!CheckField(theForm.phone,"Please enter your phone address.")) {return false;}	
    if (!CheckEmailField(theForm.email,"Please enter your email address.")) {return false;}	
	if (!CheckField(theForm.note,"Please enter your question or comment.")) {return false;}	
    return true;
}


