function refreshDateTime() {
	now = new Date() ;
	document.getElementById( 'date-time' ).innerHTML = now.toLocaleString() ;
}

function numericalFormat(secs)
{
 if (secs < 10)
 {
  return '0' + secs;
 }

 return secs;

}

function between(num,min,max)
{
 if (min > num || max < num) {
    return false;
 }

 return true;
}


function refreshCountdown() 
{
	var secondsPerMinute = 60 ;
	var secondsPerHour = secondsPerMinute * 60 ;
	var secondsPerDay = secondsPerHour * 24 ;

	var secondsToGo = 0 ;
	var targetType = '' ;
	var todaysDate = new Date().getTime();
	var targetDate = new Date( 2010, 0, 1, 0, 0, 0).getTime();

	//alert(targetDate);
	//alert(todaysDate);


	secondsToGo = Math.floor((targetDate - todaysDate) / 1000);

  if (secondsToGo >= 0)
  {
	 
	
	var daysToGo = Math.floor( secondsToGo / secondsPerDay ) ;
	secondsToGo = secondsToGo - ( daysToGo * secondsPerDay ) ;
	var hoursToGo = Math.floor( secondsToGo / secondsPerHour ) ;
	secondsToGo = secondsToGo - ( hoursToGo * secondsPerHour ) ;
	var minutesToGo = Math.floor( secondsToGo / secondsPerMinute ) ;
	secondsToGo = secondsToGo - ( minutesToGo * secondsPerMinute ) ;

	outputString  = '<span style="color:white;">';


	outputString += numericalFormat(daysToGo) + "&nbsp;&nbsp;";
	outputString += numericalFormat(hoursToGo)  + '&nbsp;&nbsp;';
	outputString += numericalFormat(minutesToGo) + '';
	outputString += "</span>";
	outputString += '<span style="color:#C4FA98;">&nbsp;&nbsp;<span style="font-size:12px">&nbsp;</span>';
	outputString += numericalFormat(secondsToGo);
 	outputString += "</span>";

	document.getElementById( 'countdown' ).style.display = 'block';
	document.getElementById( 'countdown' ).innerHTML = outputString ;

	document.getElementById( 'normalmode' ).style.display = 'none';
        document.getElementById('newyear').style.display = 'none';


	setTimeout("refreshCountdown()",1000);
  }
  else
  {


     // IF TARGET DAY WE NEED TO SHOW FLASH ANIMATION
     if (between(secondsToGo,-86400,0))
     {

	document.getElementById('countdown').style.display = 'none';
	document.getElementById('normalmode').style.display = 'none';
        document.getElementById('newyear').style.display = 'block';
	setTimeout("refreshCountdown()",1000);
     }
     else
     {
	document.getElementById('countdown').style.display = 'none';
	document.getElementById('normalmode').style.display = 'block';
        document.getElementById('newyear').style.display = 'none';
     }
  }
}
