// JavaScript Document

$(document).ready(function(){
	
  // Affichage aléatoire du fond d'écran de la page d'accueil
  
  var banListe=['01','02','03','04','05','06','07','08','09'];
  $('body#home').addClass('bg' + banListe[Math.floor(Math.random()*banListe.length)]);

  // Animation sur #homemenu
  
  var decalage = -20;
  
  $("#homemenu li a span").animate({
    opacity: 0,
    left: decalage,
  }, 0);
  
  $("#homemenu li a").hover(function(){
	
	$(this).children("span").animate({
	  opacity: 1.0,
	  left: 0,
	}, 500 );
	
  },function(){
	$(this).children("span").animate({
	  opacity: 0.0,
	  left: decalage,
	}, 200 );
  });
  
  // Menu LavaLamp
  
  $('#mainmenu').lavaLamp();
  
  // Accordion
  
  $( ".accordion" ).accordion({ autoHeight: false, collapsible: true, active: false });
  
  // Tabs
  
  $( ".tabs" ).tabs({ fx: { opacity: 'toggle' } });
  
  // Slideshow
  
  $("a[rel=nomad_photos]").fancybox({
	  'titleShow' 			: true,
	  'titlePosition'  : 'inside'
  });
  
  // Animation de .gallery
  
  $(".gallery a").hover(function(){
	$(this).children("img").animate({ top: -10 }, 500 );
	$(this).children(".overlay").animate({ top: -10 }, 500 );
  },function(){
	$(this).children("img").animate({ top: 0 }, 200 );
	$(this).children(".overlay").animate({ top: 0 }, 200 );
  });

  $(".gallery a .zoom").animate({ opacity: 0, left: -10 }, 0);
  
  $(".gallery a .overlay").hover(function(){
	$(this).children(".zoom").animate({ opacity: 1.0, left: 0 }, 500 );
  },function(){
	$(this).children(".zoom").animate({ opacity: 0.0, left: -10 }, 200 );
  });
  
  
  $(".launchfilm").fancybox({
	  'padding'				: 0,
	  'autoScale'			: false,
	  'transitionIn'		: 'none',
	  'transitionOut'		: 'none',
	  'width'				: 720,
	  'height'				: 405
  });
  
  // Animation crédits
  
  $("#noticesmenu .credits em").css("visibility","visible").animate({ opacity: 0 }, 0);
  
  $("#noticesmenu .credits").hover(function(){
	$(this).children("em").animate({
	  opacity: 1.0,
	  left: 20,
	}, 500 );
	
  },function(){
	$(this).children("em").animate({
	  opacity: 0.0,
	  left: 0,
	}, 200 );
  });

  // Back to Top animé
  
  $('a.top').click(function(){
	 $('html, body').animate({scrollTop: '0px'}, 300);
	 return false;
  });

});
