function IsValid(theForm){

   	if (theForm.userName.value == ""){
		alert("Please provide your name.");
        theForm.userName.focus();
        return(false);
   	}

   	if (theForm.userMessage.value == ""){
		alert("You forgot to enter your message.");
        theForm.userMessage.focus();
        return(false);
   	}

   	if (theForm.userEmail.value == ""){
		alert("Please provide an email address so that a reply can be sent to you if necessary.");
        theForm.userEmail.focus();
        return(false);
   	}

	if ( emailCheck(theForm.userEmail.value) == false) {
		alert("Please provide a valid email address so that a reply can be sent to you if necessary.");
		theForm.userEmail.focus();
		return false;
	}

	else {
		return true;
	}

	// If we've gotten this far, everything's valid!
	return(true);
} /* End formCheck */
	
function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	/* Finally, let's start trying to figure out if the supplied address is
	valid. */

	var matchArray = emailStr.match(emailPat);
	if (matchArray==null) {
		 alert("Email address seems incorrect (check @ and .'s)");
		 return false;
	}
	
	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null) {
		 alert("The email username doesn't seem to be valid.");
		 return false;
	}

	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	   for (var i=1;i<=4;i++) {
	     if (IPArray[i]>255) {
	         alert("The email destination IP address is invalid.");
	 	 return false;
	     }
	 	}
	//	return true;
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		 alert("The email domain name doesn't seem to be valid.");
		 return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || 
		 domArr[domArr.length-1].length>6) {
		// the address must end in a 2, 3, 4, 5 or 6 letter word.
		alert("The address must end with a TLD of between 2 and 6 characters in length.");
		return false;
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
		var errStr="The email address is missing a hostname.";
		alert(errStr);
		return false;
	}

} /* End emailCheck */