$(function(){
   // General actions
   $("#light").show();
   
   // Menu
   $("#menu li:not(.home) a").click(function(){
      $("#menu li").removeClass("active");
      $(this).parent().addClass("active");
   });
   

   // Slideshow
   $("#slideshow").disableTextSelect().bind("contextmenu", function(){ return false; });
   
   
   // Videos
   if ($(".scroll").height() >= 440) $(".scroll").removeClass("nojs").jScrollPane({
      mouseWheelSpeed:20,
      animateScroll:1,
      autoReinitialise:1,
      autoReinitialiseDelay:0
   });
   
      // Video
      if ($("#black").length) $("#black").hide().fadeIn(1200);
      light = false;
      $("#light a").click(function(){
         $("#black").animate({opacity:"toggle"}, 400);
         if (!light){ $(this).addClass("active"); light = true; }
         else{ light = false; $(this).removeClass("active"); }
         return false;
      });
      $("#black").click(function(){
         $(this).fadeOut(300);
         $("#light a").addClass("active");
         light = true;
         return false;
      });
      
      
   // Photos
   $("#thumbnails a").click(function(){
      var img = $(this).attr("href"),
          photo = "#picture";
      
      if (img != $(photo).attr("src")){
         $(photo).fadeOut(350, function(){
            $(this).load(function(){
               $(this).fadeIn();
            }).attr("src", img);
         });
      }
      return false;
   }).hover(function(){
         $(this).css({opacity:0.9}).animate({opacity:1}, 250);
      }, function(){
         $(this).animate({opacity:0.9}, 500);
   });
      
   
   // Rollover
   $(".item").hover(function(){
         $(this).find(".title, .infos, .black").hide();
         $(this).stop().find(".title, .infos, .black").fadeIn(200);
      }, function(){
         $(this).find(".title, .infos, .black").fadeOut(300);
   });
   
   
   // Galleries
   $(".gallery a").fancybox({
      padding:0,
      margin:20,
      centerOnScroll:true,
      overlayColor:"#333330",
      overlayOpacity:1,
      changeSpeed:250,
      speedIn:700,
      speedOut:300
   });
   
   // Contact
   $(".mail").each(function(){
	   var email = $(this).html();
	   $(this).html(email).replaceWith('<a href="mailto:' + $(this).text() + '">' + $(this).text() + '</a>');
	});
   
   $("#form #mail[value='Adresse e-mail'], #form #mail[value='E-mail address'], #form #message:contains(Message)").focus(function(){
   	if(this.value == this.defaultValue){
   		this.value = "";
   	}
   });
});
