function isValidSubscribeForm(email) {
	// Requires the validate.js include file in the containing page.
	if (isValidEmailAddress(email)) {
		return true;
	} else {
		alert("Invalid email address.  Please try again.");
		return false;
	}
}

function isValidEmailAddress(email) {

	// can't be empty
	if (email.length == 0)  return false;
	
	// can't contain any invalid character
	invalidChars = " /:,;";
	for (i=0;  i < invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) return false;
	}
	
	//  there must be one "@" character
	atPos = email.indexOf("@",1);
	if (atPos == -1) return false;
	
	// there must be at last one "." after the "@"
	dotPos = email.indexOf(".", atPos);
	if (dotPos == -1) return false;
	
	// there must be at least two characters after the "."
	if (dotPos + 3 > email.length) return false;
	
	return true;
}

function isEmptyField(fld) {
	return (trim(fld).length == 0);
}

function trim(strText) { 
	// this will get rid of leading spaces 
	while (strText.substring(0,1) == ' ') 
		strText = strText.substring(1, strText.length);

	// this will get rid of trailing spaces 
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1);

   return strText;
} 
