function checkEmail(emailField)
{
	//first, check there is e-mail
	//it is not empty
	var strEmail;
	var strMessage;
	var intIndex;
	var intEmailLength;
	var charAt = "@";
	var charPeriod = ".";
	var intAtIndex;
	var intPeriodIndex;
	var intFinalPeriodIndex;
	var charAfterAt;
	var charBeforeAt;
	
	strEmail = emailField.value;
	//alert(strEmail); 
	
	intEmailLength = strEmail.length;
	var intAtCounter = 0;
	var intPeriodCounter = 0;
	
	if(intEmailLength == 0)
	{
		//if email is empty
		alert("Please enter your e-mail address. Thank you.");
		return false;
	}
	//step through the email address and see
	for(intIndex = 0; intIndex < intEmailLength; intIndex++)
	{
		if(strEmail.charAt(intIndex) == charAt)
		{
			intAtCounter = intAtCounter + 1;
		}
		if(strEmail.charAt(intIndex) == charPeriod)
		{
			intPeriodCounter = intPeriodCounter + 1;
			intFinalPeriodIndex = intIndex;
			//check whether or not there are two consecutive periods
			//because can possibly have two non-consecutive periods
			//intPeriodIndex = intIndex;
			if(strEmail.charAt(intIndex + 1) == charPeriod)
			{
				strMessage = "There are two consecutive periods in ";
				strMessage = strMessage + "your e-mail address. ";
				strMessage = strMessage + "Please check your email address.";
				strMessage = strMessage + " Thank you.";
				alert(strMessage);
				emailField.focus();
				return false;
				
			}
			
		}
	}
	//if there is no at sign, notify user
	if(intAtCounter == 0)
	{	
		strMessage = "There should be an '@' in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail again. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false; 
	}//
	//if there is no period, notify user
	if(intPeriodCounter == 0)
	{
		strMessage = "There should be a '.' in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail again. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false;	
	}
	//if At sign or period written more than once, incorrect
	if(intAtCounter > 1)
	{
		strMessage = "There is more than one '@' in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail again. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false;
	}
	//---The problem with bringing up an error when there is more than one period
	//is some e-mail addresses may have two periods, e.g. first.last@university.edu
	//if(intPeriodCounter > 1)
	//{
	//	strMessage = "There is more than one '.' in your e-mail address. ";
	//	strMessage = strMessage + "Please check your e-mail again. Thank you.";
	//	alert(strMessage);
	//	emailField.focus();
	//	return false;
	//}
	//now, that we've seen there is exactly one At sign in the e-mail
	//we check that there are not period and At sign immediately adjacent to each other
	intAtIndex = strEmail.indexOf(charAt);
	charAfterAt = strEmail.charAt(intAtIndex + 1);
	charBeforeAt = strEmail.charAt(intAtIndex - 1);
	//first, check the '@' is not at the very beginning of the e-mail address
	if(intAtIndex == 0)
	{
		strMessage = "The '@' should not be at the beginning of your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail address. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false;
	}
	
	if( (charBeforeAt == charPeriod)  || (charAfterAt == charPeriod))
	{
		strMessage = "There is a '.' adjacent to the '@' in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail address. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false; 
	}
	//check that there is a period after the at sign, as there should be
	if(intFinalPeriodIndex < intAtIndex)
	{
		strMessage = "There should be a '.' after the '@' in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail address again. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false;
	}
	//make sure the '.' is not the end
	if(intFinalPeriodIndex == intEmailLength-1)
	{
		strMessage = "The '.' should not be the last character ";
		strMessage = strMessage + "in your e-mail address. ";
		strMessage = strMessage + "Please check your e-mail address again. Thank you.";
		alert(strMessage);
		emailField.focus();
		return false;
	}
	return true;
	
}