//<script language="javascript">
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//	name:			EmailCheck
	//	date:				7/26/2000
	//	description:	This function is used to validate email addresses (from "The JavaScript Source").  The function
	//						will validate the following types of email addresses:
	//							1)	user@domain
	//							2)	user@[IP]
	//							3)	"user with spaces"@domain or "user with spaces"@[IP]
	//						The function will verify that the user hasn't entered multiple "@"'s or continuous "."'s in the
	//						address, and will also verify that the domain ends in a two or three letter word (".com" or ".uk")
	//	inputs:			email address
	//	output:			true : false return value
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	function EmailCheck (emailAddress) {

		var emailPat = /^(.+)@(.+)$/;	//pattern validator for user@domain format
		var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";	//	characters not allowed in address
		var validChars = "\[^\\s" + specialChars + "\]";	// range of characters not allowed in a username or domainname
		var quotedUser = "(\"[^\"]*\")";	//pattern applies if "user" is a quoted string (no special rules about allowed characters)
		var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;		//pattern applies for domains that are IP addresses (square brackets are required)
		var atom = validChars + '+';		//represents a series of non-special characters
		var word = "(" + atom + "|" + quotedUser + ")";	//the following string represents one word in the typical username. for example, in john.doe@somewhere.com, john and doe are words.
		var userPat = new RegExp("^" + word + "(\\." + word + ")*$");		// The following pattern describes the structure of the user
		var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");	// The following pattern describes the structure of a normal symbolic domain
		
		var matchArray = emailAddress.match(emailPat);	// break up user@domain into different pieces
		if (matchArray==null)  // too many/few @'s or something; address doesn't even fit the general mould of a valid e-mail address.
		{
			alert("Please make sure that e-mail address is correct");
			return false;
		}
		
		var user = matchArray[1];
		if (user.match(userPat) == null)  //validate user name
		{
		    alert("The e-mail address doesn't seem to be valid.")
		    return false
		}

		var domain = matchArray[2];
		var IPArray=domain.match(ipDomainPat);
		if (IPArray != null)	// domain is an IP address
		{
			for (var i=1; i <= 4; i++)	
			{
				if (IPArray[i] > 255)
				{
					alert("The destination IP address is invalid.\n\nEach number within the IP address must be between 0 and 255");
					return false;
				}
			}
			return true
		}
		
		var domainArray=domain.match(domainPat);
		if (domainArray==null)	// domain is symbolic name
		{
			alert("The e-mail domain name doesn't seem to be valid.");
		    return false;
		}

		// domain name seems valid, but now make sure that it ends in a three-letter word (like com, edu, gov) 
		// or a two-letter word, representing country (uk, nl), and that there's a hostname preceding 
		// the domain or country.

		// break up the domain to get a count of how many atoms it consists of.
		
		// the address must end in a two letter or three letter word.   
		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
		{
		   alert("The e-mail address must end in a three-letter domain, or two letter country.");
		   return false;
		}

		var len=domArr.length;
		if (len<2)	// make sure there's a host name preceding the domain
		{
		   alert("The email address is missing a hostname");
		   return false;
		}

		// everything's valid
		return true;
	}