function afficheOnglet(id) {
    cacheOnglet();
    document.getElementById('menu'+id).style.display="block";
    document.getElementById('onglet'+id).style.backgroundImage="url('images/onglet.png')";
    document.getElementById('onglet'+id).style.color="#4f83c6";
}

function cacheOnglet() {
    var div1 = document.getElementById('menu1');
    var div2 = document.getElementById('menu2');
    var div3 = document.getElementById('menu3');
    var div4 = document.getElementById('menu4');
    if (div1.style.display == "block") {
        div1.style.display="none";
        document.getElementById('onglet1').style.backgroundImage="url('images/onglet_non_selectionner.png')";
    }
    
    else if(div2.style.display == "block") {
        div2.style.display="none";
        document.getElementById('onglet2').style.backgroundImage="url('images/onglet_non_selectionner.png')";
    } 
    
    else if (div3.style.display == "block") {
        div3.style.display="none";
        document.getElementById('onglet3').style.backgroundImage="url('images/onglet_non_selectionner.png')";
    }
    
    else if (div4.style.display == "block") {
        div4.style.display="none";
        document.getElementById('onglet4').style.backgroundImage="url('images/onglet_non_selectionner.png')";
    }
}

function changeCouleur(id) {    
    document.getElementById('onglet'+id).style.color="#4f83c6";
}

function rechangeCouleur(id) {    
    document.getElementById('onglet'+id).style.color="#666666";
}

function zoom_image(id) {
    var url = document.getElementById(id).src;
    document.getElementById('image_zoomer').src=url;
}

var i = 0;
function scroll_dg(direction, nb_image)
{
    if (direction == "droite") 
    {
        if (i != 0)
        {				
            $('#block').animate( {
                "left":
                "+=1000px"},
                1500);
                i--;
                nb--;
        }
    }
        
    if (direction == "gauche") 
    {
        if (i != (nb_image - 1))
        {				
            $('#block').animate( {
                "left":
                "-=1000px"},
                1500);
                i++;
                nb++;
        }
    }
}

var x = 0;
function scroll_capture(direction, nb_img)
{
    var max = nb_img - 6;
    
    if (direction == "droite") 
    {
        if (x != 0)
        {				
            $('#block_capture').animate( {
                "left":
                "+=120px"},
                1000);
                x--;
        }
        
        if (x == 0)
        {
            document.getElementById('fl_gauche_capture').style.backgroundImage='url(images/pixel.png)';
        } 
        
        if (x == (max - 1))
        {
            document.getElementById('fl_droite_capture').style.backgroundImage='url(images/fd.png)';
        }        
    }
        
    if (direction == "gauche") 
    {
        if (x != max)
        {				
            $('#block_capture').animate( {
                "left":
                "-=120px"},
                1000);
                x++;
        }
        
        if (x == max)
        {
            document.getElementById('fl_droite_capture').style.backgroundImage='url(images/pixel.png)';
        }
        
        if (x == 1)
        {
            document.getElementById('fl_gauche_capture').style.backgroundImage='url(images/fg.png)';
        }
    }
}

function afficheMenu(id) {
    for (var i = 1; i<=4; i++)
    {
        $("#Smenu"+i).slideUp(1);
        document.getElementById("les_menu"+i).style.color='#666666';
        document.getElementById("les_menu"+i).style.backgroundRepeat='no-repeat';
        document.getElementById("les_menu"+i).style.backgroundImage='';
    
    }
    
    $("#Smenu"+id).slideDown(500);

    document.getElementById("les_menu"+id).style.backgroundImage='url(images/bg_menu_titre.png)';
    document.getElementById("les_menu"+id).style.backgroundRepeat='no-repeat';
    document.getElementById("les_menu"+id).style.backgroundPosition="50% -3px";
    document.getElementById("les_menu"+id).style.color='white';
    
}

function afficheMenu2(id) {
    for (var i = 1; i<=4; i++)
    {
        $("#Smenu"+i).slideUp(1);
        document.getElementById("les_menu"+i).style.color='#666666';
        document.getElementById("les_menu"+i).style.backgroundRepeat='no-repeat';
        document.getElementById("les_menu"+i).style.backgroundImage='';
    
    }
    
    $("#Smenu"+id).slideDown(500);

    document.getElementById("les_menu"+id).style.backgroundImage='url(images/bg_menu_titre2.png)';
    document.getElementById("les_menu"+id).style.backgroundRepeat='no-repeat';
    document.getElementById("les_menu"+id).style.backgroundPosition="50% -3px";
    document.getElementById("les_menu"+id).style.color='white';
    
}

function hover(id_div) {
    document.getElementById('id_div').style.backgroundImage='url(images/'+id_div+'2.png)';
}

function fermerMenu() {
    for (var i = 1; i<=4; i++)
    {    
        $("#Smenu"+i).slideUp(1);
    }
}

function timerSlider(nb_image) {
    setInterval("appelSlider("+nb_image+")", 3500);
}

var nb = 1;
var retour = false;
var timer_ok = true;
function appelSlider(nb_image) {
    if (((nb != nb_image) && (retour == false)) && (timer_ok == true)) {
        scroll_dg('gauche',nb_image);
    }
    
    else if ((nb > 1) && (timer_ok == true)) {
        scroll_dg('droite',nb_image);
        retour = true;
        if (nb == 1)
            retour = false;
    }
}

function startTimer() {
    timer_ok = true;
}

function stopTimer() {
    timer_ok = false;
}
