
/***************************************
* FONCTION * AJOUT DU SITE AUX FAVORIS *
***************************************/

function ART_fav(url,lbl) {
    if ( navigator.appName != 'Microsoft Internet Explorer' ){
        window.sidebar.addPanel(lbl,url,"");
    }else{
        window.external.AddFavorite(url,lbl);
    }
}

/*************************************************************
* FONCTION * CREE UN LIEN POUR UN ELEMENT A PARTIR D'UN HREF *
**************************************************************/

$(document).ready(function(){
    //lien menu de gauche
    $('.menu_onglet').click(function() { 
        $(this).find('a').each(function(){ window.location = this.href; });
    }); 
    $('.menu_promo').click(function() { 
        $(this).find('a').each(function(){ window.location = this.href; });
    });                
});
 

/***************************************************
* infobulle
****************************************************/
this.tooltip = function(){    
    /* CONFIG */        
        xOffset = 10;
        yOffset = 20;        
        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result        
    /* END CONFIG */        
    $(".tooltip").hover(function(e){                                              
        var reg=new RegExp("(-_-)","g");
        if(this.tar==undefined){
            this.tar = this.title.split('-_-');
            this.t = "<span>"+this.tar.shift()+"</span><br />"+this.tar.join('<br />');
        } 
        this.title = "";                                      
        tT_div = document.createElement("tooltip");
        tT_div.id = "tooltip";
        tT_div.className = 'tooltip_box'; 
        tT_div.style.position = "absolute";
        tT_div.style.zIndex = 1500;
        tT_div.innerHTML = this.t;
        tT_div.style.display = 'none'; 
        document.body.appendChild(tT_div);
        
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px") 
            .fadeIn("fast");        
    },
    function(){
        this.title = this.t;        
        $("#tooltip").remove();
    });    
    $(".tooltip").mousemove(function(e){
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });            
};

function ART_sec2time(val){
    var r = "";
    
    var mi = parseInt(val/60);
    var mf = val - mi*60;
    if(mf>=60) {mi++;mf--;}
    if(mf<10) mf = "0"+mf;
    
    var hi = parseInt(mi/60);
    var hf = mi - hi*60;
    if(hf>=60) {hi++;hf--;}
    if(hf<10) hf = "0"+hf;
    
    var ji = parseInt(hi/24);
    var jf = hi - ji*24;
    if(jf>=24) {ji++;jf--;}
    if(jf<10) jf = "0"+jf; 
    //alert(mf+" "+mi);
    
    var r = hf+"m"+mf+"s";
    var t = hf+"m"+mf+"s";
    if(jf!="00") t = jf+"h"+r;
    if(ji>0) t = ji+" jour(s) "+jf+"h"+r;
    
    return t;
}

var madatedep;
var madate;
var flashTempo;
var mes_temps;
function temps_flash(){
    mes_temps = $(".temps_flash_temps");
    for(n=0;n<mes_temps.length;n++){
        var tps = mes_temps[n];
        var val = parseInt(tps.innerHTML);
        tps.fin = tps.getAttribute('title');
        tps.removeAttribute('title');
        tps.val = val;
        tps.innerHTML = ART_sec2time(val);
        tps.style.visibility = 'visible';
    }
    madatedep = new Date();
    flash_tempo();
}

function flash_tempo(){
    madate = new Date();
    var mondelta = ((madate.getTime() - madatedep.getTime())/1000);
    var di = parseInt(mondelta);
    var df = 9-parseInt((mondelta-di)*10);
    //alert(mondelta);
    for(n=0;n<mes_temps.length;n++){
        var tps = mes_temps[n];
        var v = tps.val-di;
        if(v>0) tps.innerHTML = ART_sec2time(v)+df; else tps.innerHTML = tps.fin;
        
    }
    flashTempo = setTimeout('flash_tempo()',100);
}


// starting the script on page load
$(document).ready(function(){
    tooltip();
    temps_flash();    

    $("#table_menu td").hoverIntent({
        sensitivity: 3, 
        interval: 200, 
        over: makeTall, 
        timeout: 500, 
        out: makeShort
    });
}); // close document.ready

function makeTall(){ 
  ART_showMenu(Mid,Mbtn,Mtable_menu);
}
function makeShort(){}
