$(function(){
 
    $("#recherche_avancee").css("display","none");
    $("#rechAv").css("cursor","pointer");

    $("#rechAv").stop().click(function () { 
        $("#recherche_avancee").slideToggle("slow"); 
     }); 

    $(".remplaceMenu").css("display",($("#menu ul li ul.on").length) ? "none" : "block");

    $("#menu >ul >li >ul >li:first-child a").addClass('firstClassMenu');
    $("#menu >ul >li >ul >li:last-child a").addClass('lastClassMenu');
 
    $("ul>li>ul>li.on:has(ul) a.lastClassMenu").addClass("selectLastClassMenu");

    $(".selectLastClassMenu").next("ul").addClass("selectLastUl");

    $(".bodyActus #inter div:nth-child(2n)").addClass('paire');

    $("#enUnClic ul").sortable();

    $(".hr").after("<hr />").remove(".hr");

    $("#menu ul li a span").each(function() {
        if($(this).html().length > 26) {
            $(this).parents("li").first().addClass("double");
        }
    });

   $(".contentReplaceMenu h3").each(function() {
        if($(this).html().length > 26) {
            $(this).addClass("double");
        }
    });



   $(".exergue").prepend("<span class=exergueBefore></span>");
   $(".exergue").append("<span class=exergueAfter></span>");

   $("#albums").addClass("slideWindow");

   $(".slideWindow ul li").mouseover(function(){
          $(this).children(".titre").stop().animate({"top": "-85px"}, "slow"); 
   });

   $(".slideWindow ul li").mouseout(function(){
          $(this).children(".titre").stop().animate({"top": "0px"}, "slow"); 
   });

    // Personnalisation des checkbox des annonces
    // ------------------------------------------------------------------------------    
    $('#resultats_horaires input[type="checkbox"]').each( function() {
        $(this).css('display', 'none');
        $(this).parent().append('<div class="checkbox"></div>');
        if ($(this)[0].checked) $(this).next("div").addClass("checked");
    });
    $("#resultats_horaires div.checkbox").hover(
        function() { $(this).addClass("over"); },
        function() { $(this).removeClass("over"); }
    )
    .click( function() {
        if ($(this).hasClass("checked")) {
            $(this).removeClass("checked");        
        } else {
            $(this).addClass("checked");
        }
        $(this).prev("input")[0].checked = $(this).hasClass("checked");
    });

    // Click sur annuler du formulaire de recherche des annonces
    // --------------------------------------------------------------------------------
    $('#form01[action="annonces.html"] input[type="reset"]').click(function() {
        $('#horaires div.checked').removeClass("checked");
    });


});
