$(function(){

    $('#hautpage a').live('click', function(event){ 
       event.preventDefault();
       $('html,body').animate({scrollTop: 0}, {duration:500}); 
    }); 

/*---*/

$("#theWrapperDesScrolls").css({height:"275px", position:"relative", float:"left", overflow:"hidden"});

/*---------------------------------------------------------------------------*/

$("#btnActualiteAccueil").click(function(){ 
 $(this).css("cursor","pointer").removeAttr("href"); 
 $("#wrapper_scrollAccueil").stop().animate({"top": "0px"}, "slow");
 $("#wrapper_scrollReduire").stop().animate({"top": "0px"}, "slow");
 $("#wrapper_scrollTrier").stop().animate({"top": "275px"}, "slow");
 $("#wrapper_scrollValoriser").stop().animate({"top": "275px"}, "slow");
}); 
 
$("#btnReduireAccueil").click(function(){ 
 $(this).css("cursor","pointer").removeAttr("href"); 
 $("#wrapper_scrollAccueil").stop().animate({"top": "-275px"}, "slow");
 $("#wrapper_scrollReduire").stop().animate({"top": "-275px"}, "slow");
 $("#wrapper_scrollTrier").stop().animate({"top": "-275px"}, "slow");
 $("#wrapper_scrollValoriser").stop().animate({"top": "0px"}, "slow"); 
}); 

$("#btnTrierAccueil").click(function(){ 
 $(this).css("cursor","pointer").removeAttr("href"); 
 $("#wrapper_scrollAccueil").stop().animate({"top": "-275px"}, "slow");
 $("#wrapper_scrollReduire").stop().animate({"top": "-550px"}, "slow");
 $("#wrapper_scrollTrier").stop().animate({"top": "-550px"}, "slow");
 $("#wrapper_scrollValoriser").stop().animate({"top": "-550px"}, "slow"); 
}); 

$("#btnValoriserAccueil").click(function(){ 
 $(this).css("cursor","pointer").removeAttr("href"); 
 $("#wrapper_scrollAccueil").stop().animate({"top": "-275px"}, "slow");
 $("#wrapper_scrollReduire").stop().animate({"top": "-550px"}, "slow");
 $("#wrapper_scrollTrier").stop().animate({"top": "-825px"}, "slow");
 $("#wrapper_scrollValoriser").stop().animate({"top": "-825px"}, "slow");
}); 

/*----------------------------------------------------------------------------*/

    if ($("#scrollAccueil").size() > 0) {
        $("#scrollAccueil").slidable({
            width: 816,
            height: 275,
            vitesse : 1,
            shadow : true,
            shadowWidth : 1,
            arrows: {
                position: 'in',
                width: 33,
                left: {
                    left: 0,
                    top: -20
                },
                right: {
                    left: 783,
                    top: -20
                }
            }
        });
    }



    if ($("#scrollReduire").size() > 0) {
        $("#scrollReduire").slidable({
            width: 816,
            height: 275,
            vitesse : 1,
            shadow : true,
            shadowWidth : 1,
            arrows: {
                position: 'in',
                width: 33,
                left: {
                    left: 0,
                    top: -20
                },
                right: {
                    left: 783,
                    top: -20
                }
            }
        });
    }



    if ($("#scrollTrier").size() > 0) {
        $("#scrollTrier").slidable({
            width: 816,
            height: 275,
            vitesse : 1,
            shadow : true,
            shadowWidth : 1,
            arrows: {
                position: 'in',
                width: 33,
                left: {
                    left: 0,
                    top: -20
                },
                right: {
                    left: 783,
                    top: -20
                }
            }
        });
    }



    if ($("#scrollValoriser").size() > 0) {
        $("#scrollValoriser").slidable({
            width: 816,
            height: 275,
            vitesse : 1,
            shadow : true,
            shadowWidth : 1,
            arrows: {
                position: 'in',
                width: 33,
                left: {
                    left: 0,
                    top: -20
                },
                right: {
                    left: 783,
                    top: -20
                }
            }
        });
    }


/*-----------------------------------------------------------------------------------------*/

$('#menu>ul>li>a').each(function(){
    if (!$(this).parent().hasClass("on")){
        $(this).css({backgroundPosition: "0px  0px"}) 
        .mouseover(function(){ 
            $(this).stop().animate({backgroundPosition:"(0px -44px)"}, {duration:100}) 
        }) 
        .mouseout(function(){ 
            $(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:500}) 
        })
    }
});


/*---*/


$('#menu>ul>li>ul>li>ul>li>a').mouseover(function(){ 
$(this).stop().animate({backgroundPosition:"(5px -86px)"}, {duration:250}) 
}) 

$('#menu>ul>li>ul>li>ul>li>a').mouseout(function(){ 
$(this).stop().animate({backgroundPosition:"(5px 7px)"}, {duration:500}) 
}) 



/*---*/


$("#footer #liensFooter li a").mouseover(function(){ 
     $(this).stop().animate({backgroundPosition:"(0px -38px)"},250); 
}); 

$("#footer #liensFooter li a").mouseout(function(){ 
     $(this).stop().animate({backgroundPosition:"(0px 0px)"}); 
}); 


/*-------------------------------------------------------------------------------------------------------*/
/*------------------ ACCORDEON SUR PAGES A EDITION MANUELLE -----------------*/
/*-------------------------------------------------------------------------------------------------------*/

   var mode = 0;
   $('p').each(function() {
      if($(this).html().match(/\/{3,}/)) {
         if (mode == 0) { 
            $(this).replaceWith('<div class="replie">');
            mode = 1;
      
         } else if (mode == 1) {
            $(this).replaceWith('<div class="replie_fin">');
            mode = 0;
         } 
      }
   });
   $('div.replie').nextUntil('div.replie_fin').each(function() {
       $(this).prev('div.replie').append($(this));
   });
   $('div.replie_fin').remove();
   $('div.replie').css({"overflow":"hidden", "display": "none" });
   $('div.replie').each(function(){
      $(this).prev().css({cursor:'pointer'});
      $(this).prev().toggle(function(){
         $(this).next('div.replie').slideDown("slow");
      },function(){ 
         $(this).next('div.replie').slideUp("slow");
      });
   });



}); 
