//'********************************************************************
//'	Copyright (c) 1998-2005 Web Alchemy
//'********************************************************************
//'	/scripts/emailUtils.js
//'********************************************************************

function IsValidEmail(email) {
	//	...first, make sure there is an email
	var valid = (email != "");
	if (valid) {
		// array of invalid characters
		var invalidChars = " /:,;&#";

		//	...loop through the array of invalid characters
		//		and checking for any unacceptable characters
		for (i=0; (i < invalidChars.length) && valid; i++) {
			badChar = invalidChars.charAt(i);
			if (email.indexOf(badChar, 0) > -1) {
				valid = false;
			}
		}
		if (valid) {
			var www = (email.substring(0, email.indexOf('.')+1));
			valid = (www.toLowerCase() != "www.")
		}
		if (valid) {
			//	...check for the at sign (@)
			atPos = email.indexOf("@", 0);
			valid = (atPos != -1)
		}
		if (valid) {
			//	...check for the @ sign
			atPos = email.indexOf("@", 0);
			valid = (atPos != 0)
			if (valid) {
				valid = (email.indexOf("@", atPos+1) == -1)
				if (valid) {
					//	...check for the dot
					periodPos = email.indexOf(".", 0);
					valid = (periodPos != -1)
					if (valid) {
						periodPos = email.indexOf(".", (email.length-1));
						valid = (periodPos+1 != email.length)
					}
				}
			}
		}
	}
	if (valid) {
		var bad_words = new Array(".shit.","@shit.","shit@",".eatme","eatme@","@eatme.","fuck","fuck.",".fuck","@fuck","suckme","yousuck");
		for (i=0; (i < bad_words.length) && valid; i++)
			valid = ((email.indexOf(bad_words[i], 0)) == -1);
	}
	if (valid) {
		var atdot = "@.";
		var dotat = ".@";
		valid = ((email.indexOf(atdot, 0)) == -1);
		if (valid)
			valid = ((email.indexOf(dotat, 0)) == -1);
	}
	return valid;
}

