function checkForm(theForm) {//// Form pre-submission checker designed by David Ameeti//	function checkEmail(emailAddr) {		var emailRE = new RegExp(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i);		return emailRE.test(emailAddr);	}var errorColor	= "#ffbbbb";		// color when field is invalidvar goodColor	= "#ffffff";		// color when field is validvar fixQuotes	= true;				// if true, change quotes to unicode (vs. reporting them as errors)var useNames	= true;				// if true, error msg uses name (vs. the text field #)// check email address (if defined *and* field content) for validity	var emailValid = true;	var theEmail = false;	if ( (typeof theForm.email != "undefined") && (theForm.email.type == "text") )		theEmail = theForm.email	else if ( (typeof theForm.r_email != "undefined") && (theForm.r_email.type == "text") ) {		theEmail = theForm.r_email;		emailValid = theEmail.value.length > 0;	}	if (emailValid && theEmail) {		emailValid = checkEmail(theEmail.value);		theEmail.style.backgroundColor = (emailValid ? goodColor : errorColor);	}// check (most) text field to verify fields filled in properly	var boxesInvalid = "";	var boxNum = 0;	for (var i = 0; i < theForm.elements.length; i++) {		var theItem = theForm.elements[i];		if ( (theItem.type == "text") || (theItem.type == "textarea") ) {	// search for text fields			boxNum++;			theItem.style.backgroundColor = goodColor;			if ( ((theItem.value.length == 0) && (theItem.name.indexOf("r_") == 0)) ||					(!fixQuotes && (theItem.value.indexOf("'") != -1) || (theItem.value.indexOf('"') != -1)) ) {				if (boxesInvalid.length == 0)					theItem.focus();							// if first bad field, set focus on field				boxesInvalid += (boxesInvalid.length > 0 ? ", " : "") + (useNames ? theItem.name.substring(theItem.name.indexOf("r_") == 0 ? 2 : 0) : "#" + boxNum);				theItem.style.backgroundColor = errorColor;		// highlight background			}		}	}	if (fixQuotes && (!boxesInvalid.length && emailValid))		// If no other errors, auto-correct quotes to unicode format		for (var i = 0; i < theForm.elements.length; i++) {			var theItem = theForm.elements[i];			theItem.value = theItem.value.replace(/'/g,"&#39;").replace(/"/g,"&#34;");		}	if (!emailValid) alert("The email address entered is not a valid email address.\n\nPlease correct the address and re-submit your information.  Thank you."); 	if (boxesInvalid.length) {		alert("Some of the required entries have not been filled in" + (fixQuotes ? "" : " or contain unacceptable characters such as single (') or double quotes (\")") + ".\n\nFields needing correction: " + boxesInvalid + "\n\nThe fields with invalid information are noted by the red background in the input area.\n\nPlease correct the information and resubmit.  Thank you.");		return false;	}	alert("Form is " + ( (boxesInvalid.length || !validEmail) ? "in" : "") + "valid.");	return emailValid;		// if we get this far, only status not acted upon is email}
