function validate_login_form ( )
{
    valid = true;

    if ( document.login_form.UserEmail.value == "" )
    {
        alert ( "Please fill in your Email Address." );
        document.login_form.UserEmail.focus();
        valid = false;
       	return valid;
    }
    

    return valid;
    form.submit();
}

function validate_reset_pass ( )
{
    valid = true;

    if ( document.login_form.username.value == "" )
    {
        alert ( "Please fill in your Email Address." );
        document.login_form.username.focus();
        valid = false;
       	return valid;
    }
    if ( document.login_form.password.value == "" )
    {
        alert ( "Please fill in your Password." );
        document.login_form.password.focus();
        valid = false;
        return valid;
    }
    if ((document.login_form.password.value.length < 4) || (document.login_form.password.value.length > 15)) 
    {
	alert ("The password is the wrong length.\n");
	document.login_form.password.focus();
	valid = false;
	return valid;
    }
    if ( document.login_form.password.value != document.login_form.password2.value)
    {
	alert ( "Please make sure both Password fields match" );
	document.login_form.password2.focus();
	valid = false;
	return valid;
    }
    

    return valid;
    form.submit();
}

function validate_form ( )
{
    valid = true;

	if ( document.contact_form.UserFName.value == "" )
	{
		alert ( "Please fill in your First Name." );
		document.contact_form.UserFName.focus();
		valid = false;
		return valid;
	}
	if ( document.contact_form.UserLName.value == "" )
	{
		alert ( "Please fill in your Last Name." );
		document.contact_form.UserLName.focus();
		valid = false;
		return valid;
	}
	if ( document.contact_form.UserEmail.value == "" )
	{
		alert ( "Please fill in your Email Address." );
		document.contact_form.UserEmail.focus();
		valid = false;
		return valid;
	}
	
	var checkEmail = "@.";
	var checkStr = document.contact_form.UserEmail.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkEmail.length;  j++)
			{
				if (ch == checkEmail.charAt(j) && ch == "@")
				{
					EmailAt = true;
				}
				if (ch == checkEmail.charAt(j) && ch == ".")
				{
					EmailPeriod = true;
				}
			  	if (EmailAt && EmailPeriod)
			  	{
					break;
				}
			  	if (j == checkEmail.length)
			  	{
					break;
				}
			}
			
			// if both the @ and . were in the string
				if (EmailAt && EmailPeriod)
				{	
					EmailValid = true
					break;
				}	
		}
		if (!EmailValid)
		{
			alert("The Email Address must contain an \"@\" and a \".\".");
			document.contact_form.UserEmail.focus();
			valid = false;
			return valid;
		}
		
	
	    return valid;
	    form.submit();
}

function validate_email_form ( )
	{
	    valid = true;
	
		if ( document.email_form.UserEmail.value == "" )
		{
			alert ( "Please fill in your Email Address." );
			document.email_form.UserEmail.focus();
			valid = false;
			return valid;
		}
		if ( document.email_form.FriendEmail.value == "" )
		{
			alert ( "Please fill in the email address of whom you wish to send this message." );
			document.email_form.FriendEmail.focus();
			valid = false;
			return valid;
		}
	
		var checkEmail = "@.";
		var checkStr = document.email_form.FriendEmail.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
			for (i = 0;  i < checkStr.length;  i++)
			{
				ch = checkStr.charAt(i);
				for (j = 0;  j < checkEmail.length;  j++)
				{
					if (ch == checkEmail.charAt(j) && ch == "@")
					{
						EmailAt = true;
					}
					if (ch == checkEmail.charAt(j) && ch == ".")
					{
						EmailPeriod = true;
					}
				  	if (EmailAt && EmailPeriod)
				  	{
						break;
					}
				  	if (j == checkEmail.length)
				  	{
						break;
					}
				}
				
				// if both the @ and . were in the string
					if (EmailAt && EmailPeriod)
					{	
						EmailValid = true
						break;
					}	
			}
			if (!EmailValid)
			{
				alert("The Email Address must contain an \"@\" and a \".\".");
				document.email_form.FriendEmail.focus();
				valid = false;
				return valid;
			}
	
	
	    return valid;
	    form.submit();
}



