// $Id: util.js,v 1.1 2007/09/29 17:38:25 ejubenville Exp $

// Validate a string's email syntax
function emailSyntaxOK(s) {
	at_pos = s.indexOf("@");
	dot_pos = s.lastIndexOf(".");
	space_pos = s.indexOf(" ");
	if (at_pos == -1 || dot_pos == -1)
		return false;		// must have at least one "@" and one "."
	if (s.indexOf(" ") != -1)
		return false;		// no spaces allowed
	if (at_pos == 0 || dot_pos == (s.length-1))
		return false;		// "@" cannot be first, and "." cannot be last.
	if (dot_pos <= at_pos+1)
		return false;		// must have non-blank between "@" and "."
	return true;
}
