﻿

    function displayFakePasswordValue () {
        var el = document.getElementById("fakePasswordValue");        
        var elInput = document.getElementById("leftSection").getElementsByTagName("input")[1];
        
        el.style.display = "block";
        
        el.onclick = function () {
            el.style.display = "none";
            elInput.focus();
        }
        elInput.onfocus = function () {
            el.style.display = "none";
        }
        elInput.onblur = function () {
            if (elInput.value == "") {
                el.style.display = "block";
            }
        }    
    }
    function makeBookMark()
    {
        if (window.sidebar) // Firefox
        {
            window.sidebar.addPanel(document.title, document.URL,"");
        } 
        else if(window.opera && window.print) // Opera
        {
        } 
        else if(document.all) // IE
        {
            window.external.AddFavorite(document.URL, document.title);
        }
        
    }
    
    function AddEventOnLoad(newFunction)
    {
        var oldOnLoad = window.onload;
        
        if (typeof(oldOnLoad) != 'function')
        {
            window.onload = newFunction;
        }
        else
        {
            window.onload =  function()
            {
                oldOnLoad();
                newFunction();
            }
        }
   }
    
    
    AddEventOnLoad(function () 
    {
        if (document.getElementById("fakePasswordValue")) 
        {
            displayFakePasswordValue ();
        }
            //on fait une requète Jquery pour récupérer tous les elements DOM dont
            //l'id commence par "overflow"
            $('div[id^=overflow]').jScrollPane({showArrows:true, scrollbarWidth:8});
            //$('#overflow').jScrollPane({showArrows:true, scrollbarWidth:8});
            //$('#overflow_histoires').jScrollPane({showArrows:true, scrollbarWidth:8});
            
    });

    function _getChanson(name) 
    {
        document[name].transfertAmi();
    }
    
    
    function displayReglement (dis) 
    {
        var el = document.getElementById('popUp-reglement');
        el.style.display = dis;
    }
    
	function displayReglementParrain(dis)
	{
        var el = document.getElementById('popUp-reglement-parrainage');
        el.style.display = dis;
    }
    
    function EcrireCookie(nom, valeur)
    {
        var argv=EcrireCookie.arguments;
        var argc=EcrireCookie.arguments.length;
        var expires=(argc > 2) ? argv[2] : null;
        var path=(argc > 3) ? argv[3] : null;
        var domain=(argc > 4) ? argv[4] : null;
        var secure=(argc > 5) ? argv[5] : false;
        document.cookie=nom+"="+escape(valeur)+
        ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
        ((path==null) ? "" : ("; path="+path))+
        ((domain==null) ? "" : ("; domain="+domain))+
        ((secure==true) ? "; secure" : "");
    }
    
    function getCookieVal(offset)
    {
        var endstr=document.cookie.indexOf (";", offset);
        if (endstr==-1) endstr=document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
    }
    
    function LireCookie(nom) { // fonction pour lire le Cookie
        var arg=nom+"=";       // renvoie null si inexistant
        var alen=arg.length;
        var clen=document.cookie.length;
        var i=0;
        while (i<clen)
        {
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;

        }
        return null;
    }
    
    function afficherPopup () {
        document.getElementById('test').style.display = 'block';
    }
    
    function hidePopup () {
        document.getElementById('test').style.display = 'none';
    }
    
    var javascriptToCookie = function  () {
             // fonction pour creer le cookie lorsque l'on arrive sur le site
        thecookie = LireCookie('heureconnexion');
        if(thecookie == null) {              // si le cookie n'existe pas, on le cree
            var heure = new Date;
            time = Date.parse(heure) + 25000; // (temps en milisecondes ecoulées depuis le 1/1/1970) + 25000 ms
            EcrireCookie('heureconnexion',time);
        }
    }
    
    var recupeFromCookie = function  () {
        time = LireCookie('heureconnexion'); // temps arrivé sur le site + 25000 ms
        var timeAct = new Date;              // temps actuel au chargement de la page
        timeAct = Date.parse(timeAct);       // temps actuel transformé en milisecondes
        if(time >= timeAct) {                // si le temps dans le cookie et plus grand que le temps actuel
            dif = time - timeAct;            // difference en milisecondes
            setTimeout('afficherPopup()',dif); // afficher la popup apres que la diference soit écouler
        }
    }
    

AddEventOnLoad(javascriptToCookie); 
AddEventOnLoad(recupeFromCookie);
    