// JavaScript Document

	var hasEnteredEmail=false;

	function validateForm(theForm) {
		var errs = '';

		if (theForm.action.value=='cancel') {return true;}

		var emailEntered = theForm.email.value;
        
        if (emailEntered != '') {
        	if (isEmail(emailEntered)) {return true;} else
        	{ alert("The email address you entered does not appear to be\nwell-formed. Please check it carefully and try again.\nYou may also leave this field blank.");
        	return false;  }
        }
		
		if (theForm.feedback.value=='') {errs+='Message is blank.';}
		if (errs!='') {alert(errs); return false} 
		else return true;
	}

	function mailingListCheck() {
		var emailEntered = listForm.address.value;
		
		if ((emailEntered=='') || (emailEntered=='enter your address here')) {
		    alert("You need to enter your email address\nbefore hitting the 'subscribe' button");
		    return false;
		} else { 
			if (isEmail(emailEntered)) {return true;} else
			{ alert("The email address you entered does not appear to be\nwell-formed. Please check it carefully and try again.");
			return false;  }
		}
	}

	function isEmail(s) {
		var i = 1;
		var sLength = s.length;
		// look for @
		while ((i < sLength) && (s.charAt(i) != "@"))
		{ i++
		}
	    if ((i >= sLength) || (s.charAt(i) != "@")) {return false;} else {i += 2;}
		// look for .
		while ((i < sLength) && (s.charAt(i) != "."))
	    { i++
	    }
		// there must be at least one character after the .
	    if ((i >= sLength - 1) || (s.charAt(i) != ".")) {return false}
	    else {return true};
		}
