// JavaScript Document
function check(inputText, inputValue)
{
	if(inputValue == "") 
	{
		alert(inputText + " is a required field and is currently empty. Please enter valid information");
		return false;
	}
	
	if(inputValue < 1)
	{
		alert("You have not selected a valid option for " + inputText + ". Please enter valid information.");
		return false;
	}
	
	if(inputValue.length < 2)
	{
		alert("The length of " + inputText + " is too short to be valid. Please enter valid information.");
		return false;
	}	
	return true;
}

function checkEmail(inputText, inputValue)
{
	var a = 0;
	var p = 0;
	for(var i = 1; i < inputValue.length; i++)
	{
		if(!inputValue.charAt(i))
		{
			return false;
		}
		else if(inputValue.charAt(i) == '@')
		{
			a++;
			if(inputValue.charAt(i + 1) == '')
			{ 
				alert(inputText + " is not valid. Please enter a valid email address.");
				return false;
		    }
		}
		else if(inputValue.charAt(i) == '.')
		{
			p++;
			if(inputValue.charAt(i + 1) == '' || inputValue.charAt(i + 1) == '@' || inputValue.charAt(i - 1) == '@')
			{ 
				alert(inputText + " is not valid. Please enter a valid email address.");
				return false; 
			}
		}
	}
	if(a == 1&&p)
	{ 
		return true; 
	}
	else 
	{ 
		alert(inputText + " is not valid. Please enter a valid email address.");
		return false; 
	}
	return true;
}
	
function checkPass(inputText, pass1, pass2)
{
	if(pass1 == "") 
	{
		alert(inputText + " is a required field and is currently empty.");
		return false;
	}
	
	if(pass1 != pass2)
	{
		alert("Your passwords do not match. Please re-enter your passwords.");
		return false;
	}
	return true;
}

function checkNumber(inputText, inputValue)
{
	if(isNaN(inputValue))
	{
		alert("Your "+inputText+" is not a number. Please enter a valid "+inputText+".");
		return false;
	}
	if(!check(inputText, inputValue)) {return false;}
	
	return true;
}

function checkDate(inputText, year, month)
{
	date = new Date(year, month);
	today = new Date();
	if( date < today )
	{
		alert("Your "+inputText+" is not a valid Date. Please enter a valid "+inputText+".");
		return false;
	}
	return true;
}