function openFilm() {
$('body').prepend('<div id="high" class="layer"></div>');
$('#high').load('thefilm.html',function(){$('#high').fadeIn('slow');});
$('#high').addClass('divactive video');
$('#wrapper').append('<span id="theLegend2"><strong>Le film culte qui donne envie ! Le distrait. 1970. R&eacute;alisation Pierre Richard.</strong></span>');
$("#homepage").html('');
twistaudio();
}


function openRef(reference)
     {
		 
		 $('body').prepend('<div id="high" class="layer"></div>');
         $('#high').load(reference,function(){$('#high').fadeIn("slow");});
		 $('#high').addClass('divactive');
		 if(reference=='whatelse.html'){twistaudio();$('#high').addClass('video');}
		 $("#homepage").html('');
	
		 
	  }

function twistaudio()
		{
			if ($('#playermp3').is(".stopped"))
			 {
			//niftyplayer('niftyPlayer1').playToggle();
			//$('#playermp3').addClass('paused');
			 }
			else if ($('#playermp3').is(".init")) 
		      {
			$('#playermp3').removeClass('init');
			  }
			 else
			 {
			niftyplayer('niftyPlayer1').playToggle();
			$('span.hitplayer').toggle();
			 }
}



function twistaudiofirst()
		{
		var nbzone = $('div.divactive').size();
		if(nbzone==0){
			if ($('#playermp3').is(".stopped"))
			 {
			$('#playermp3').removeClass('init');
			 }
			 else if ($('#playermp3').is(".init"))
			 {
			$('#playermp3').removeClass('init');
			niftyplayer('niftyPlayer1').playToggle();
			$('span.hitplayer').toggle();
			 }
			 else if ($('#playermp3').is(""))
			 {
			niftyplayer('niftyPlayer1').playToggle();
			$('span.hitplayer').toggle();
			 }
			
		}
		}


		

function retourHome() {
	$('#theLegend2').remove();
	var nbzone = $('div.divactive').size();
	var nbvideo = $('div.video').size();

	switch(nbzone) {
	   case 2:
		  $("div.divactive:first").fadeOut('fast',function(){$("div.divactive:first").remove();});
		  $('#prevM,#nextM').css({"opacity":1});
		   break;
	   case 1:
	   	   //$('#accueil').show();
		   $("div.divactive:first").fadeOut('slow',function(){$("div.divactive:first").remove();});
		   if(nbvideo==1)twistaudio();
		   $('#homepage').load('homepage2.html');
		   break;
	   case 0:
		   break;	   	
	}
}


$('img.white').live("mouseover",
      function () {
         var nomimage = $(this).attr("src");
		 nomimage = nomimage.replace('.jpg','_on.jpg');
		 $(this).attr({src:nomimage});     }
);
$('img.white').live("mouseout",
      function () {
         var nomimage = $(this).attr("src");
		 nomimage = nomimage.replace('_on.jpg','.jpg');
		 $(this).attr({src:nomimage});     }
);

$('img.imgref').live("click",
      function () {
		$('#prevM,#nextM').css({"opacity":0});
		 $('body').prepend('<div id="high" class="layer"></div>'); 
         var toload = $(this).attr("name");
	     $('#high').load(toload,function(){$('#high').fadeIn("slow");});
		 $('#high').addClass('divactive');
	     $("#homepage").html('');
		
		 
	  }
		 
);





$('#next').live("click",				  
		function () {
			 $('#prev').removeClass();
			 var repere=$(this).attr('name');
			 //var thelegend = $('#deroulant img.visible,object.visible + *').attr('name');
			 var nbobjet = $('#deroulant').children('img,object').size();
			 if ($(this).is(".last")==false) //je n'active la fonction que si je ne suis pas sur le dernier Ã©lÃ©ment
			 {
			 $('#deroulant *.visible:first').fadeOut(2000).addClass('viewed');	 
			 $('#deroulant *.visible + *').fadeIn(2000).addClass('visible');
			 $('#deroulant *.visible:first').removeClass("visible");
			 var thelegend = $('.visible').attr('alt');
			  $('#sstitre').html(thelegend);
			 repere++;
			 $(this).attr({name:repere});
			 }
			 if(repere==nbobjet){//enfin, je calcule si je ne suis pas au bout de ma liste.
			 $(this).addClass("last");//le cas Ã©cheant, j'ajoute une classe au bouton pour le faire disparaitre.
			 }
			 return false;
		} );

 $('#prev').live("click",				  
		function () {
			 $('#next').removeClass();
			 var repere=$('#next').attr('name');
			 //var thelegend = $('#deroulant img.viewed:last').attr('alt');
 			 $('#deroulant *.visible:first').fadeOut(2000);	 
			 $('#deroulant *.viewed:last').fadeIn(2000).addClass('visible').removeClass("viewed");
			 $('#deroulant *.visible:last').removeClass("visible");
			 var thelegend = $('.visible').attr('alt');
			 $('#sstitre').html(thelegend);
			 repere--;
			 $('#next').attr({name:repere});
			 if(repere==1){//enfin, je calcule si je ne suis pas au bout de ma liste.
			 $(this).addClass("first");//le cas Ã©cheant, j'ajoute une classe au bouton pour le faire disparaitre.
			 }
			 return false;
		} );



$('#nextM').live("click",				  
		function () {
			 $('#prevM').removeClass();
			 $(".page1").hide();
			 $(".page2").show();
			 $(this).addClass("last");//le cas Ã©cheant, j'ajoute une classe au bouton pour le faire disparaitre.
			 return false;
		} );

 $('#prevM').live("click",				  
		function () {
			 $("#nextM").removeClass();
			 $(".page2").hide();
			 $(".page1").show();
			 $(this).addClass("first");
			 return false;
		} );









		$('td#gotopeople').live("click",
      function () {
		     $('body').prepend('<div class="layer" id="thepeople"></div>');
		     $('#thepeople').fadeIn("slow");
			 $('#thepeople').addClass('divactive');
			 $("#homepage").html('');
		      }
	 );									   
						   
						   

 
 
  $('#gotoref').live("click",
      function () {
		  	 $('body').prepend('<div id="medium" class="layer"></div>');
		     $('#medium').load('marques.html',function(){$('#medium').fadeIn("slow");});
			 $('#medium').addClass('divactive');
			 $("#homepage").html('');
		} );
  
   $('#gotospec').live("click",
      function () {
		  	 $('body').prepend('<div id="medium" class="layer"></div>');
		     $('#medium').load('specialites.html',function(){$('#medium').fadeIn("slow");});
			 $('#medium').addClass('divactive');
			 $("#homepage").html('');
		} );
 
 
   $('#thePhilo').live("click",
      function () {
		  twistaudio();
		  	$('body').prepend('<div id="high" class="layer"></div>');
		     $('#high').load('philosophie.html',function(){$('#high').fadeIn("slow");});
			  $('#high').addClass('divactive');
			 $('#high').addClass('video'); 
			 $("#homepage").html('');
			  
		} );







$(document).ready(function(){
			
	
	$('#homepage').load('homepage.html');
	
	
    $('#theContact').toggle(
			function(){
				$(this).animate({"width": "+=400px"}, "slow");
				$('#tbContact').animate({"left": "+=320px"}, "slow");
			},
			function(){
				$(this).animate({"width": "-=400px"}, "slow");
				$('#tbContact').animate({"left": "-=320px"}, "slow");
			}			
			);
 	
	$('#playermp3 a#Stop').click(
				function(){
					$('#playermp3').removeClass();
					$('span.hitplayer').toggle();
					niftyplayer('niftyPlayer1').stop();
					$('#playermp3').addClass('stopped');
					return false;
				}
				);
	$('#playermp3 a#Play').click(
				function(){
					$('#playermp3').removeClass();
					$('span.hitplayer').toggle();
					niftyplayer('niftyPlayer1').play();
					return false;
				}
				);
 
 
});

