function submitme(form) {
/*	Validates required fields on form
	11/10/2004	JJO	Revised to accomodate missing fields (not on the form), to add
							commenting for clarity, and to clean up code indentation
*/

	var formvalid		= true;
	var formmessage	= "";
	var formfocus		= "";

	/* first name field must be filled in	*/
	if (form.firstname) {
		if (formvalid && form.firstname.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  First name is required.";
			formfocus	= "firstname";
		}
	}
	/* last name field must be filled in	*/
	if (form.lastname) {
		if (formvalid && form.lastname.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  Last name is required.";
			formfocus	= "lastname";
		}
	}
	/* Address line 1 field must be filled in	*/
	if (form.address1) {
		if (formvalid && form.address1.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  Address is required.";
			formfocus	= "address1";
		}
	}
	/* City field must be filled in	*/
	if (form.city) {
		if (formvalid && form.city.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  City is required.";
			formfocus	= "city";
		}
	}
	/* State field must be filled in	*/
	if (form.state) {
		if (formvalid && form.state.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  State is required.";
			formfocus	= "state";
		}
		/* Convert state to upper case	*/
		form.state.value = form.state.value.toUpperCase();
	}
	/* Zip code field must be filled in and valid	*/
	if (form.zip) {
		if (formvalid && form.zip.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  Zip code is required.";
			formfocus	= "zip";
		}
		/* Zip code validation	*/
		//if (formvalid) {
			// to be added...
		//}
	}
	/* Email address field must be filled in	*/
	if (form.emailaddress) {
		if (formvalid && form.emailaddress.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  Email Address is required.";
			formfocus	= "emailaddress";
		}
	}
	/* Email address field must be filled in	*/
	if (form.emailconfirm) {
		if (formvalid && form.emailconfirm.value == "") {
			formvalid	= false;
			formmessage	= "Please fill in all required fields.  Confirm Email Address is required.";
			formfocus	= "emailconfirm";
		}
	}
	/*	Email validations	*/
	if (form.emailconfirm && form.emailaddress) {
		/*	email and confirmation must match	*/
		if (formvalid && form.emailaddress.value != form.emailconfirm.value) {
			formvalid	= false;
			formmessage	= "The confirmation email you entered does not match your original email entry.";
			formfocus	= "emailconfirm";
		}
		/*	check for valid email address	structure	*/
		if (formvalid) {
			/*	check for valid address structure (xxxxx@xxxxx) */
			var emailparts = form.emailaddress.value.split("@");
			if (emailparts.length!=2) {
				formvalid	= false;
				formmessage	= "'"+form.emailaddress.value+"' is not a valid email address.";
				formfocus	= "emailaddress";
			}
			if (formvalid) {
				/*	check for valid domain structure after the @ character (xxxxxx.xxx)	*/
				var domainparts	= emailparts[1].split(".");
				if (domainparts.length<2) {
					formvalid	= false;
					formmessage	= "'"+form.emailaddress.value+"' is not a valid email address.";
					formfocus	= "emailaddress";
				}
			}
			if (formvalid) {
				form.emailaddress.value = form.emailaddress.value.toLowerCase();
				form.emailconfirm.value = form.emailconfirm.value.toLowerCase();
			}
		}
	}
	/*	Phone number validations and formatting	*/
	if (form.homephone) {
		if (formvalid && !checkphoneformat(form.homephone)) {
			formvalid	= false;
			formmessage	= "'"+form.homephone.value+"' is not a valid phone number.";
			formfocus	= "homephone";
		}
	}
	/*	Work phone	*/
	if (form.workphone) {
		if (formvalid && !checkphoneformat(form.workphone)) {
			formvalid	= false;
			formmessage	= "'"+form.workphone.value+"' is not a valid phone number.";
			formfocus	= "workphone";
		}
	}
	/*	FAX	*/
	if (form.fax) {
		if (formvalid && !checkphoneformat(form.fax)) {
			formvalid	= false;
			formmessage	= "'"+form.fax.value+"' is not a valid phone number.";
			formfocus	= "fax";
		}
	}

	/*	if not valid, show message and set focus on errant field	*/
	if (!formvalid) {
		alert(formmessage);
		var fld = eval("form."+formfocus);
		if (typeof(fld)=="object") {
			fld.focus();
		}
	} else {
		//alert("form is valid!");
		form.submit();
	}

	return formvalid;

}



function checkphoneformat(phonefld) {
/*	function checks and formats a phone number field.  Returns true if a valid number or false otherwise
	number must be a 10 digit phone number

*/

	var tempphone	= "";
	var digits		= "0123456789";

	/* if field is blank, return true	*/
	if (phonefld.value=="") {
		return true;
	}

	/* create stripped copy of phone number	*/
	for (i=0; i<phonefld.value.length; i++) {
		if (digits.indexOf(phonefld.value.charAt(i))!=-1) {
			tempphone = tempphone + phonefld.value.charAt(i);
		}
	}
	/* check length	*/
	if (tempphone.length!=10) {
		return false;
	}
	/*	phone is valid, reformat	*/
	phonefld.value	= "("+tempphone.substr(0,3)+") "+tempphone.substr(3,3)+"-"+tempphone.substr(6,4);

	return true;

}

