// JavaScript Document

function showCountdown()
{
  document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='200' height='24'>");
  document.write ("<param name='movie' value='http://www.ulax.org/admin/countdown.swf'>");
  document.write ("<param name='quality' value='high'>");
  document.write ("<param name='menu' value='false'>");
  document.write ("<embed src='http://www.ulax.org/admin/countdown.swf' width='200' height='24' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='false'></embed></object>");
}

function showGame(id, league)
{
  window.open('playoff_game.asp?league=' + league + '&id=' + id, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=350,height=375');
}

function bio(l, n)
{
  window.open('bio.asp?league=' + l + '&num=' + n, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=770,height=320,screenX=0,screenY=0,top=0,left=0');
}

//signup form
function getPayments(arbor, atlanta, bloomington, boston, boulder, buffalo, chicago, columbus, denver, fairfield, li, madison, ny, orange, philly, pittsburgh, providence, francisco, somerset, virginia, westchester)
{    
  var payments = new Array();
    
  document.form1.payment.disabled = false;
  
  for (var i=document.form1.payment.options.length-1; i>=0; i--)
  {
    document.form1.payment.options[i] = null;
  }
  document.form1.payment.selectedIndex = -1;  
  document.form1.payment.options[document.form1.payment.options.length]=new Option("- select -", "");
  
  if(document.form1.league.value == "arbor")
  {
    if(arbor.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(arbor.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "atlanta")
  {    	
	if(atlanta.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(atlanta.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "bloomington")
  {    	
	if(bloomington.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(bloomington.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "boston")
  {    	
	if(boston.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(boston.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "boulder")
  {    	
	if(boulder.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(boulder.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "buffalo")
  {    	
	if(buffalo.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(buffalo.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "chicago")
  {    	
	if(chicago.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(chicago.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "columbus")
  {    	
	if(columbus.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(columbus.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "denver")
  {    	
	if(denver.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(denver.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "fairfield")
  {    	
	if(fairfield.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(fairfield.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "li")
  {    	
	if(li.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(li.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }  
  
  if(document.form1.league.value == "madison")
  {    	
	if(li.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(li.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }  
  
  if(document.form1.league.value == "ny")
  {    	
	if(ny.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(ny.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "orange")
  {    	
	if(orange.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(orange.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "philly")
  {    	
	if(philly.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(philly.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "pittsburgh")
  {    	
	if(pittsburgh.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(pittsburgh.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "providence")
  {    	
	if(providence.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(providence.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "francisco")
  {    	
	if(francisco.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(francisco.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "somerset")
  {    	
	if(francisco.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(francisco.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "virginia")
  {    	
	if(virginia.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(virginia.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
  
  if(document.form1.league.value == "westchester")
  {    	
	if(westchester.charAt(0) == 1)	
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('Check', 'Check');
	  
	if(westchester.charAt(2) == 1)
	  document.form1.payment.options[document.form1.payment.options.length]=new Option('PayPal', 'PayPal');
  }
}

function getTeams(arbor, atlanta, bloomington, boston, boulder, buffalo, chicago, columbus, denver, fairfield, li, madison, ny, orange, philly, pittsburgh, providence, francisco, somerset, virginia, westchester)
{  
  var teams = new Array();   
  
  document.form1.team.disabled = false;
  
  for (var i=document.form1.team.options.length-1; i>=0; i--)
  {
    document.form1.team.options[i] = null;
  }
  document.form1.team.selectedIndex = -1;  
  document.form1.team.options[document.form1.team.options.length]=new Option("- select -", "");
  document.form1.team.options[document.form1.team.options.length]=new Option("Free Agent / TBD", "0"); 
  
  if(document.form1.league.value == "arbor")
  {
    teams = arbor.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  if(i==0)	  
	    document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  else
	    document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "atlanta")
  {
    teams = atlanta.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  if(i==0)	  
	    document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  else
	    document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }  
  else if(document.form1.league.value == "bloomington")
  {
    teams = bloomington.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }  
  else if(document.form1.league.value == "boulder")
  {
    teams = boulder.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "boston")
  {
    teams = boston.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "buffalo")
  {
    teams = buffalo.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "chicago")
  {
    teams = chicago.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "columbus")
  {
    teams = columbus.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "orange")
  {
    teams = orange.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "fairfield")
  {
    teams = fairfield.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "francisco")
  {
    teams = francisco.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "somerset")
  {
    teams = somerset.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "li")
  {
    teams = li.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "madison")
  {
    teams = li.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "ny")
  {
    teams = ny.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "philly")
  {
    teams = philly.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "pittsburgh")
  {
    teams = pittsburgh.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
  else if(document.form1.league.value == "providence")
  {
    teams = providence.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }  
  else if(document.form1.league.value == "virginia")
  {
    teams = virginia.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }  
  else if(document.form1.league.value == "westchester")
  {
    teams = westchester.split("|");
    
	for(i = 0; i < teams.length-1; i++)
	{	
	  document.form1.team.options[document.form1.team.options.length]=new Option(teams[i+1], teams[i]);
	  i++;
	}
  }
}

//web validation --------------------

function IsValidEmail(strEmail)
{
  var IsValid;
  IsValid = true;

  var index;
  index = 0
	  
  if ( strEmail.length > 0 )
  {    	
	if ( strEmail.length < 5 )
    {
      IsValid = false;
    }
    else
    {	  
	  if ( strEmail.indexOf(" ") > 0 )
	  {	    
		IsValid = false;
	  }
      else
	  { 	    
		if ( strEmail.indexOf("@") < 0)
	    {
	      IsValid = false;		  
	    }
	    else
	    {
		  index = strEmail.indexOf("@");
		            
		  while (index != -1)
	      {    
            index = strEmail.indexOf("@", index + 1);			
		  
		    if (index != -1)
		    {
		      IsValid = false;			  			  
		    }
          }
		  if ( strEmail.lastIndexOf(".") < (strEmail.indexOf("@", 1) + 2) )
		  {
		    IsValid = false;
		  }
	    }
	  }
    }
  }
  else
  {
    IsValid = false;
  } 
  return IsValid  
}

function validateForumLogin()
{    
  if (document.forms[0].team.selectedIndex == 0)
  {
    alert("Please select your team");
	return false;
  } 
  else if (!IsValidEmail(document.form1.email.value))
  {
    alert("Please enter a valid email address");
	return false;
  }
  else
  {
    return true;
  }
}

function getTeam(l)
{
    box = document.forms[0].teams;
	destination = box.options[box.selectedIndex].value;
	location.href = "rosters.asp?league=" + l + "#" + destination;
	document.form1.teams.selectedIndex = 0;
}

function getCupTeam(l)
{
    box = document.forms[0].teams;
	destination = box.options[box.selectedIndex].value;
	
	if (l == "cup")	
	  location.href = "rosters.asp" + "#" + destination;
	else
	  location.href = "rosters.asp?league=" + l + "#" + destination;
	
	document.form1.teams.selectedIndex = 0;
}

function getStats(l)
{
    box = document.forms[0].teams;
	destination = box.options[box.selectedIndex].value;
	location.href = "stats.asp?league=" + l + "#" + destination;
	document.form1.teams.selectedIndex = 0;
}

function getSchedule(league)
{
    box = document.forms[0].teams;
	destination = box.options[box.selectedIndex].value;		
	
	if (destination == "")
	{
	  location.href = "schedule.asp?league=" + league;
	}
	else
	{
	  location.href = "schedule.asp?league=" + league + "&id=" + destination;
	}
}

function getCupSchedule(league)
{
    box = document.forms[0].teams;
	destination = box.options[box.selectedIndex].value;		
	
	if (destination == "")
	{
	  location.href = "schedule.asp?league=" + league;
	}
	else
	{
	  location.href = "schedule.asp?league=" + league + "&id=" + destination;
	}
}

function showStats(id)
{
  window.open('stats.asp?team=' + id + '', '1','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=500,screenX=0,screenY=0,top=0,left=0');
}

function validateIntern()
{
  if (document.frmSend.name.value.length < 1)
  {
    alert("Please enter your name");
	return false;
  } 
  else if (!IsValidEmail(document.frmSend.email.value))
  {
    alert("Please enter a valid email address");
	return false;
  }
  else if(document.frmSend.attach2.value == "" && document.frmSend.resume.value == "")
  {
    alert("Please attach or paste your resume");
	return false;
  }
  else if (document.frmSend.attach2.value.length > 0)
  {
    var dot = document.frmSend.attach2.value.indexOf(".")
    var ext = document.frmSend.attach2.value.substring(dot+1, document.frmSend.attach2.value.length)

    ext = ext.toLowerCase();	
	
	if (!(ext == "doc" || ext == "pdf" || ext == "txt"))
    {    
      alert("Please attach a resume of format .doc, .pdf or .txt");
	  return false;
    }
	else
	{
	  document.frmSend.Submit.disabled = true;
	  return true;
	}
  }
  else
  {
    document.frmSend.Submit.disabled = true;
	return true;
  }
}

function showCheque()
{
  window.open ('http://www.ulax.org/cheque.asp', '','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=525,height=275,screenX=0,screenY=0,top=0,left=0'); 
}

function showGallery(id, l)
{
  window.open ('gallery.asp' + '?league=' + l + '&game_id=' + id + '&page=1', '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=600,screenX=0,screenY=0,top=0,left=0'); 
}

function showVid(v)
{
  window.open ('http://www.ulax.org/show_video.asp' + '?vid=' + v, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=425,screenX=0,screenY=0,top=0,left=0'); 
}

function showCupGallery(l, id)
{
  window.open ('gallery.asp?league=' + l + '&game_id=' + id + '&page=1', '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=900,height=700,screenX=0,screenY=0,top=0,left=0'); 
}

//admin validation ------------------

  var dtCh= "/";
  var minYear=2000;
  var maxYear=2100;

  function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
  }

  function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
  }

  function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
  }
  function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
  }

  function isDate(dtStr)
  {
    var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
  return true
  }
  
function isNumber(str)
{
  var ValidChars = "0123456789.";
  var IsNumber = true;
  var Char;
  var radio_choice = false;    
  
  if (str.length == 0)
  {
    IsNumber = false;
	return IsNumber;
  }
  
  for (i = 0; i < str.length && IsNumber == true; i++) 
  { 
    
	Char = str.charAt(i); 
    if (ValidChars.indexOf(Char) == -1) 
    {
      IsNumber = false;
    }
  }
  
  return IsNumber;
}

function validateAddTeam()
{    
  if (document.form1.name.value.length < 1)
  {
    alert("A team name is required");
	return false;
  }
  else
  {
    return true;    	
  }
}

function validateAddGame()
{            
  if (isDate(document.form1.date.value) == false)
  {    
    return false;
  }
  else if (document.form1.hour.value == "" || document.form1.minute.value == "" || !isNumber(document.form1.hour.value) || !isNumber(document.form1.minute.value) || document.form1.hour.value > 12 || document.form1.minute.value > 59)
  {
    alert("A valiid time is required")
	return false;  
  }
  else if(document.getElementById("home_team").value == document.getElementById("away_team").value)
  { 
    alert("Home and Away teams match")
	return false;
  }  
  else
  {
    return true;
  }
}

function validateEditGame()
{                   
  if (isDate(document.form1.date.value) == false)
  {    
    return false;
  }
  else if (document.form1.hour.value == "" || document.form1.minute.value == "" || !isNumber(document.form1.hour.value) || !isNumber(document.form1.minute.value) || document.form1.hour.value > 12 || document.form1.minute.value > 59)
  {
    alert("A valiid time is required");
	return false;  
  }
  else if(document.getElementById("home_team").value == document.getElementById("away_team").value)
  { 
    alert("Home and Away teams match");
	return false;
  }
  else if( (document.form1.home_score.value != "" && !isNumber(document.form1.home_score.value)) || (document.form1.away_score.value != "" && !isNumber(document.form1.away_score.value)) )  
  {
    alert("Scores must be numeric");
    return false;
  }
  else
  {
    return true;
  }
}

function validateAddPlayer()
{          
  if (document.form1.f_name.value.length < 1)
  {
    alert("First name is required")
	return false;
  }
  else if (document.form1.l_name.value.length < 1)
  {
    alert("Last name is required")
	return false;
  }
  else if (document.form1.email.value.length < 1)
  {
    alert("Email is required")
	return false;
  }
  else if(!isNumber(document.form1.jersey.value))
  {
    alert("Jersey must be numeric")
	return false;
  }
  else if(!isNumber(document.form1.feet.value))
  {
    alert("Height (feet) must be numeric")
	return false;
  }
  else if(!isNumber(document.form1.inches.value))
  {
    alert("Height (inches) must be numeric and less than 12")
	return false;
  }
  else if(!isNumber(document.form1.weight.value))
  {
    alert("Weight must be numeric")
	return false;
  }
  else if(!isNumber(document.form1.age.value))
  {
    alert("Age must be numeric")
	return false;
  }
  else
  {
    return true;
  }
}

function validateEditStats()
{    
  if (!isNumber(document.form1.gp.value))
  {
    alert("GP must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.g.value))
  {
    alert("G must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.a.value))
  {
    alert("A must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.ppg.value))
  {
    alert("PPG must be numeric and cannot be blank")
	return false;
  }  
  else if (!isNumber(document.form1.shg.value))
  {
    alert("SHG must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.lb.value))
  {
    alert("LB must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.pim.value))
  {
    alert("PIM must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.shots.value))
  {
    alert("Shots must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.sog.value))
  {
    alert("SOG must be numeric and cannot be blank")
	return false;
  }  
  else
  {
    return true;
  }
}

function validateEditGoalieStats()
{    
  if (!isNumber(document.form1.gp.value))
  {
    alert("GP must be numeric and cannot be blank")
	return false;
  }
  else if (document.form1.min.value.length < 1)
  {
    alert("MIN cannot be blank (use 0:00 for zero)")
	return false;
  }
  else if (!isNumber(document.form1.w.value))
  {
    alert("W must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.l.value))
  {
    alert("L must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.ga.value))
  {
    alert("GA must be numeric and cannot be blank")
	return false;
  }
  else if (!isNumber(document.form1.sv.value))
  {
    alert("SV must be numeric and cannot be blank")
	return false;
  }      
  else
  {
    return true;
  }
}

function validateMessage()
{
  if (!IsValidEmail(document.form1.from.value))
  {
    alert("Please enter a valid FROM address");
	return false;
  }
  else if (document.form1.subject.value.length < 1)
  {
    alert("Please enter a message subject");
	return false;
  }
  else if (document.form1.body.value.length < 1)
  {
    alert("Please enter a message body");
	return false;
  }
  else
  {
    return true;
  }
}

function validateLogin()
{
  var dot;
  var ext;
  
  if (document.form1.username.value.length < 1 || document.form1.password.value.length < 1)
  {
    alert("Username/password cannot be blank");
	return false;
  }
  else
  {
    return true;
  }
}

function validateItem()
{
  if (document.frmSend.name.value.length < 1)
  {
    alert("Please enter item name");
	return false;
  } 
  else if (document.frmSend.description.value.length < 1)
  {
    alert("Please enter a description");
	return false;
  }
  else if( isNaN(document.frmSend.price.value) || document.frmSend.price.value.length == 0 )
  {
    alert("Please enter a valid price");
	return false;
  }
  else if(document.frmSend.sale_price.value.length > 0 && isNaN(document.frmSend.sale_price.value))
  {
    alert("Please enter a valid sale price");
	return false;
  }  
  else
  {
    document.frmSend.Submit.disabled = true;
	return true;
  }
}

function hideForms()
{  
  blog.style.visibility = 'hidden';   
  
  var iframe = document.getElementById("blogFrame");
  iframe.src = "";
}

function showdeadcenterdiv(Xwidth,Yheight,divid) { 
// First, determine how much the visitor has scrolled 

var scrolledX, scrolledY; 
if( self.pageYoffset ) { 
scrolledX = self.pageXoffset; 
scrolledY = self.pageYoffset; 
} else if( document.documentElement && document.documentElement.scrollTop ) { 
scrolledX = document.documentElement.scrollLeft; 
scrolledY = document.documentElement.scrollTop; 
} else if( document.body ) { 
scrolledX = document.body.scrollLeft; 
scrolledY = document.body.scrollTop; 
} 

// Next, determine the coordinates of the center of browser's window 

var centerX, centerY; 
if( self.innerHeight ) { 
centerX = self.innerWidth; 
centerY = self.innerHeight; 
} else if( document.documentElement && document.documentElement.clientHeight ) { 
centerX = document.documentElement.clientWidth; 
centerY = document.documentElement.clientHeight; 
} else if( document.body ) { 
centerX = document.body.clientWidth; 
centerY = document.body.clientHeight; 
} 

  // Xwidth is the width of the div, Yheight is the height of the 
  // div passed as arguments to the function: 
var leftoffset = scrolledX + (centerX - Xwidth) / 2; 
var topoffset = scrolledY + (centerY - Yheight) / 2; 
  // The initial width and height of the div can be set in the 
  // style sheet with display:none; divid is passed as an argument to // the function 
var o=document.getElementById(divid); 
var r=o.style; 
r.position='absolute'; 
r.top = topoffset + 'px'; 
r.left = leftoffset + 'px'; 
r.display = "block"; 

//set width/height of iframe
var iframe = document.getElementById("blogFrame");
iframe.width = '850';
iframe.height = '400';

r.visibility = 'visible';
} 

function selectText()
{
  document.search.search.select();
}