function checkAccessForm(eMail, password, formName) {
	if (!checkEmail(eMail))
		return
	else if (password.length < 4)
		alert("Please enter your password\n(must be at least 4 characters)")
	else {	
		document.accessForm.dbFunction.value = formName
		document.accessForm.eMail.value = eMail
		document.accessForm.password.value = password
		switch(formName) {
		case "teacherAccess" : document.accessForm.submit()
			break
		case "studentAccess" : document.accessForm.submit()
		}
	}
}

function checkEmail ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is a valid email address.*/
/* Valid email addresses can only contain letters, numbers, 1 asterisk, and  */
/* the following characters: @.-_!                                           */
/* Receives : The value to check                                             */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	var errormsg = "Please make sure your e-mail address is correct!"

	// Return false if blank.
	if ( objectValue.length == 0 ) {
		alert(errormsg)
		return false
	}

	// Make sure contains valid characters.
	if ( !checkValidChars( objectValue, true, true, false, "@.-_!")) {
		alert(errormsg)
		return false
	}

	// Make sure valid length.
	if ( objectValue.length < 7 ) {
		alert(errormsg)
		return false
	}

	// Make sure there is only 1 @ symbol and at least 1 period.
	var foundAt 	= false;
	var foundPeriod = false;
	
	for ( i = 0; i < objectValue.length; i++ )
	{
		if ( objectValue.charAt(i) == "@" ) // Second @ symbol.
			if ( foundAt ) {    
				alert(errormsg)
				return false
			} else
				foundAt = true;
		if ( objectValue.charAt(i) == "." )
			foundPeriod = true;
	}
	
	if ( foundAt && foundPeriod )
		return true;
	else {
		alert(errormsg)
		return false
	}
}



function checkValidChars ( objectValue, allowNumbers, allowLetters, allowSpaces, specialChars, isInclude )
/*****************************************************************************/
/*                                                                           */
/* Receives :                                                                */
/* Returns  :                                                                */
/*****************************************************************************/
{
	// Set default variables.
	if ( allowNumbers == null )
		allowNumbers = true;
		
	if ( allowLetters == null )
		allowLetters = true;

	if ( allowSpaces == null )
		allowSpaces = true;

	if ( specialChars == null )
		specialChars = "";

	if ( isInclude == null )
		isInclude = true;

	// Verify passed variables.
	if (( allowNumbers != true ) && ( allowNumbers != false ))
	{
		alert("Invalid variable : allowNumbers\ntrue of false expected");
		return false;
	}
	
	if (( allowLetters != true ) && ( allowLetters != false ))
	{
		alert("Invalid variable : allowLetters\ntrue of false expected");
		return false;
	}
	
	if (( allowSpaces != true ) && ( allowSpaces != false ))
	{
		alert("Invalid variable : allowSpaces\ntrue of false expected");
		return false;
	}
		
	if ( objectValue.length == 0 )
		return true;
		
	if (( isInclude != true ) && ( isInclude != false ))
	{
		alert("Invalid variable : isInclude\ntrue of false expected");
		return false;
	}
		
	// Initialize local variables.
	var letters			= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var charCheck;

	for ( i = 0; i < objectValue.length; i++ )
	{
		if ( !isNaN(objectValue.charAt(i)) )
		{
			if (!(objectValue.charAt(i) == " "))
			{
				if ( !allowNumbers )
					return false;
			}
			else if ( !allowSpaces )
				return false;
		}
		else if ( !(letters.indexOf(objectValue.charAt(i)) < 0) )
		{
			if ( !allowLetters )
				return false;		
		}
		else if ( objectValue.charAt(i) == " " )
		{
			if ( !allowSpaces )
				return false;
		}
		else if ( isInclude )
		{
			if ( specialChars.indexOf(objectValue.charAt(i)) < 0 )
				return false;
		}
		else
		{
			if ( !( specialChars.indexOf(objectValue.charAt(i)) < 0 ) )
				return false;
		}
		
	}
	
	return true;
}




