// the target is the time you want the countdown to run to
var targetMonth = 12; // set number of month
var targetDay = 15;  // set day of month
var targetHour = 0;  // set hour 0 to 23
var targetMinutes = 0; // set minutes 0 to 59
var targetSeconds = 0; // set seconds 0 to 59
var h = 20;

// set showSeconds to false for hours and minutes only
var showSeconds = true; 

var cl = 0;


function nothing()
	{
	// dummy url
	}
	

function refreshClock() 
	{
   if(cl) 
   		{
      	clearTimeout(cl);
      	cl  = 0;
   		}
   		
   		var today = new Date();
   		var target = new Date();
   		target.setMonth(targetMonth-1);
   		target.setDate(targetDay);
   		target.setHours(targetHour);
   		target.setMinutes(targetMinutes);
   		target.setSeconds(targetSeconds);
   		
   		if(today.getTime() < target.getTime())
   			{
   			var difference = target.getTime() - today.getTime();
   			
   			var seconds = Math.floor(difference/1000);
   			
   			var minutes = Math.floor(seconds/60);
   			
   			var days = Math.floor(minutes/(60*24));
   			
   			var rhours = minutes - (days*60*24);
   			var hours = Math.floor(rhours/60);
   			
   			var rminutes = minutes - ((days*24*60) + (hours*60));
   			
   			var rseconds = seconds - ((days*(24*60*60)) + (hours*(60*60)) + (rminutes*60));

			var theDays = pad(days);
   			var theHours = pad(hours);
   			var theMins = pad(rminutes);
   			var theSecs = pad(rseconds);
			}
		else
			{
			var theDays = 0;
   			var theHours = 0;
   			var theMins = 0;
   			var theSecs = 0;
			}
   			
   		
   		
  		var theDays = pad(days);
   		var theHours = pad(hours);
   		var theMins = pad(rminutes);
   		var theSecs = pad(rseconds);
   		
   		var d1 = Math.floor(theDays/10);
   		var d2 = theDays-(d1*10);
   		var h1 = Math.floor(theHours/10);
		var h2 = theHours-(h1*10);
   		var m1 = Math.floor(theMins/10);
   		var m2 = theMins-(m1*10);
   		var s1 = Math.floor(theSecs/10);
   		var s2 = theSecs-(s1*10); 
   
   		cl = setTimeout("refreshClock()", 1000);
   
   
   		doDigit(1,d1);
   		doDigit(2,d2);
   		doDigit(3,h1);
   		doDigit(4,h2);
   		doDigit(5,m1);
   		doDigit(6,m2);
   		if (showSeconds)
   			{
   			doDigit(7,s1);
   			doDigit(8,s2);
   			}
   			
   		cl = setTimeout("refreshClock()", 1000);
   		}
   		

function doDigit(f,y)
	{
	if (document.getElementById)
			{
			v=0-h*y;
			var theDigit = document.getElementById("n"+f);
			theDigit.style.backgroundPosition="0 "+v+"px";
			}		
	}


function start() 
	{
   	refreshClock();
	}
	
	

function stop() 
	{
   	if(cl) {
      	clearTimeout(cl);
      	cl  = 0;
   		}
	}
	

function pad(n)
	{
	
	if(n < 10)
		{
		return "0"+ n;
		}
	else
		{
		return n;
		}
	}
	
