﻿/* publicité haut */
$(document).ready(function() {
	$('#accAnim').jcarousel({
		scroll: 1,
		wrap: "circular",
		animation: 600,
        auto: 8,
		buttonPrevHTML: '<a href="javascript:void(0);" title="Précédent">&nbsp;</a>',
		buttonNextHTML: '<a href="javascript:void(0);" title="Suivant">&nbsp;</a>',
		itemLoadCallback: { onBeforeAnimation: mycarousel_itemLoadCallback }
	});
});

function mycarousel_itemLoadCallback(carousel, state)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() { carousel.startAuto(0); });
    carousel.buttonPrev.bind('click', function() { carousel.startAuto(0); });
};


/* publicité bas */
var TimePubBas = 6000;
var AutoAnimTimeout2 = null;
var AutoAnimPause2 = false;
function SwitchAutoAnim2() {
    if (!AutoAnimPause2) {

        if (CurringIndex >= ListDivPubliciteBottom.length - 1) {
            CurringIndex = -1;
        }

        ShowPubliciteBottom(CurringIndex + 1);
        AutoAnimTimeout = setTimeout(SwitchAutoAnim2, TimePubBas);

    }
}


var ListDivPubliciteBottom;
var ListAPubliciteBottom;
var CurringIndex = 0;

/*Cache toute les publicites et affiche la premiere */
$(document).ready(function() {
    ListDivPubliciteBottom = jQuery("div.PubliciteBottom");
    ListAPubliciteBottom = jQuery("a.PubliciteBottom");
    ShowPubliciteBottom(0);

});

/*Afficher la bonne publicite selon itemindex.*/
function ShowPubliciteBottom(itemIndex) {
    ListDivPubliciteBottom.css("display", "none");
    ListAPubliciteBottom.removeClass("Active");

    if (ListDivPubliciteBottom.length > itemIndex) {
        CurringIndex = itemIndex;
        $(ListDivPubliciteBottom[itemIndex]).css("display", "block");
        $(ListAPubliciteBottom[itemIndex]).addClass("Active");


        $("#aPubliciteBottomNext").attr("href", "javascript:ShowPubliciteBottom(" + (CurringIndex + 1) + ")");
        if (CurringIndex >= ListDivPubliciteBottom.length - 1)
            $("#aPubliciteBottomNext").attr("href", "javascript:ShowPubliciteBottom(0)");
    }

}
