function i18n(text)
{
	return text;
}
function FormatDigit(digit)
{
	if(digit.length == 0)
	{
		return "00";
	}
	if(digit.length == 1)
	{
		return "0" + digit;
	}
	
	return digit;
}
function GetTimeStr()
{
   var dt=new Date()
   var h = dt.getHours().toString();
   var m = dt.getMinutes().toString();
   var s = dt.getSeconds().toString();
   
   return FormatDigit(h) + ":" + FormatDigit(m) + ":" + FormatDigit(s);
}

function ClockInTitle()
{
   document.title = i18n("Happy New Year: ") + GetTimeStr();
   setTimeout("ClockInTitle()",1000);
}
ClockInTitle();

function Pause(time)
{
   var d=new Date();
   while(1)
   {
	 var n = new Date();
	 var diff = n-d;
	 if (diff > time)
		break;
	}
}

/*Get controls*/
var new_year_text = document.getElementById("new_year_text");
var new_year_count = document.getElementById("new_year_count");
var next_year_val;
var next_year;
var coef=1000;
function calcNextYear()
{
	next_year_val = new Date().getFullYear() + 1;
	next_year = new Date("01/01/" + next_year_val + " 00:00:00");
}

function CountDown()
{
	/*Init years*/
	var now = new Date();
	var countdown = Math.round((next_year.getTime() - now.getTime()) / coef);
	if(countdown < 1 )
	{
		new_year_count.innerHTML =  "BONNE ANNE !! YOUPI";
		if(countdown > -60)
		{
			calcNextYear();
		}
	}
	else
	{
		new_year_count.innerHTML =  countdown + " s";
	}
	setTimeout("CountDown()",250);
}

calcNextYear();
CountDown();