function validateEmail(address)	// validateEmail() function to do a high-level validation of an email address on an html form
{
	var email = address.value;	// read in the user's input
	if(email==""){return true;}	// if user did not enter anything, do nothing.
	
	var atIndex = email.indexOf("@");	// find the index of the '@' symbol, which is required for an email address
	
	if(atIndex==-1)	// if the index is -1, no '@' was found, notify the user & return false
	{alert("Your email address must contain a '@' character."); address.select(); return false;}
	
	if(atIndex==0)	// if the index is 0, there is an '@' as the first character, which is not valid; notify the user & return false
	{alert("Your email address must not start with '@' symbol."); address.select(); return false;}
	
	for(var i=atIndex+1;i<email.length;i++)	// loop through the rest of the string after the '@' symbol, looking for any additional '@' symbols
	{
		if(email.charAt(i)=="@")	// if we find any additional '@' symbols, notify the user & return false
		{alert("Your email address must contain only one '@' symbol."); address.select(); return false;}
	}
	
	if((email.charAt(atIndex-1)==".")||(email.charAt(atIndex+1)=="."))	// if there is a '.' immediately prior to, or immediately after, the '@' symbol (which is invalid)...
	{alert("'.' and '@' symbols must not occur next to each other in your email address."); address.select(); return false;}	//...notify the user & return false
	
	if(email.indexOf("..") !=-1)	// if there are any occurances of adjacent "."s (which is not valid), notify the user & return false
	{alert("Your email address must not contain adjacent '.' symbols."); address.select(); return false;}
	
	var domainName = email.substring(atIndex+1,email.length);		// domainName is everything following the '@' symbol
	var lastDotIndex = domainName.lastIndexOf(".");					// lastDotIndex is the index of the last '.' in the string (which is to be followed by a suffix like .com or .edu)
	var suffix = domainName.substring(lastDotIndex+1,email.length);	// suffix is everything following the last '.' in the string
	
	if((lastDotIndex==-1)||(suffix.length < 2)||(suffix.length >4))	// if there is not a '.' in the domainName, notify the user & return false.
	{alert("Your email address must end with a '.' followed by a \n  two to four character suffix such as .com or .net."); address.select(); return false;}
	
	return true;
}
