<!--dev_progress.js-->

var chrono=null;
var temps=0;
var incremProgress = 10;
var progressWith=0;
var delta;
var temps_total;
var agit;



function heure()
{
    var Hn = new Date(); 
    heure_n=Hn.getTime();
    incremProgress=(5*delta);
    //temps_ecoule=temps absoul écoulé deuis le début
    temps_ecoule=Math.floor((heure_n-heure_0)/10); //en centiÃ¨mes de sec.

    //temps=temps total restant
    temps=(temps_total-temps_ecoule); //en centiÃ¨mes de sec.

    //temps restant avant la prochaine agitation
    temps_agit=(temps_repos-(temps_ecoule%temps_repos)); //en centiÃ¨mes de sec.
 
    if(temps<=0)
    {
        document.getElementById("Progress").style.width = 500 + "px";
        document.getElementById("Pourcent").innerHTML = "- 100 % -";
        texte="00:00:00";
        texte2="00:00:00";
        clearInterval(chrono);
        document.getElementById("notification").innerHTML = "TerminÃ©";
        document.getElementById("notification").style.color="#990000";
        document.getElementById("notification").style.backgroundColor="silver";
        
       
    }
    
    else
    {
        avancement=Math.floor(100*(1-(temps/temps_total)));
        progressWith = avancement*5;   
        document.getElementById("Progress").style.width = progressWith + "px";
        document.getElementById("Pourcent").innerHTML = avancement +" %";
                
        if(temps<=1500) 
        {
            document.formu.cadran.style.color = "red";  
        }
        
        texte2=formate_temps_js(temps_agit); 
        texte=formate_temps_js(temps);
   
    
        if((temps_repos-temps_agit)<duree_agitation)
        {
            document.getElementById("notification").innerHTML = "Agitation !";
            document.formu.cadran2.style.color = "red";  
                
            if(navigateur!=0){
                    document.getElementById("notification").style.color="silver";
                    document.getElementById("notification").style.backgroundColor="#990000";
            }
        }
        
        else
        {
           document.getElementById("notification").innerHTML = "en cours... (appuyez sur [STOP] pour arrÃªter)";
           if(navigateur!=0){
                document.getElementById("notification").style.color="#990000";
                document.getElementById("notification").style.backgroundColor="silver";
                document.formu.cadran2.style.color = "white"; 
                            }
        }
    } 
document.formu.cadran.value=texte; 
document.formu.cadran2.value=texte2;  
}



    

function commence(minutes,agitation) {
var H0 = new Date(); 
heure_0=H0.getTime();

delta=100; //en milliÃ¨mes de sec.
temps_total=minutes*60*100; //en centiÃ¨mes de sec.
temps_repos=agitation*60*100;
 temps=minutes*60*100; //temps est en centiÃ¨mes de secondes
//agit=fréquence d'agitation en centièmes de secondes
agit=agitation*60*100;
duree_agitation=agitation*1000;
 heure();
 document.formu.bouton.value="STOP";
 chrono=setInterval("heure()",delta); 
} 

function stoppe() {
 if (chrono!=null) clearInterval(chrono);
 chrono=null;
 progressWith =0;
 document.formu.bouton.value="DEPART";
 document.getElementById("notification").innerHTML = "ArrÃªtÃ©";
document.getElementById("notification").style.color="#990000";
  document.getElementById("notification").style.backgroundColor="silver";
}  

function clique(minutes,agitation) {
navigateur=navigator.appName; if(navigateur=="Microsoft Internet Explorer"){
navigateur=0;}
 if (chrono==null) commence(minutes,agitation); else stoppe();



} 

function formate_temps_js(temps){
base=Math.floor(temps);
 cs=base % 100;
 base=(temps-cs) / 100;
 s=base % 60;
 m=(base-s) / 60; 
 texte=""; 
 
 if (m<10) texte=texte+"0"; 
 texte=texte+m+":"; 
 if (s<10) texte=texte+"0"; 
 texte=texte+s+":";
 if (cs<10) texte=texte+"0"; 
 chaine=texte+cs;
return chaine;}


