var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var old_dday=new String("000"), old_dhour = new String("00"), old_dmin = new String("00"), old_dsec = new String("00");

function countdown(){
	// la date de r�f�rence est compos�e de variable globale
	theyear=yr;themonth=m;theday=d;thehour=heure;themin=minutes;thesec=secondes
	// date du jour
	var today=new Date();
	//today = today.toGMTString();
	// ann�e en cours
	var todayy=today.getYear()
	if (todayy < 1000) todayy+=1900
		
	var todaym=today.getMonth()
	var todayd=today.getDate()
	var todayh=today.getHours()
	var todaymin=today.getMinutes()
	var todaysec=today.getSeconds()
	
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	futurestring=montharray[m-1]+" "+theday+", "+theyear+" "+thehour+":"+themin+":"+thesec
	
	//diff�rence entre les 2 dates en millisecondes
	offsetGMT = new Date().getTimezoneOffset(); // en minutes
	dd=Date.parse(futurestring)-(Date.parse(todaystring)+(offsetGMT+60)*60*1000);
	//alert(dd);
	dday	= Math.floor(dd/(60*60*1000*24)*1)
	dhour	= Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
	dmin	= Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
	dsec	= Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
	
	dday 	= (dday		< 10 ? '0' + dday 	: dday).toString();
	dhour 	= (dhour	< 10 ? '0' + dhour 	: dhour).toString();
	dmin 	= (dmin		< 10 ? '0' + dmin 	: dmin).toString();
	dsec 	= (dsec		< 10 ? '0' + dsec 	: dsec).toString();
	
	if(dd>0) {
		refresh_clock(dday,dhour,dmin,dsec);
	}
	else {
		refresh_clock('00','00','00','00');
	}
	
	old_dday  = dday;
	old_dhour = dhour;
	old_dmin  = dmin;
	old_dsec  = dsec;
}

function countdown2(){
	// la date de r�f�rence est compos�e de variable globale
	theyear=yr2;themonth=m2;theday=d2;thehour=heure2;themin=minutes2;thesec=secondes2
	// date du jour
	var today=new Date();
	//today = today.toGMTString();
	// ann�e en cours
	var todayy=today.getYear()
	if (todayy < 1000) todayy+=1900
		
	var todaym=today.getMonth()
	var todayd=today.getDate()
	var todayh=today.getHours()
	var todaymin=today.getMinutes()
	var todaysec=today.getSeconds()
	
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	futurestring=montharray[m-1]+" "+theday+", "+theyear+" "+thehour+":"+themin+":"+thesec
	
	//diff�rence entre les 2 dates en millisecondes
	offsetGMT = new Date().getTimezoneOffset(); // en minutes
	dd=Date.parse(futurestring)-(Date.parse(todaystring)+(offsetGMT+60)*60*1000);
	//alert(dd);
	dday	= Math.floor(dd/(60*60*1000*24)*1)
	dhour	= Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
	dmin	= Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
	dsec	= Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
	
	dday 	= (dday		< 10 ? '0' + dday 	: dday).toString();
	dhour 	= (dhour	< 10 ? '0' + dhour 	: dhour).toString();
	dmin 	= (dmin		< 10 ? '0' + dmin 	: dmin).toString();
	dsec 	= (dsec		< 10 ? '0' + dsec 	: dsec).toString();
	
	if(dd>0) {
		refresh_clock2(dday,dhour,dmin,dsec);
	}
	else {
		refresh_clock2('00','00','00','00');
	}
	
	old_dday  = dday;
	old_dhour = dhour;
	old_dmin  = dmin;
	old_dsec  = dsec;
}

function refresh_clock(d,h,m,s) {	
	var clock_div = document.getElementById('compte_a_rebours');
	var html = '<span class="compteur day">';
	
		for (var i = 0; i<d.length; i++) {
		html += '<span id="d' + i + '" class="compteur' + d.charAt(i) + ' chiffre textimage">' + d.charAt(i) + '</span>';	
		}
	
	html += '<span id="jour-' + (d>1?'plur':'sing') + '" class="unite textimage">&nbsp;days&nbsp;</span></span>\n';
	
	html += '<span class="compteur"><span id="h0" class="compteur' + h.charAt(0) + ' chiffre textimage">' + h.charAt(0) + '</span><span id="h1" class="compteur'  + h.charAt(1) +  ' chiffre textimage">' + h.charAt(1) + '</span><span id="heure-' + (h>1?'plur':'sing') + '" class="unite textimage">&nbsp;hours&nbsp;</span></span>\n';
	
	html += '<span id="m0" class="compteur"><span id="h1" class="compteur' + m.charAt(0) + ' chiffre textimage">' + m.charAt(0) + '</span><span id="m1" class="compteur'  + m.charAt(1) +  ' chiffre textimage">' + m.charAt(1) + '</span><span id="minute-' + (m>1?'plur':'sing') + '" class="unite textimage">&nbsp;minutes&nbsp;</span></span>\n';
	
	html += '<span id="s0" class="dernier"><span class="compteur' + s.charAt(0) + ' chiffre textimage">' + s.charAt(0) + '</span><span id="s1"  class="compteur'  + s.charAt(1) +  ' chiffre textimage">' + s.charAt(1) + '</span><span id="seconde-' + (s>1?'plur':'sing') + '" class="unite textimage">&nbsp;seconds&nbsp;</span></span>\n';
	
	clock_div.innerHTML = html;
	
	
		if (old_dday != d && old_dday.length == d.length) {
			for (var i=0; i<d.length; i++) {
				if (old_dday.charAt(i) != d.charAt(i) ) new Effect.Opacity('d'+i, {duration:0.5, from:0.5, to:1.0});
			}
		}
		if (old_dhour != h && old_dhour.length == h.length) {
			if (old_dhour.charAt(0) != h.charAt(0) ) new Effect.Opacity('h0', {duration:0.5, from:0.5, to:1.0});
			if (old_dhour.charAt(1) != h.charAt(1) ) new Effect.Opacity('h1', {duration:0.5, from:0.5, to:1.0});
		}
		if (old_dmin != m && old_dmin.length == m.length) {
			if (old_dmin.charAt(0) != m.charAt(0) ) new Effect.Opacity('m0', {duration:0.5, from:0.5, to:1.0});
			if (old_dmin.charAt(1) != m.charAt(1) ) new Effect.Opacity('m1', {duration:0.5, from:0.5, to:1.0});
		}
		if (old_dsec != s && old_dsec.length == s.length) {
			if (old_dsec.charAt(0) != s.charAt(0) ) new Effect.Opacity('s0', {duration:0.5, from:0.5, to:1.0});
			if (old_dsec.charAt(1) != s.charAt(1) ) new Effect.Opacity('s1', {duration:0.5, from:0.5, to:1.0});
		}
}
function refresh_clock2(d,h,m,s) {	
	var clock_div = document.getElementById('compte_a_rebours2');
	var html = '<span class="compteur day">';
	
		for (var i = 0; i<d.length; i++) {
		html += '<span id="d' + i + '" class="compteur' + d.charAt(i) + ' chiffre textimage">' + d.charAt(i) + '</span>';	
		}
	
	html += '<span id="jour-' + (d>1?'plur':'sing') + '" class="unite textimage">&nbsp;days&nbsp;</span></span>\n';
	
	html += '<span class="compteur"><span id="h0" class="compteur' + h.charAt(0) + ' chiffre textimage">' + h.charAt(0) + '</span><span id="h1" class="compteur'  + h.charAt(1) +  ' chiffre textimage">' + h.charAt(1) + '</span><span id="heure-' + (h>1?'plur':'sing') + '" class="unite textimage">&nbsp;hours&nbsp;</span></span>\n';
	
	html += '<span id="m0" class="compteur"><span id="h1" class="compteur' + m.charAt(0) + ' chiffre textimage">' + m.charAt(0) + '</span><span id="m1" class="compteur'  + m.charAt(1) +  ' chiffre textimage">' + m.charAt(1) + '</span><span id="minute-' + (m>1?'plur':'sing') + '" class="unite textimage">&nbsp;minutes&nbsp;</span></span>\n';
	
	html += '<span id="s0" class="dernier"><span class="compteur' + s.charAt(0) + ' chiffre textimage">' + s.charAt(0) + '</span><span id="s1"  class="compteur'  + s.charAt(1) +  ' chiffre textimage">' + s.charAt(1) + '</span><span id="seconde-' + (s>1?'plur':'sing') + '" class="unite textimage">&nbsp;seconds&nbsp;</span></span>\n';
	
	clock_div.innerHTML = html;
	
	
		if (old_dday != d && old_dday.length == d.length) {
			for (var i=0; i<d.length; i++) {
				if (old_dday.charAt(i) != d.charAt(i) ) new Effect.Opacity('d'+i, {duration:0.5, from:0.5, to:1.0});
			}
		}
		if (old_dhour != h && old_dhour.length == h.length) {
			if (old_dhour.charAt(0) != h.charAt(0) ) new Effect.Opacity('h0', {duration:0.5, from:0.5, to:1.0});
			if (old_dhour.charAt(1) != h.charAt(1) ) new Effect.Opacity('h1', {duration:0.5, from:0.5, to:1.0});
		}
		if (old_dmin != m && old_dmin.length == m.length) {
			if (old_dmin.charAt(0) != m.charAt(0) ) new Effect.Opacity('m0', {duration:0.5, from:0.5, to:1.0});
			if (old_dmin.charAt(1) != m.charAt(1) ) new Effect.Opacity('m1', {duration:0.5, from:0.5, to:1.0});
		}
		if (old_dsec != s && old_dsec.length == s.length) {
			if (old_dsec.charAt(0) != s.charAt(0) ) new Effect.Opacity('s0', {duration:0.5, from:0.5, to:1.0});
			if (old_dsec.charAt(1) != s.charAt(1) ) new Effect.Opacity('s1', {duration:0.5, from:0.5, to:1.0});
		}
}