<!-- Hide script from older browsers
	//////////////////////////////////////////////////////////////////////
	//  Description:  This javascript contains functions to validate the
	//                mail form input fields that are passed to the
	//                mail.pl cgi-bin script.  This script performs the
	//                validation on the client-side, reducing process
	//                load on the server.  The following form elements
	//                are required by this script.
	//
	//    Name        Type        Description
	//    ----------  ----------  -----------------------------------
	//    fullname    text        The full name of the sender.
	//    email       text        The e-mail address of the sender.
	//    comments    textarea    The comments from the sender.
	//
	//
	//    Here is sample html form code for implementing this script:
	//
	//  <form method="post" action="/cgi-bin/mail.pl" onSubmit="return validateMailForm(this);">
	//    Name: <input type="text" name="fullname" size="40"><br>
	//    E-Mail: <input type="text" name="email" size="40"><br>
	//    Comments: <textarea name="comments" rows="10" cols="60"></textarea><br>
	//    <input type="hidden" name="recipient" value="ncep.webmaster">
	//    <input type="hidden" name="author" value="NCEP Web Team">
	//    <input type="hidden" name="subject" value="Website Comments">
	//    <input type="hidden" name="nav"
	//           value='<a href="/">Home</a> &gt; <a href="/mail_webmaster/">Mail Webmaster</a>'>
	//    <input type="reset" value="Erase Comments">
	//    <input type="submit" value="Send Comments">
	//  </form>
	//
	//
	// Programmer        Date         Description
	// ----------------  -----------  ----------------------------------
	// Ricardo Romero    04-Jun-2004  Initial Version.
	// Ricardo Romero    14-Feb-2006  Disabled check for an empty email
	//                                address and name.  Govt. privacy
	//                                policy does not permit these to be
	//                                required elements.
	//
	//////////////////////////////////////////////////////////////////////

	// Check if the form fields are filled in and valid
	function validateMailForm(mailForm) {

		fullname = mailForm.fullname.value
		email = mailForm.email.value
		comments = mailForm.comments.value

		fullname = removeLeadingAndTrailingBlanks(fullname)
		email = removeLeadingAndTrailingBlanks(email)

		// Disabled due to privacy rights policies. RRomero. 
		if ( isEmpty(fullname) ) {
			//alert("Please provide your full name.")
			//mailForm.fullname.focus()
			//return false;
			return true;
		}

		// Disabled due to privacy rights policies. RRomero. 
		if ( isEmpty(email) ) {
			//alert("Please provide your e-mail address.")
			//mailForm.email.focus()
			//return false;
			return true;
		}

		if ( ! isEmpty(email) ) {
			if ( ! validEmail(email) ) {
				alert("You entered an invalid E-mail address.\nPlease verify that it is typed correctly.")
				mailForm.email.focus()
				mailForm.email.select()
				return false;
			}
		}

		if ( isEmpty(comments) ) {
			alert("Please provide your comments.")
			mailForm.comments.focus()
			return false;
		}

		return true;
	}

	// Check if an email address is valid
	function validEmail(email) {
		// Set string of invalid email address characters
		invalidChars = " /:,;"

		// Does the email address contain invalid characters
		for ( i=0; i<invalidChars.length; i++ ) {
			badChar = invalidChars.charAt(i)
			if ( email.indexOf(badChar, 0) > -1 ) {
				return false;
			}
		}

		// Get the position of the "@" in the email address
		atPos = email.indexOf("@", 1)

		// Does the email address contain "@"
		if ( atPos == -1 ) {
			return false;
		}

		// Does the email address contain multiple "@"s
		if ( email.indexOf("@", atPos+1) > -1 ) {
			return false;
		}

		// Get position of the "." in the email address
		periodPos = email.indexOf(".", atPos)

		// Does the email address contain "."
		if ( periodPos == -1 ) {
			return false;
		}

		// Does the email address end in "."
		lastChar = email.charAt(email.length - 1)
		if ( lastChar == "." ) {
			return false;
		}
		return true;
	}

	// Check if a text field is empty
	function isEmpty(textItem) {
		if (textItem == "" || textItem == null) {
			return true;
		}
		return false;
	}

	// Remove leading and trailing blanks
	function removeLeadingAndTrailingBlanks(inputVal) {
		newStr = "";
		inputStr = "" + inputVal;

		// Remove leading blanks.
		leadIndex = 0;
		done = false;
		while ( ! done) {
			if (inputStr.charAt(leadIndex) == " ") {
				leadIndex++;
				continue;
			} else {
				done = true;
			}
		}

		// Remove trailing blanks.
		trailIndex = inputStr.length - 1;
		done = false;
		while (! done) {
			if (inputStr.charAt(trailIndex) == " ") {
				trailIndex--;
				continue;
			} else {
				done = true;
			}
		}
		newStr = inputStr.substring(leadIndex, trailIndex + 1);
		return newStr;
	}

// End Hiding Script -->
