var myPlayer;

function hideContentPage(){
// cache le div de contenu

	$("#blocCentreFull").animate({
		/*top: '-' + $("#blocCentreFull").height() + 'px' ,*/
	   	opacity: 0
	}, 500, '', false);		
	
	/*
	$(".menuBas").animate({
		opacity:1, 		
		bottom: 0
	}, 500) ;
	*/
			
	$(".menu").css('background-color','transparent'); 
	$(".menuTop").css('opacity','0');
	$(".menuBottom").css('opacity','0');
}
function showMenuVignette(){
// affiche le div des vignettes
		
	$(".menuBas").animate({
		opacity:1, 		
		bottom: 0
	}, 500) ;
	//$(".menuBas a.slideshowThumb:first").trigger('click');
}



function showContentPage(){
// affiche le div de contenu

	$(".menuBas2").animate({
		opacity:1, 		
		bottom: 0
	}, 2000, '', false) ;
			
	$("#blocCentreFull").animate({
		/* top: '-' + $("#blocCentreFull").height() + 'px' , */
	   	opacity: 0

	}, 500, function() {
		$("#blocCentreFull").css('display','none')
	}) ;
}

function hideBackground(){
// cache le flash en background d'id slideshowBox (galerie d'image)

	$("#slideshowBox").animate({
	
	   	opacity: 0
	}, 500, function() {
	
		$("#slideshowBox").css('display','none')
	}) ;
}
function showBackground(){
// affiche le flash en background d'id slideshowBox (galerie d'image)

    if($("#slideshowBox").css('display') == 'none'){
    
    	$("#slideshowBox").animate({
    	
    	   	opacity: 1
    	}, 500, function() {
    	
    		$("#slideshowBox").css('display','block')
    	}) ;
    }
}
function showPlayer(){
// affiche le flash du player

    /*
	$("#flashcontentPlayer").animate({
	
	   	opacity: 0
	}, 500, function() {
	
		$("#flashcontentPlayer").css('display','block')
	}) ;
	*/
	$("#flashcontentPlayer").css({'display':'block','visibility':'visible','z-index':'2000'});
	
}
function hidePlayer(){
// cache le flash du player


	/*
	$("#flashcontentPlayer").animate({
	
	   	opacity: 0
	}, 500, function() {
	
		$("#flashcontentPlayer").css('display','none')
	}) ;
	*/
	
    $("#flashcontentPlayer").css('display','none');
    if($('#example_video_1').length>0){
    		myPlayer.pause();
    }
    
}



$(document).ready(function(){

	// *---------- On fixe les valeurs de départ0
	
		if($('#example_video_1').length>0){
			myPlayer = VideoJS.setup("example_video_1");
		}
	
		var pos = $("#blocCentreFull").position();
		
		$("#blocCentreFull").css('position', '') ;
		$("#blocCentreFull").css('top', 0) ;
		$("#blocCentreFull").css('left', pos.left) ;
		 
	
		$(".menuBas").css('opacity', 0) ;  

		$(".menuBas").css('bottom', '-' + $(".menuBas").height() + 'px' ) ;
		
		/* 2e version */
		$(".menuBas2").css('opacity', 0) ;  
		$(".menuBas2").css('display', 'block') ;
		$(".menuBas2").css('top', '-' + $(".menuBas2").height() + 'px' ) ;
		
		
		$('.swapAffichage').css('cursor', 'pointer');
		$('.swapRetour').css('cursor', 'pointer');
		
		
		$('.swapAffichagePlayer').css('cursor', 'pointer');
		
	
	// *---------------- Affichage du menu
	$('.swapAffichage').click(function() {
		hideContentPage();
		showMenuVignette();
	});
	// *---------------- Affichage du player
	$('.swapAffichagePlayer').click(function() {
		hideContentPage();
		hideBackground();
		showPlayer();
	});
	
	// *---------------- Affichage du menu 2e version
	$('.swapAffichage2').click(function() {
		showContentPage();
	});
	
	
	// *---------------- Retour au contenu
	$('.swapRetour').click(function() {
		
		hidePlayer();
		showBackground();
		
		$("#blocCentreFull").animate({
			top: 0,
		   	opacity: 1
		}, 1000, '', false);		

		$(".menu").css('background-color','#211611'); 
		$(".menuTop").css('opacity','1');
		$(".menuBottom").css('opacity','1');
	
			
		$(".menuBas").animate({
			opacity:0, 		
			bottom: '-' + $(".menuBas").height() + 'px' 
		}, 1000, function() {
			$(".menuBas").css('display','none')
		}) ;

		/* 2e version */
		$(".menuBas2").animate({
			opacity:0, 		
			bottom: '-' + $(".menuBas2").height() + 'px' 
		}, 1000) ;
				
	}); 
	
});
