document.addEvent('domready', init);


function init() {
	//el = new Element('span', {'id':'restant'});
	//el.inject($('decompte'));
	updateTime();
	updateTime.periodical(1000);
}

function updateTime() {
	$('restant').set('html', getRestant());
}

function getRestant() {
	
	now = new Date();
	
	echeance = new Date(2010, 2, 14, 19, 30, 0);
	
	tempsRestant = echeance.getTime() - now.getTime();
	tempsRestant = Math.floor(tempsRestant/1000);
	
	heures = Math.floor(tempsRestant/3600);
	tempsRestant -= heures*3600;
	
	minutes = Math.floor(tempsRestant/60);
	tempsRestant -= minutes*60;
	
	secondes = tempsRestant;
	
	return heures+':'+complete(minutes)+':'+complete(secondes);
}

function complete(res) {
	res = res.toString();
	vide= "00";
	return vide.substring(0, vide.length - res.length) + res;
}