/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name       :  ClickMembersOnlySubmit
' Purpose    :  Perform form validation on the Members-Only Area
'            :  subscription form.  If everything is valid, 
'		submit the form.
' Parameters :  none.
' Return val :  none.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function ClickMembersOnlySubmit()
{
	var firstname = document.frmSignUp.iFirstname.value;
	var lastname = document.frmSignUp.iLastname.value;
	var emailAddress = document.frmSignUp.iEmail.value;
	var studentRelation = document.frmSignUp.iRelation.value;
	var studentFirstname = document.frmSignUp.iStudentFirstname.value;
	var studentLastname = document.frmSignUp.iStudentLastname.value;
	var studentSection = document.frmSignUp.iSection.value;
        var studentClass = document.frmSignUp.iClass.value;
	var username = document.frmSignUp.iUsername.value;
	var password1 = document.frmSignUp.iPassword1.value;
	var password2 = document.frmSignUp.iPassword2.value;

	// validate name
	if (firstname.length <= 0)
	{
		alert("Please enter a first name...");
		// set focus to First Name
		document.frmSignUp.iFirstname.focus();
		return false;
	}
	if (lastname.length <= 0)
	{
		alert("Please enter a last name...");
		// set focus to Last Name
		document.frmSignUp.iLastname.focus();
		return false;
	}

	// validate email address
	if (emailAddress.length <= 0)
	{
		alert("Please enter an e-mail address...");
		// set focus to email address
		document.frmSignUp.iEmail.focus();
		return false;
	}
	else
	{
		// Verify if the given value is a possible valid email address by making sure the email address has:
		// 1) one "@" and at least one "."
		// 2) no spaces, extra "@"s or a "." just before or after the "@"
		// 3) at least one "." after the "@"
		var at = "@";
		var dot = ".";
		var lat = emailAddress.indexOf(at);
		var lstr = emailAddress.length;
		var ldot = emailAddress.indexOf(dot);
		if (emailAddress.indexOf(at) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at) == -1 || emailAddress.indexOf(at) == 0 || emailAddress.indexOf(at) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot) == -1 || emailAddress.indexOf(dot) == 0 || emailAddress.indexOf(dot) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at, (lat + 1)) != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.substring(lat - 1, lat) == dot || emailAddress.substring(lat + 1, lat + 2) == dot)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot, (lat + 2)) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(" ") != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}
	}

	// validate student relation
	if (studentRelation.length <= 0)
	{
		alert("Select a student relation...");
		// set focus to student relation
		document.frmSignUp.iRelation.focus();
		return false;
	}

	if (studentRelation == "Parent")
	{
		// validate student's name
		if (studentFirstname.length <= 0)
		{
			alert("Please enter a student's first name...");
			// set focus to Student's First Name
			document.frmSignUp.iStudentFirstname.focus();
			return false;
		}
		if (studentLastname.length <= 0)
		{
			alert("Please enter a student's last name...");
			// set focus to Student's Last Name
			document.frmSignUp.iStudentLastname.focus();
			return false;
		}
	}

	if (studentRelation == "Parent" || studentRelation == "Self")
	{
		// validate student section
		if (studentSection.length <= 0)
		{
			alert("Select a student section...");
			// set focus to student section
			document.frmSignUp.iSection.focus();
			return false;
		}
	}


	// validate student section
	if (studentClass.length <= 0)
	{
		alert("Select a student classification...");
		// set focus to student classification
		document.frmSignUp.iClass.focus();
		return false;
	}


	var invalidCharList = " ";	// Invalid character is a space

	// validate username
	if (username.length <= 0)
	{
		alert("Please enter a valid username...");
		// set focus to Username
		document.frmSignUp.iUsername.focus();
		return false;
	}

	// check for spaces
	if (username.indexOf(" ") > -1)
	{
		alert("Spaces are not allowed in your username.  Please try again...");
		document.frmSignUp.iUsername.focus();
		return false;
	}

	// validate password
	var minLength = 8;
	var maxLength = 16;

	// check for proper length
	if (password1.length < minLength)
	{
		alert('Your password must be between ' + minLength + ' and ' + maxLength + ' characters long.  Please try again...');
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for spaces
	if (password1.indexOf(" ") > -1)
	{
		alert("Spaces are not allowed in your password.  Please try again...");
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for a value in both fields.
	if (password1.length <= 0 || password2.length <= 0)
	{
		alert('Please enter your password twice.  Please try again...');
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for password validation
	if (password1 != password2)
	{
		alert ("Password entries do not match.  Please try again...");
		return false;
	}

	document.frmSignUp.submit();
}


/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name       :  ClickAlumniAreaSubmit
' Purpose    :  Perform form validation on the Alumni Area
'            :  subscription form.  If everything is valid, 
'		submit the form.
' Parameters :  none.
' Return val :  none.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function ClickAlumniAreaSubmit()
{
	var firstname = document.frmSignUp.iFirstname.value;
	var lastname = document.frmSignUp.iLastname.value;
	var emailAddress = document.frmSignUp.iEmail.value;
	var alumniRelation = document.frmSignUp.iRelation.value;
	var alumniFirstname = document.frmSignUp.iAlumniFirstname.value;
	var alumniLastname = document.frmSignUp.iAlumniLastname.value;
	var alumniSection = document.frmSignUp.iSection.value;
        var alumniClass = document.frmSignUp.iClass.value;
	var username = document.frmSignUp.iUsername.value;
	var password1 = document.frmSignUp.iPassword1.value;
	var password2 = document.frmSignUp.iPassword2.value;

	// validate name
	if (firstname.length <= 0)
	{
		alert("Please enter a first name...");
		// set focus to First Name
		document.frmSignUp.iFirstname.focus();
		return false;
	}
	if (lastname.length <= 0)
	{
		alert("Please enter a last name...");
		// set focus to Last Name
		document.frmSignUp.iLastname.focus();
		return false;
	}

	// validate email address
	if (emailAddress.length <= 0)
	{
		alert("Please enter an e-mail address...");
		// set focus to email address
		document.frmSignUp.iEmail.focus();
		return false;
	}
	else
	{
		// Verify if the given value is a possible valid email address by making sure the email address has:
		// 1) one "@" and at least one "."
		// 2) no spaces, extra "@"s or a "." just before or after the "@"
		// 3) at least one "." after the "@"
		var at = "@";
		var dot = ".";
		var lat = emailAddress.indexOf(at);
		var lstr = emailAddress.length;
		var ldot = emailAddress.indexOf(dot);
		if (emailAddress.indexOf(at) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at) == -1 || emailAddress.indexOf(at) == 0 || emailAddress.indexOf(at) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot) == -1 || emailAddress.indexOf(dot) == 0 || emailAddress.indexOf(dot) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at, (lat + 1)) != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.substring(lat - 1, lat) == dot || emailAddress.substring(lat + 1, lat + 2) == dot)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot, (lat + 2)) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(" ") != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmSignUp.iEmail.focus();
			return false;
		}
	}

	// validate alumni relation
	if (alumniRelation.length <= 0)
	{
		alert("Select aa alumni relation...");
		// set focus to alumni relation
		document.frmSignUp.iRelation.focus();
		return false;
	}

	if (alumniRelation == "Parent")
	{
		// validate alumni's name
		if (alumniFirstname.length <= 0)
		{
			alert("Please enter an alumni's first name...");
			// set focus to Alumni's First Name
			document.frmSignUp.iAlumniFirstname.focus();
			return false;
		}
		if (alumniLastname.length <= 0)
		{
			alert("Please enter an alumni's last name...");
			// set focus to Alumni's Last Name
			document.frmSignUp.iAlumniLastname.focus();
			return false;
		}
	}

	if (alumniRelation == "Parent" || alumniRelation == "Self")
	{
		// validate alumni section
		if (alumniSection.length <= 0)
		{
			alert("Select an alumni section...");
			// set focus to alumni section
			document.frmSignUp.iSection.focus();
			return false;
		}

		// validate alumni section
		if (alumniClass.length <= 0)
		{
			alert("Select an alumni classification...");
			// set focus to alumni classification
			document.frmSignUp.iClass.focus();
			return false;
		}
	}


	var invalidCharList = " ";	// Invalid character is a space

	// validate username
	if (username.length <= 0)
	{
		alert("Please enter a valid username...");
		// set focus to Username
		document.frmSignUp.iUsername.focus();
		return false;
	}

	// check for spaces
	if (username.indexOf(" ") > -1)
	{
		alert("Spaces are not allowed in your username.  Please try again...");
		document.frmSignUp.iUsername.focus();
		return false;
	}

	// validate password
	var minLength = 8;
	var maxLength = 16;

	// check for proper length
	if (password1.length < minLength)
	{
		alert('Your password must be between ' + minLength + ' and ' + maxLength + ' characters long.  Please try again...');
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for spaces
	if (password1.indexOf(" ") > -1)
	{
		alert("Spaces are not allowed in your password.  Please try again...");
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for a value in both fields.
	if (password1.length <= 0 || password2.length <= 0)
	{
		alert('Please enter your password twice.  Please try again...');
		document.frmSignUp.iPassword1.focus();
		return false;
	}

	// check for password validation
	if (password1 != password2)
	{
		alert ("Password entries do not match.  Please try again...");
		return false;
	}

	document.frmSignUp.submit();
}


/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name       :  ClickContactSubmit
' Purpose    :  Perform form validation on the Alumni Area
'            :  subscription form.  If everything is valid, 
'		submit the form.
' Parameters :  none.
' Return val :  none.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function ClickContactSubmit()
{
	var firstname = document.frmMessage.iFirstname.value;
	var lastname = document.frmMessage.iLastname.value;
	var emailAddress = document.frmMessage.iEmail.value;
	var comments = document.frmMessage.iComment.value;


	// validate name
	if (firstname.length <= 0)
	{
		alert("Please enter a first name...");
		// set focus to First Name
		document.frmMessage.iFirstname.focus();
		return false;
	}
	if (lastname.length <= 0)
	{
		alert("Please enter a last name...");
		// set focus to Last Name
		document.frmMessage.iLastname.focus();
		return false;
	}

	// validate email address
	if (emailAddress.length <= 0)
	{
		alert("Please enter an e-mail address...");
		// set focus to email address
		document.frmMessage.iEmail.focus();
		return false;
	}
	else
	{
		// Verify if the given value is a possible valid email address by making sure the email address has:
		// 1) one "@" and at least one "."
		// 2) no spaces, extra "@"s or a "." just before or after the "@"
		// 3) at least one "." after the "@"
		var at = "@";
		var dot = ".";
		var lat = emailAddress.indexOf(at);
		var lstr = emailAddress.length;
		var ldot = emailAddress.indexOf(dot);
		if (emailAddress.indexOf(at) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at) == -1 || emailAddress.indexOf(at) == 0 || emailAddress.indexOf(at) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot) == -1 || emailAddress.indexOf(dot) == 0 || emailAddress.indexOf(dot) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at, (lat + 1)) != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.substring(lat - 1, lat) == dot || emailAddress.substring(lat + 1, lat + 2) == dot)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot, (lat + 2)) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(" ") != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmMessage.iEmail.focus();
			return false;
		}
	}
	if (comments.length <= 0)
	{
		alert("Please enter a comment...");
		// set focus to Last Name
		document.frmMessage.iComment.focus();
		return false;
	}


	document.frmMessage.submit();
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name       :  ClickGolfRegistrationSubmit
' Purpose    :  Perform form validation on the Alumni Area
'            :  subscription form.  If everything is valid, 
'		submit the form.
' Parameters :  none.
' Return val :  none.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function ClickGolfRegistrationSubmit()
{
	var player1Name = document.frmGolfRegistration.Player1Name.value;
	var player2Name = document.frmGolfRegistration.Player2Name.value;
	var player3Name = document.frmGolfRegistration.Player3Name.value;
	var player4Name = document.frmGolfRegistration.Player4Name.value;
	var playerCount = document.frmGolfRegistration.PlayerCount.value;
	var teamName = document.frmGolfRegistration.iTeamName.value;
	var emailAddress = document.frmGolfRegistration.iEmail.value;
	var p1shirtSize = document.frmGolfRegistration.P1ShirtSize.value;
	var p2shirtSize = document.frmGolfRegistration.P2ShirtSize.value;
	var p3shirtSize = document.frmGolfRegistration.P3ShirtSize.value;	
	var p4shirtSize = document.frmGolfRegistration.P4ShirtSize.value;
	var phone = document.frmGolfRegistration.iPhone.value;


	// validate name
	if (player1Name.length <= 0)
	{
		alert("Please enter a name for player #1");
		// set focus to First Name
		document.frmGolfRegistration.Player1Name.focus();
		return false;
	}
	if (playerCount > 1)
	{
		if (player2Name.length <= 0)
		{
			alert("Please enter a name for player #2");
			// set focus to Last Name
			document.frmGolfRegistration.Player2Name.focus();
			return false;
		}
	}

	if (playerCount > 2)
	{
		if (player3Name.length <= 0)
		{
			alert("Please enter a name for player #3");
			// set focus to Last Name
			document.frmGolfRegistration.Player3Name.focus();
			return false;
		}
	}

	if (playerCount > 3)
	{
		if (player4Name.length <= 0 && playerCount > 3)
		{
			alert("Please enter a name for player #4");
			// set focus to Last Name
			document.frmGolfRegistration.Player4Name.focus();
			return false;
		}
	}
		// validate shirtSize section
	if (p1shirtSize == 0)
	{
		alert("Select a shirt size for player #1");
		// set focus to shirtSize classification
		document.frmGolfRegistration.P1ShirtSize.focus();
		return false;
	}
	if (p2shirtSize == 0 && playerCount > 1)
	{
		alert("Select a shirt size for player #2");
		// set focus to shirtSize classification
		document.frmGolfRegistration.P2ShirtSize.focus();
		return false;
	}
	if (p3shirtSize == 0 && playerCount > 2)
	{
		alert("Select a shirt size for player #3");
		// set focus to shirtSize classification
		document.frmGolfRegistration.P3ShirtSize.focus();
		return false;
	}
	if (p4shirtSize == 0 && playerCount > 3)
	{
		alert("Select a shirt size for player #4");
		// set focus to shirtSize classification
		document.frmGolfRegistration.P4ShirtSize.focus();
		return false;
	}
	
	if (teamName.length <= 0)
	{
		alert("Please enter a team name or 'NONE'.");
		// set focus to Last Name
		document.frmGolfRegistration.iTeamName.focus();
		return false;
	}
	
	// validate email address
	if (emailAddress.length <= 0)
	{
		alert("Please enter an e-mail address...");
		// set focus to email address
		document.frmGolfRegistration.iEmail.focus();
		return false;
	}
	else
	{
		// Verify if the given value is a possible valid email address by making sure the email address has:
		// 1) one "@" and at least one "."
		// 2) no spaces, extra "@"s or a "." just before or after the "@"
		// 3) at least one "." after the "@"
		var at = "@";
		var dot = ".";
		var lat = emailAddress.indexOf(at);
		var lstr = emailAddress.length;
		var ldot = emailAddress.indexOf(dot);
		if (emailAddress.indexOf(at) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at) == -1 || emailAddress.indexOf(at) == 0 || emailAddress.indexOf(at) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot) == -1 || emailAddress.indexOf(dot) == 0 || emailAddress.indexOf(dot) == lstr)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(at, (lat + 1)) != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.substring(lat - 1, lat) == dot || emailAddress.substring(lat + 1, lat + 2) == dot)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(dot, (lat + 2)) == -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}

		if (emailAddress.indexOf(" ") != -1)
		{
			alert("Please enter a valid e-mail address...");
			// set focus to email address
			document.frmGolfRegistration.iEmail.focus();
			return false;
		}
	}
	
	if (phone.length <= 0)
	{
		alert("Please enter a contact phone number.");
		// set focus to Last Name
		document.frmGolfRegistration.iPhone.focus();
		return false;
	}
	
	document.frmGolfRegistration.submit();
}


