
//////////////////////////////////////////////////
// Diaporama fond de page
//////////////////////////////////////////////////

// Initialisation des donn�es
var diapoContainer	= "photo_fond";
var diapoFolder		= "images/";
var diapoCount		= 10;
var diapoDelay		= 2000;
var diapoFade		= 1000;
var diapoId		= 1;
var diapoPreloads	= new Array();

// Ajout d'un �couteur d'�v�nement body.onload
if(window.addEventListener)
    window.addEventListener("load", diapoStart, false);
else if(document.addEventListener)
    document.addEventListener("load", diapoStart, false);
else if(window.attachEvent)
    window.attachEvent("onload", diapoStart);


//////////////////////////////////////////////////
// Fonctions
//////////////////////////////////////////////////

function diapoStart() {
	
    // Initialisation des objets
    diapoFade /= 1000;
    diapoContainer = document.getElementById("photo_fond");
	
    // Pr�chargement des images
    for (var i=1; i<= diapoCount; i++) {
        diapoPreloads[i] = new Image();
        diapoPreloads[i].src = diapoFolder + "photo_accueil_"  + i + ".jpg";
    }
	
    // D�marrage du diaporama
    window.setTimeout("diapoHideCurrent()", diapoDelay);
}

function diapoHideCurrent() {
	
    // Disparition
    new Effect.Opacity("photo_fond", {
        from: 1,
        to: 0,
        duration: diapoFade,
        transition: Effect.Transitions.sinoidal,
        afterFinish: diapoShowNext
    });
	
}

function diapoShowNext() {
	
    // Incr�mentation de la diapo
    diapoId ++;
    if(diapoId > diapoCount)
        diapoId = 1;
	
    // Apparition
    diapoContainer.style.backgroundImage = "url(" + diapoFolder + "photo_accueil_" + diapoId + ".jpg" + ")";
    new Effect.Opacity(diapoContainer, {
        from: 0,
        to: 1,
        duration: diapoFade,
        transition: Effect.Transitions.sinoidal,
        afterFinish: function(){
            window.setTimeout("diapoHideCurrent()", diapoDelay)
            }
        });

}


/* ================================================================ 
This copyright notice must be kept untouched in the stylesheet at 
all times.

The original version of this script and the associated (x)html
is available at http://www.stunicholls.com/menu/pro_drop_1.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */
stuHover = function() {
    var cssRule;
    var newSelector;
    for (var i = 0; i < document.styleSheets.length; i++)
        for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
        {
            cssRule = document.styleSheets[i].rules[x];
            if (cssRule.selectorText.indexOf("LI:hover") != -1)
            {
                newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
                document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
            }
        }
    var getElm = document.getElementById("nav").getElementsByTagName("LI");
    for (var j=0; j<getElm.length; j++) {
        getElm[j].onmouseover=function() {
            this.className+=" iehover";
        }
        getElm[j].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" iehover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", stuHover);


