function StartClock() 
{
	if (!document.getElementById) return;
		
	if(this.flashWidgetA != null) 
	{
		if(this.thresh > 0) 
		{
			//setTimeout('DecrementClock('+this.id+')', 1000);
			setTimeout('FlashColon('+this.id+')', '500');
		}
		else 
		{
			this.dayWidget.innerHTML = "00";
			this.hourWidget.innerHTML = "00";
			this.minWidget.innerHTML = "00";
			this.secWidget.innerHTML = "00";
		}
	}
}


function FlashColon(id) 
{	

	// Toggle visibility of each colon every half second
	f = tickerObjects[id].flashWidgetA;
	if(f.style.visibility == "hidden") f.style.visibility = "visible"
	else f.style.visibility = "hidden";

	f = tickerObjects[id].flashWidgetB;
	if(f.style.visibility == "hidden") f.style.visibility = "visible"
	else f.style.visibility = "hidden";

	f = tickerObjects[id].flashWidgetC;
	if(f.style.visibility == "hidden") f.style.visibility = "visible"
	else f.style.visibility = "hidden";

	// Decrement clock on when making colon visible
	if (f.style.visibility == "visible")
		DecrementClock(id);

	// Set time to next blink (0.5 secs, minus a bit for CPU time)
	setTimeout('FlashColon('+id+')',497);
}

function DecrementClock(id) 
{
	callee = tickerObjects[id];

	var stdOut;
	
	// If we still have time to go, decrement by 1 second
	if ((callee.sLeft > 0)
		|| (callee.mLeft > 0)
		|| (callee.hLeft > 0)
		|| (callee.dLeft > 0))
	{
		callee.sLeft -= 1;
	
		// Cycle mins
		if (callee.sLeft == -1) 
		{
			callee.sLeft = 59;
			callee.mLeft -= 1;
		}
		// Cycle hours
		if (callee.mLeft == -1) 
		{
			callee.mLeft = 59;
			callee.hLeft -= 1;
		}
		// Cycle days
		if (callee.hLeft == -1) 
		{
			callee.hLeft = 23;
			callee.dLeft -= 1;
		}
	}

	//Format display string
	stdOut = callee.dLeft;
	callee.dayWidget.innerHTML = stdOut;
	
	stdOut = callee.hLeft;
	if (callee.hLeft < 10) stdOut = '0' + stdOut;
	callee.hourWidget.innerHTML = stdOut;
	
	stdOut = callee.mLeft;
	if (callee.mLeft < 10) stdOut = '0' + stdOut;
	callee.minWidget.innerHTML = stdOut;
		
	stdOut = callee.sLeft;
	if (callee.sLeft < 10) stdOut = '0' + stdOut;
	callee.secWidget.innerHTML = stdOut;
	
	//setTimeout('DecrementClock('+id+')', 995);

}
	
function TickerObject(id, dLeft, hLeft, mLeft, sLeft, thresh)
{
	this.id = id;
	this.dLeft = dLeft;
	this.hLeft = hLeft;
	this.mLeft = mLeft % 60;
	this.sLeft = sLeft % 60;
	this.thresh = thresh;
	this.StartClock = StartClock;
	
	this.dayWidget = document.getElementById('stDay'+id);
	this.hourWidget = document.getElementById('stHour'+id);
	this.minWidget = document.getElementById('stMin'+id);	
	this.secWidget = document.getElementById('stSec'+id);	
	this.flashWidgetA = document.getElementById('stColonA'+id);
	this.flashWidgetB = document.getElementById('stColonB'+id);
	this.flashWidgetC = document.getElementById('stColonC'+id);
	
	//You may fire when ready
	this.StartClock();
}

var tickerObjects = new Array();