jQuery(document).ready(function($) {

  $("#fmail").validate();

  // Expand Panel
  $("#open").click(function(){
    $("#espace_user").hide();
    $("div#panel").slideDown("slow");
  });
  // Collapse Panel
  $("#close").click(function(){
    $("div#panel").slideUp("slow", function() {
      $("#espace_user").fadeIn();
    });
  });
  // Switch buttons from "Log In | Register" to "Close Panel" on click
  $("#toggle a").click(function () {
    $("#toggle a").toggle();
  });

  //div fonctionne en a
  $("#menu_home ul li").click(function(){
    //get the url from href attribute and launch the url
    window.location=$(this).find("a").attr("href"); return false;
  });

  //effect img home
  $("#menu_home img").hover(function(){
    $(this).stop(true, true).fadeTo("slow", 0.6); // on hover
  },function(){
    $(this).stop(true, true).fadeTo("slow", 1.0); // mouseout
  });

  //change class hover menu
  var backup_content_top = $('#content_top').attr('class');
  var backup_menu = $('#menu li.active').index();

  $('#menu li').hover(
    function()
    {
      $('#menu li').removeClass('active');
      $(this).addClass('active');

      $('#content_top').removeAttr('class').addClass($(this).find('a').attr('rel'));
    },
    function()
    {
      $('#content_top').removeAttr('class').addClass(backup_content_top);
      $('#menu li').removeClass('active').eq(backup_menu);
    }
  );

  //colorbox
  jQuery("a[rel='boxpopupimg']").colorbox();

  //tooltip
  jQuery(".east").tipsy({gravity: 'e', 'fade':true});
  jQuery(".north").tipsy({gravity: 'n', 'fade':true});


});

