/*
	Paragon Book Gallery
	E-Newsletter signup form validation
	Provides one function, formValidator, accepting a form object as input.
	This form object should contain a field, "bl_email", which represents the
	E-mail address to validate.  (It may contain additional fields.)
	It then verifies that the e-mail address is present and valid.  If so, true
	is returned.  If not, an alert is displayed and false is returned.
	Originally by Jonathan Roberts.
	12/26/02 PWK, Last modified
*/

function formValidator(theForm) {
	var foundSymbol = false;
	var foundFullemail = false;
	
	// Present?
  	if (theForm.bl_email.value == '') {
		alert('Please enter your E-mail address.');
		theForm.bl_email.focus();
		return (false);
	}

	// Valid?
	for (i = 0; i < theForm.bl_email.value.length; i++) {
		var ch = theForm.bl_email.value.substring(i, i+1)
		
		if(ch == "@")
			foundSymbol = true;
		if(foundSymbol && ch == '.')
		 	foundFullemail = true;
	}
	if (!foundFullemail) {
		alert('Your E-mail address is not valid.  Please double-check that it is complete and has been correctly entered.  Also, please ensure that the "E-mail" and "Full name" fields have not been accidentally switched.');
		theForm.bl_email.focus();
		return (false);	
	}

	return (true);
}  // formValidator

