function FormatTime(time){
	seconds = time % 60;
	time = (time-seconds) / 60;
	
	minutes = time % 60;
	time = (time-minutes) / 60;
	
	hours = time % 24;
	time = (time-hours) / 24;
	
	str = '';
	if(time != 0){ str = str + time + 'j '; }
	if(hours != 0){ str = str + FormatTimeZero(hours) + 'h '; }
	if(minutes != 0){ str = str + FormatTimeZero(minutes) + 'm '; }
	if(seconds != 0) { str = str + FormatTimeZero(seconds) + 's '; }
	
	return str;
}
function FormatTimeZero(time) {
	var str = '';
	if(time < 10) {
		str = '0' + time;
	}
	else {
		str = time;
	}
	return str;
}

function AutoCountDown() {
	var n = new Date();
	n.setTime(n.getTime() + dateOffset);
	
	$(".CountDown").each(function() {

		var time = (Math.round($(this).attr("name")*1000) - (n.getTime()) );

		if( time <= 0 ) {
			var str = 'Compl&egrave;t&eacute;';
		}
		else {
			var str = FormatTime(Math.round(time/1000));
		}
		$(this).html(str);
	});
	setTimeout('AutoCountDown();', 450);
}
$(document).ready(function() {
	AutoCountDown();
});

