// JavaScript Document



$(document).ready(function () {

    /**
    * Switch JS if activate
    */

    $("*").removeClass("scroll-no-js");
    $("#slider-01-no-js").hide();
    $("#slider-01").show();
    $("#slider-02-no-js").hide();
    $("#slider-02").show();


    tabs = $('.clear');
    for (itabs = 0; itabs < tabs.length; itabs++) {
        if (tabs[itabs].innerHTML == ' ') {
            tabs[itabs].style.height = 0;
            tabs[itabs].style.overflow = 'hidden';
        }
        else if (tabs[itabs].innerHTML == '&#160;') {
            tabs[itabs].style.height = 0;
            tabs[itabs].style.overflow = 'hidden';
        }
        else if (tabs[itabs].innerHTML == '&nbsp;') {
            tabs[itabs].style.height = 0;
            tabs[itabs].style.overflow = 'hidden';
        }
    }


    /** MENU V2 */
    /*
    var currentSubItem;
    var currentItem;
    $("#header ul li ul").each(function () {
    if($(this).hasClass("select")) {
    currentSubItem = $(this)
    }
    });
    $("#header ul li").each(function () {
    if($(this).hasClass("active")) {
    currentItem = $(this)
    }
    });
	
    $("#header ul").mouseover(function(){
    $("#header ul li ul").each(function () {
    if($(this).hasClass("select")) {
    $("#header ul li ul").removeClass("select");
    }
    });
		
    });
	
    $("#header ul li").mouseover(function(){
    $("#header ul").children("li").each(function () {
    $(this).removeClass("active");
    });
    $(this).addClass("active");
    });
	
    $("#header").mouseout(function(){
    currentSubItem.addClass("select");
    $("#header ul li").each(function () {
    if($(this).hasClass("active")) {
    $(this).removeClass("active")
    }
    });
    currentItem.addClass("active");
    });
	
    */
    /**
    * 
    */
    $("input.autoreset").focus(function () {
        if ($(this).val() == $(this).attr("title"))
            $(this).val("");
    });

    $("input.autoreset").blur(function () {
        if ($(this).val() == "")
            $(this).val($(this).attr("title"));
    });

    /*$("ul.lang li a:first").addClass("actif");
    $("ul.lang li a").click(function () {
    $("ul.lang li a").removeClass("actif"); //Remove any "active" class
    $(this).addClass("actif"); //Add "active" class to selected tab
    //return false;
    });*/


    $("ul.ssmenu").children("li:last").addClass("last");


    $("ul.ssmenu").children("li:not(:last,:first)").each(function () {
        $(this).addClass("sep");
    });
    $("ul.ssmenu li li").removeClass("sep");

    $("ul.ssmenu div.sub").each(function () {
        $(this).children("div:last").removeClass("border");
    });
    $("ul.ssmenu").each(function () {
        $(this).children("li:last").addClass("last");
    });

    $(".box_scroll li:first").addClass("first");

    $("#lien div").children("ul").each(function (i) {
        $(this).addClass("list");
        $(this).attr("id", "list-0" + i);
    });


    $("#header ul.ssmenu li.last a").hover(
      function () {
          $(this).parent('li').css('background-position', '0 -22px');
      },
      function () {
          $(this).parent('li').css('background-position', '0 6px');
      }
    );


    /* Sommaire Edito */


    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function () {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        /*$('.acc_trigger').removeClass('active');
        $('.acc_container').hide();*/
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

    //Set default open/close settings
    $('.acc_container').hide(); //Hide/close all containers
    //$('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
    $(".tab_container .tab_content").each(function () {
        //$(this).children('.acc_trigger:first').addClass('active').next().show();
    });


    //On Click
    $('.acc_trigger').click(function () {
        $('.acc_trigger').removeClass('active');
        $('.acc_container').hide();
        if ($(this).next().is(':hidden')) { //If immediate next container is closed...
            $('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
            $(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container

        }
        else {
            $(this).removeClass('active');
            $('.acc_container').hide();

        }
        return false; //Prevent the browser jump to the link anchor
    });

});
