﻿// Slider des images de l'entête d'accroche

var currentImage;
var currentIndex = -1;
var interval;
function showImage(index) {
    if (index < $('#bigPic img').length) {
        var indexImage = $('#bigPic img')[index]
        if (currentImage) {
            if (currentImage != indexImage) {
                $(currentImage).css('z-index', 2);
                clearTimeout(myTimer);
                $(currentImage).fadeOut(250, function() {
                    myTimer = setTimeout("showNext()", 7000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage).css({ 'display': 'block', 'opacity': 1 });
        currentImage = indexImage;
        currentIndex = index;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index]).addClass('active');
    }
}

function showNext() {
    var len = $('#bigPic img').length;
    var next = currentIndex < (len - 1) ? currentIndex + 1 : 0;
    showImage(next);
}

var myTimer;

$(document).ready(function() {
    myTimer = setTimeout("showNext()", 7000);
    showNext(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage(parseInt(count) - 1);
    });
});







//Slider des logos clients

var currentImage_clients;
var currentIndex_clients = -1;
var interval_clients;
function showImage_clients(index_clients) {
    if (index_clients < $('#bigPic_clients img').length) {
        var indexImage_clients = $('#bigPic_clients img')[index_clients]
        if (currentImage_clients) {
            if (currentImage_clients != indexImage_clients) {
                $(currentImage_clients).css('z-index', 2);
                clearTimeout(myTimer_clients);
                $(currentImage_clients).fadeOut(250, function() {
                    myTimer_clients = setTimeout("showNext_clients()", 7000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage_clients).css({ 'display': 'block', 'opacity': 1 });
        currentImage_clients = indexImage_clients;
        currentIndex_clients = index_clients;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index_clients]).addClass('active');
    }
}

function showNext_clients() {
    var len_clients = $('#bigPic_clients img').length;
    var next_clients = currentIndex_clients < (len_clients - 1) ? currentIndex_clients + 1 : 0;
    showImage_clients(next_clients);
}

var myTimer_clients;

$(document).ready(function() {
    myTimer_clients = setTimeout("showNext_clients()", 7000);
    showNext_clients(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage_clients(parseInt(count) - 1);
    });
});






//Slider du texte du module actu

var currentImage_actutxt;
var currentIndex_actutxt = -1;
var interval_actutxt;
function showImage_actutxt(index_actutxt) {
    if (index_actutxt < $('#bigPic_actu div').length) {
        var indexImage_actutxt = $('#bigPic_actu div')[index_actutxt]
        if (currentImage_actutxt) {
            if (currentImage_actutxt != indexImage_actutxt) {
                $(currentImage_actutxt).css('z-index', 2);
                clearTimeout(myTimer_actutxt);
                $(currentImage_actutxt).fadeOut(250, function() {
                    myTimer_actutxt = setTimeout("showNext_actutxt()", 10000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage_actutxt).css({ 'display': 'block', 'opacity': 1 });
        currentImage_actutxt = indexImage_actutxt;
        currentIndex_actutxt = index_actutxt;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index_actutxt]).addClass('active');
    }
}

function showNext_actutxt() {
    var len_actutxt = $('#bigPic_actu div').length;
    var next_actutxt = currentIndex_actutxt < (len_actutxt - 1) ? currentIndex_actutxt + 1 : 0;
    showImage_actutxt(next_actutxt);
}

var myTimer_actutxt;

$(document).ready(function() {
    myTimer_actutxt = setTimeout("showNext_actutxt()", 10000);
    showNext_actutxt(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage_actutxt(parseInt(count) - 1);
    });
});






//Slider du titre du module actu

var currentImage_actutitle;
var currentIndex_actutitle = -1;
var interval_actutitle;
function showImage_actutitle(index_actutitle) {
    if (index_actutitle < $('#bigPic_actu h2').length) {
        var indexImage_actutitle = $('#bigPic_actu h2')[index_actutitle]
        if (currentImage_actutitle) {
            if (currentImage_actutitle != indexImage_actutitle) {
                $(currentImage_actutitle).css('z-index', 2);
                clearTimeout(myTimer_actutitle);
                $(currentImage_actutitle).fadeOut(250, function() {
                    myTimer_actutitle = setTimeout("showNext_actutitle()", 10000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage_actutitle).css({ 'display': 'block', 'opacity': 1 });
        currentImage_actutitle = indexImage_actutitle;
        currentIndex_actutitle = index_actutitle;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index_actutitle]).addClass('active');
    }
}

function showNext_actutitle() {
    var len_actutitle = $('#bigPic_actu h2').length;
    var next_actutitle = currentIndex_actutitle < (len_actutitle - 1) ? currentIndex_actutitle + 1 : 0;
    showImage_actutitle(next_actutitle);
}

var myTimer_actutitle;

$(document).ready(function() {
    myTimer_actutitle = setTimeout("showNext_actutitle()", 10000);
    showNext_actutitle(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage_actutitle(parseInt(count) - 1);
    });
});




//Slider du lien du module actu

var currentImage_actulink;
var currentIndex_actulink = -1;
var interval_actulink;
function showImage_actulink(index_actulink) {
    if (index_actulink < $('#bigPic_actu a').length) {
        var indexImage_actulink = $('#bigPic_actu a')[index_actulink]
        if (currentImage_actulink) {
            if (currentImage_actulink != indexImage_actulink) {
                $(currentImage_actulink).css('z-index', 2);
                clearTimeout(myTimer_actulink);
                $(currentImage_actulink).fadeOut(250, function() {
                    myTimer_actulink = setTimeout("showNext_actulink()", 10000);
                    $(this).css({ 'display': 'none', 'z-index': 1 })
                });
            }
        }
        $(indexImage_actulink).css({ 'display': 'block', 'opacity': 1 });
        currentImage_actulink = indexImage_actulink;
        currentIndex_actulink = index_actulink;
        $('#thumbs li').removeClass('active');
        $($('#thumbs li')[index_actulink]).addClass('active');
    }
}

function showNext_actulink() {
    var len_actulink = $('#bigPic_actu a').length;
    var next_actulink = currentIndex_actulink < (len_actulink - 1) ? currentIndex_actulink + 1 : 0;
    showImage_actulink(next_actulink);
}

var myTimer_actulink;

$(document).ready(function() {
    myTimer_actulink = setTimeout("showNext_actulink()", 10000);
    showNext_actulink(); //loads first image
    $('#thumbs li').bind('click', function(e) {
        var count = $(this).attr('rel');
        showImage_actulink(parseInt(count) - 1);
    });
});
