﻿$(document).ready(function () {
    $('#bloc-1').css('display', 'block');
    $('#bloc-1').addClass('active_bloc');

    //Bloc news
    $('.bloc_news_header_a').click(function () {
        switch_bloc_news(this);
        return false;
    });

    $('.bloc_news_header_button').mouseenter(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_defil_ON.png") top right no-repeat');
    }).mouseout(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_defil_OFF.png") top right no-repeat');
    });

    $('.bloc_news_footer_link').mouseenter(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_suite_ON.png") top right no-repeat');
    }).mouseout(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_suite_OFF.png") top right no-repeat');
    });

    //Liste Actu
    $('.bloc_news_list_read a').mouseenter(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_suite_ON.png") top right no-repeat');
    }).mouseout(function () {
        $(this).css('background', 'url("../images/bloc_news/MVSR_btn_suite_OFF.png") top right no-repeat');
    });

    $('.bloc_news_list_item').click(function () {
        switch_liste_actu(this);
    });
});
//setInterval('init_bloc_animation()', 10000);
var current_bloc_news = 2;

function init_bloc_animation() {
    switch_bloc_news('.bloc_news_header_button_' + current_bloc_news + ' a');
}

function switch_bloc_news(news) {
    var bloc_display = $(news).attr('href');
    $('.active_bloc_news_header_a').removeClass('active_bloc_news_header_a');
    $(news).addClass('active_bloc_news_header_a');
    $('.active_bloc').hide();
    $('.active_bloc').removeClass('active_bloc');
    $(bloc_display).addClass('active_bloc');
    $(bloc_display).fadeIn(1000);
    var current_bloc = bloc_display.split('-');
    current_bloc_news = parseInt(current_bloc[1])+1;
    if (current_bloc_news > 3)
        current_bloc_news = 1;
}

function switch_liste_actu(actu) {
    $('.bloc_news_list_active_item').removeClass('bloc_news_list_active_item');
    $(actu).addClass('bloc_news_list_active_item');
}
