﻿var rmEvenement;
var rmVoyage;
var rmExcursion;
var rubrique;


function Initialize(Evenement, Voyage, Excursion, rub)
{
    var random;

    if (rub == "") 
    {
        random = Math.floor(Math.random() * 3);
        switch (random) 
        {
            case 0: document.getElementById("AllEvents").style.marginLeft = -Evenement * 608 + "px";
                AffichOn('Evenement');
                break;

            case 1: document.getElementById("AllVoyages").style.marginLeft = -Voyage * 608 + "px";
                AffichOn('Voyage');
                break;

            case 2: document.getElementById("AllExcursions").style.marginLeft = -Excursion * 608 + "px";
                AffichOn('Excursion');
                break;
        }
    }
    else 
    {
        AffichOn(rub);
    }
}


function AffichOn(val)
{
    document.getElementById("Men_Evenement").className = "off";
    document.getElementById("Men_Voyage").className = "off";
    document.getElementById("Men_Excursion").className = "off";
    
    document.getElementById("Evenement").style.display = "none";
    document.getElementById("Voyage").style.display = "none";
    document.getElementById("Excursion").style.display = "none";
    
    document.getElementById("Men_"+val).className = "on";
    document.getElementById(val).style.display = "";
}

var pos = 0;
var lastPosEve = 0;
var lastPosVoy = 0;
var lastPosExc = 0;


function Move(sens, nb, bloc)
{

    switch(bloc)
    {
        case "Events" : pos = lastPosEve; break;
        case "Voyages" : pos = lastPosVoy; break; 
        case "Excursions" : pos = lastPosExc; break;
    }

    var tailleMax = (nb-1)*608;
    var point;

    if(sens == "g")
    {
        if(pos == 0)
            pos = -tailleMax;
        else
            pos = pos+608;
    }
    else
    {
        if(pos == -tailleMax)
            pos = 0;
        else
            pos = pos-608;
    }
    
    point = -(pos/608);
    playTween(pos, point, bloc);
    
    switch(bloc)
    {
        case "Events" : lastPosEve = pos; break;
        case "Voyages" : lastPosVoy = pos; break; 
        case "Excursions" : lastPosExc = pos; break;
    }
}


function playTween(val, dot, section)
{
    GetDot(dot, section);

    var myFx = new Fx.Tween("All"+section);
    myFx.start('margin-left', val+"px");
}


function GetDot(val, bloc)
{
    $$('div[name^=dot'+bloc+']').set("class","point "+bloc+"off");
    document.getElementById("Point"+bloc+"_"+val).className = "point "+bloc+"on";
}

function ShowDetail(val)
{
    if(val == 1)
    {
        $$('.back').set("class","back top");
    }
    else
    {
        $$('.back').set("class","back");
    }
}



/*********************** HEADER ******************************/
/*************************************************************/

function AnimHeader()
{ 
    var random=Math.floor(Math.random()*4)+1;
    document.getElementById("Img").style.background = "url(/images/header/img/"+random+".jpg) no-repeat";
}

