/* ---- BLOQUE LE MENU QUAND IL ARRIVE EN HAUT DE PAGE ---*/

var tabImage = new Array();
var tailleZone = 0;
var nombre = 1;
 
$(function() {
    var posRight = parseInt($('#right').offset().top);
    var hauteurRight = parseInt($("#right").height());
    var windowHeight = $(window).height();
    var scrollTop = $(window).scrollTop();
    
    $(window).scroll(function() {
        var scrollTop = $(window).scrollTop();
            if(scrollTop > posRight)
                $("#wrapperRight").addClass("fixed").animate({"top": "+15px"},200);
            else
                $("#wrapperRight").removeClass("fixed").animate({"top": "-15px"});
    });
 
    $(".imgEffect img").each( function(){
        tailleZone++;
    });
 
    if(tailleZone > 0) affichage_image();
    $(".imgEffect img").fadeTo("normal", 0.5);
    $(".imgEffect img").mouseover(function(){
        $(this).fadeTo("700", 1);
    });
    $(".imgEffect img").mouseout(function(){
        $(this).fadeTo("normal", 0.5);
    });
});

function affichage_image()
{
    while(!test())
        test();
 
    var image = $(".imgEffect img:eq("+nombre+")");      
    image.fadeTo("700",1);
    image.fadeTo("700", 0.5);
    tabImage.push(nombre);
 
    if(tabImage.length == tailleZone){
        tabImage = Array();
    }
   
    window.setTimeout("affichage_image()", 1500);
}

function test()
{
    nombre = Math.floor(Math.random()*tailleZone);
 
    for(i=0; i<tabImage.length; i++){
        if(parseInt(nombre) == parseInt(tabImage[i])){
            return false;
        }
    }
    return true;
} 
