/*  Name: joinlist.js
	Description: 
		The code to include this functions is:
			<script src="http://www.cartoys.com/cartoy/include/HotDeals.js"></script>
	SF: To see the full extent of what this file used to be, see /include/JoinList.js. (8/21/06)
*/
function emailCheck (emailStr) {
	/* Used to check if the e-mail address fits the user@domain format. */	
	var emailPat=/^(.+)@(.+)$/;	
	/* This string represents the pattern for matching all special
	characters.  We don't want to allow ( ) < > @ , ; : \ " . [ ] */	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";	
	/* The following string represents the range of characters allowed in a 
	domainname.  It really states which chars aren't allowed.*/	
	var validChars="\[^\\s" + specialChars + "\]";	
	/* The following pattern applies if the "user" is a quoted string*/	
	var quotedUser="(\"[^\"]*\")";	
	/* The following string represents an atom (basically a series of non-special characters.) */	
	var atom=validChars + '+';
	/* The following pattern describes the structure of a normal symbolic
	domain, as opposed to ipDomainPat, shown above. */	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");	
	/* Begin with the pattern to break up user@domain into 2 pieces*/
	var matchArray=emailStr.match(emailPat);	
	if (matchArray==null) {
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	// Check that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("Ths domain name contains invalid characters.");
			return false;
	   }
	}
	// Make sure there's a host name
	if (len<2) {
		alert("This address is missing a hostname!");
		return false;
	}
	// everything's valid!
	document.HotList.submit();
	return true;
}