function animateFade(lastTick, eid)
{  
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
  
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}

var TimeToFade = 500.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}


var CurDisplay = 1;
var StandingsCount = 0;
var CurElement = "std_1";

function showDate()
{	var tod = new Date();
	var WeekDay = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
	var Months  = new Array("Jan","Feb","Mar","Apr","May","Jun","July","Aug","Sep","Oct","Nov","Dec")
	var Hours   = tod.getHours();
	var Minutes = tod.getMinutes();
	var Seconds = tod.getSeconds();
	var AMPM = " AM"
	if (Hours > 12) 
	{ Hours = Hours - 12;
	  AMPM = " PM"
	}

	if (Hours < 10)
	{ Hours = '0' + Hours;
	}
	if (Minutes < 10)
	{ Minutes = '0' + Minutes;
	}	
	if (Seconds < 10)
	{ Seconds = '0' + Seconds;
	}		
	todnow = WeekDay [tod.getDay()] + ' ' + Months [tod.getMonth()] + ' ' + tod.getDate() + ', ' + tod.getFullYear()
	todnow = todnow + '-' + Hours + ':' + Minutes + ':' + Seconds;
	todnow = todnow + ' ' + AMPM;
	document.getElementById("txtDate").innerHTML = todnow;
}
function rotateDivs()
{
//	fadeOut(CurElement)
	fade (CurElement);
	document.getElementById(CurElement).style.display = "none";
	CurDisplay = CurDisplay + 1
	if (CurDisplay > StandingsCount)
	{ CurDisplay = 1;
	}
	CurElement = "std_" + CurDisplay;
	fade (CurElement);
	document.getElementById(CurElement).style.display = "";
//	fadeIn(CurElement)
}

//function Fader(el, fadeIn)
//{
//	var me = this;
//	var fitc = 0;
//	var fotc = 0;
//	this.el = (typeof(el) == "object")?el:(typeof(el) == "string")?document.getElementById(el):null;
//	
//	this.fadeIn = fadeIn;
//	this.doFade = doFade;
//	
//	this.setOpacity = setOpacity;
//	this.showElement = showElement;
//	
//	this.opacity = 0;
//	
//	this.doFade();
//	
//	function setOpacity()
//	{ if (typeof(this.el.style.opacity) != null) this.el.style.opacity = this.opacity / 100;
//	  if (typeof(this.el.style.filter) != null) this.el.style.filter = "alpha(opacity=" + this.opacity + ")";
//	  this.opacity += (this.fadeIn)?1:-1;
//	}
//	
//	function showElement(show)
//	{
//	  if (this.el && this.el.style) this.el.style.display = (show)?"block":(this.fadeIn)?"block":"none";
//	}
//	
//	function doFade()
//	{ this.showElement(true);
//	  if (this.fadeIn)
//	  { this.opacity = 0;
//		this.setOpacity();
//		
//		for (var i=0; i<=100; i++)
//		{ var newFunc = function() 
//			{ 	me.setOpacity(); 
//				document.getElementById("fit").innerHTML = ++fitc;
//			};
//		  setTimeout(newFunc, 2*i);
//		}
//		var newFunc = function () { me.showElement(); };
//		setTimeout(newFunc, 210);				
//	  }
//	  else
//	  { this.opacity = 100;
//		this.setOpacity();
//		
//		for (var i=0; i<=100; i++)
//		{ var newFunc = function() 
//			{ me.setOpacity(); 
//			  document.getElementById("fot").innerHTML = ++fotc;
//			};
//		  setTimeout(newFunc, 1*i);
//		}
//		var newFunc = function () { me.showElement(); };
//		setTimeout(newFunc, 120);		
//	  }
//	}
//}
//
//function fade(obj, fadeIn)
//{
//  if (obj) new Fader(obj, fadeIn);
//}
//
//function fadeIn(objID)
//{
//  fade(objID, true);
//}
//
//function fadeOut(objID)
//{
//  fade(objID, false);
//}
