function isEmail(s){
	var i = 1;
	var sLength = s.length;
	while ((i < sLength) && (s.charAt(i) != "@")){ i++ }
	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;
	while ((i < sLength) && (s.charAt(i) != ".")){ i++ }
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}
function isNumeric(sText) {
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}
function ValidateForm1(form){
	if(form.cancel.value != "1"){
		if(form.teamID.value == ""){
			alert("Please select a team.");
			form.teamID.focus();
			return false;
		}
		if(form.teamID.value == "0" && form.title.value == ""){
			alert("Please enter a team name.");
			form.title.focus();
			return false;
		}
		if(form.teamID.value == "00" && form.teamID2.value == ""){
			alert("Please select a team to duplicate.");
			form.teamID2.focus();
			return false;
		}
		if(form.teamID.value == "00" && form.title.value == ""){
			alert("Please enter a team name.");
			form.title.focus();
			return false;
		}
		var radio_choice = false;
		for (counter = 0; counter < form.strength.length; counter++)
		{
			if (form.strength[counter].checked) {
				radio_choice = true;  
			}
		}
		if (form.teamID.value == "0" && !radio_choice)
		{
			alert("Please select the strength of your team.")
			return false;
		}
	}
	return true;
}
function ValidateForm2(form){
	if(form.cancel.value != "1"){
		if(form.rosterID.value == ""){
			alert("Please select a roster.");
			form.rosterID.focus();
			return false;
		}
		if(form.rosterID.value == "0" && form.title.value == ""){
			alert("Please enter a roster name.");
			form.title.focus();
			return false;
		}
		if(form.rosterID.value == "00" && form.rosterID2.value == ""){
			alert("Please select a roster to duplicate.");
			form.rosterID2.focus();
			return false;
		}
		if(form.rosterID.value == "00" && form.title.value == ""){
			alert("Please enter a roster name.");
			form.title.focus();
			return false;
		}
		/*if(form.division.value == ""){
		alert("Please enter your team's division.");
		form.division.focus();
		return false;
		}*/
		var radio_choice = false;
		for (counter = 0; counter < form.strength.length; counter++)
		{
			if (form.strength[counter].checked) {
				radio_choice = true;  
			}
		}
		if (!radio_choice)
		{
			alert("Please select the strength of your team.")
			return false;
		}
	}
	return true;
}
function ValidateForm3(form){
	if(form.newPlayer.value == "1" && form.cancel.value != "1"){
		if(form.first_name.value == ""){
			alert("Please enter a first name.");
			form.first_name.focus();
			return false;
		}
		if(form.last_name.value == ""){
			alert("Please enter a last name.");
			form.last_name.focus();
			return false;
		}
		if(form.high_school.value == ""){
			alert("Please enter a high school.");
			form.high_school.focus();
			return false;
		}
		if(form.address.value == ""){
			alert("Please enter an address.");
			form.address.focus();
			return false;
		}
		if(form.city.value == ""){
			alert("Please enter a city.");
			form.city.focus();
			return false;
		}
		if(form.state.value == ""){
			alert("Please enter a state.");
			form.state.focus();
			return false;
		}
		if(form.zip.value == ""){
			alert("Please enter a zip code.");
			form.zip.focus();
			return false;
		}
		if(form.cell1.value == "" || form.cell2.value == "" || form.cell3.value == ""){
			alert("Please enter a cell phone number.");
			form.cell1.focus();
			return false;
		}
		if(!isNumeric(form.cell1.value) || !isNumeric(form.cell2.value) || !isNumeric(form.cell3.value) || form.cell1.value.length < 3 || form.cell2.value.length < 3 || form.cell3.value.length < 4){
			alert("Please enter a valid cell phone number.");
			form.cell1.value="";
			form.cell2.value="";
			form.cell3.value="";
			form.cell1.focus();
			return false;
		}
		if((form.email.value != "")&&(form.email.value != null)){
			if(!isEmail(form.email.value)){
				alert("Please enter a valid email address.");
				form.email.value="";
				form.email.focus();
				return false;
			}
		} else {
				alert("Please enter an email address.");
				form.email.focus();
				return false;
		}
	}
	return true;
}
function hide(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
		if (obj.style.display == ""){ 
			obj.style.display = "none"; 
		}
	} 
} 
function show(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
		if (obj.style.display == "none"){ 
			obj.style.display = ""; 
		}
	} 
} 
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.UploadForm." + Which + "Day");
  MonthObject = eval("document.UploadForm." + Which + "Month");
  YearObject = eval("document.UploadForm." + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.UploadForm." + Which + "Day");
  MonthObject = eval("document.UploadForm." + Which + "Month");
  YearObject = eval("document.UploadForm." + Which + "Year");

  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
  line = "";
  for (i=0; i<YearsAhead; i++)
  {
    line += "<OPTION>";
    line += NowYear + i;
  }
  return line;
}
