	function validateFormOnSubmit(theForm) {
		var reason = "";
		
		reason += validateEmpty(theForm.name, "Name");
		reason += emailval(theForm,theForm.email.value);
		reason += validateEmpty(theForm.message, "Message");
		
		if (reason != "") {
			alert("Some fields need correction:\n\n" + reason);
			return false;
		}
		
		return true;
	}
	
	function emailval(theForm,email) {
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		if (regex.test(email)) {
			theForm.email.style.background = 'White'; 
			return '';
		} else {
			theForm.email.style.background = '#E9F5AD'; 
			return "The Email Address field is not valid.\n";
		}
	}

	function validateEmpty(fld, fldname) {
		var error = "";
	  
		if (fld.value.length == 0) {
			fld.style.background = '#E9F5AD'; 
			error = "The " + fldname + " field has not been filled in.\n";
		} else {
			fld.style.background = 'White';
		}
		return error;   
	}
