// Counterscript
// Idee von Christoph R�bel
// (c) Johannes P. ;31.01.2002 ; masterjojo@web.de

var nTime;
var nTarget = Date.UTC(2011, 8, 25, 13, 0, 0, 0); 

// Parameter: Jahr,Monat(Nullbased), Tag, Stunde(Nullbased), ...
// Nullbased hei�t, dass bei 0 angefangen wird zu Z�hlen (0: Januar, 1 Februar usw.)
// 21.03.2002 um 12:05 entspricht dann (2002, 6, 3, 9, 5, 0, 0)


if (document.all)
{
	Tick()
	window.setInterval('Tick()', 1000);
}
else
	window.setTimeout('Tick()', 1000);

function Tick()
{
	var dNow = new Date();
	nTime = nTarget - dNow.valueOf();
	if (nTime < 0) nTime = 0;
	nTime = Math.floor(nTime / 1000);

	Display(document.cdDay2, document.cdDay1, document.cdDay0, 86400);
	Display(null, document.cdHour1, document.cdHour0, 3600);
	Display(null, document.cdMinute1, document.cdMinute0, 60);
	Display(null, document.cdSecond1, document.cdSecond0, 1);
	if (!document.all)
		window.setTimeout('Tick()', 100)
}
	
function Display(el2, el1, el0, nDivisor)
{
	var nValue = (nTime - (nTime %= nDivisor)) / nDivisor
        mypath = "/counter/imgs/";
	el0.src = mypath + "" + (nValue % 10) + ".jpg"
	nValue = Math.floor(nValue / 10)
	el1.src = mypath + "" + (nValue % 10) + ".jpg"
	if (el2)
	{
		nValue = Math.floor(nValue / 10)
		el2.src = mypath + "" + (nValue % 10) + ".jpg"
	}
}
