﻿function compte_a_rebour(){
    var CompteARebours = document.getElementById("CompteARebours");
    var date_actuelle = new Date();
    var date_evenement = new Date("oct 13 09:00:00 2011");

    var secondes = (date_evenement - date_actuelle) / 1000;
    if(secondes > 0){
        DiffJour = Math.floor (secondes / 86400);
        DiffHeure = Math.floor ((secondes - (DiffJour * 86400)) / 3600);
        DiffMin = Math.floor ((secondes - ((DiffJour * 86400 + DiffHeure * 3600))) / 60);
        DiffSec = Math.floor (secondes - ((DiffJour * 86400 + DiffHeure * 3600 + DiffMin * 60)));
        if(DiffJour == 0){
            Jour = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
        } else {
			if (( DiffJour == 1 ) || ( DiffJour == 2 ) || ( DiffJour == 3 ) || ( DiffJour == 4 ) || ( DiffJour == 5 ) || ( DiffJour == 6 ) || ( DiffJour == 7 ) || ( DiffJour == 8 ) || ( DiffJour == 9 )) 
			{
				Jour = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+DiffJour+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
			}
			else
			{
				Jour= "A"+DiffJour+"B";
				var sjour=Jour.split('');
				Jour = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+sjour[1]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+sjour[2]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";

			}
		
        }
        if(DiffHeure == 0){
			Heure = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
        } else {
			if (( DiffHeure == 1 ) || ( DiffHeure == 2 ) || ( DiffHeure == 3 ) || ( DiffHeure == 4 ) || ( DiffHeure == 5 ) || ( DiffHeure == 6 ) || ( DiffHeure == 7 ) || ( DiffHeure == 8 ) || ( DiffHeure == 9 )) 
			{
				Heure = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;' /><img src='images/"+DiffHeure+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
			}
			else
			{
				Heure= "A"+DiffHeure+"B";
				var sheure=Heure.split('');
				Heure = "<img src='images/"+sheure[1]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+sheure[2]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
			}			
        }
        if(DiffMin == 0){
            Minute = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
        } else {
			if (( DiffMin == 1 ) || ( DiffMin == 2 ) || ( DiffMin == 3 ) || ( DiffMin == 4 ) || ( DiffMin == 5 ) || ( DiffMin == 6 ) || ( DiffMin == 7 ) || ( DiffMin == 8 ) || ( DiffMin == 9 )) 
			{
				Minute = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+DiffMin+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
			}
			else
			{
            	Minute= "A"+DiffMin+"B";
				var sMinute=Minute.split('');
				Minute = "<img src='images/"+sMinute[1]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+sMinute[2]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";

			}
			
        }
        if(DiffSec == 0){
            Seconde = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
        } else {
			if (( DiffSec == 1 ) || ( DiffSec == 2 ) || ( DiffSec == 3 ) || ( DiffSec == 4 ) || ( DiffSec == 5 ) || ( DiffSec == 6 ) || ( DiffSec == 7 ) || ( DiffSec == 8 ) || ( DiffSec == 9 )) 
			{
				Seconde = "<img src='images/0.png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+DiffSec+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";
			}
			else
			{
			    Seconde= "A"+DiffSec+"B";
				var sSeconde=Seconde.split('');
				Seconde = "<img src='images/"+sSeconde[1]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/><img src='images/"+sSeconde[2]+".png' alt='0' width='16' height='24' border='0' style='margin:0 0 0 2px;'/>";

			
			}
        }
        CompteARebours.innerHTML = '<table align="right" cellpadding="0" cellspacing="0" style="text-align:right;" ><tr><td>'+ Jour + '</td><td>&nbsp;&nbsp;&nbsp;&nbsp;' + Heure +'</td><td>&nbsp;&nbsp;'+ Minute +'</td></tr><tr><td style="margin:-20px;">Jours</td><td>Heures</td><td>Minutes</td></tr></table>'
    } else {
        CompteARebours.innerHTML = 'Terminé';
    }
    Time_ReLance = setTimeout("compte_a_rebour();", 1000);
}
