// JavaScript Document

/// le scoller


$(document).ready(function() {
///////////////// debut document ready	
$("div#container").smoothDivScroll({});


$("#slogan").fadeIn(5100);

VideoJS.setupAllWhenReady();	
 
$(".paneBloc").live('mouseenter', function() {
 				  $(this).find("h1").animate({
							opacity: 0
							}, 300, function() {
				});	
			  //si  premier element de la liste on fait padding que a droite
			  	if ($(this).hasClass("first"))
				{
						$(this).delay(500).animate({
							paddingRight: '200px'
							  }, 500, function() {
								
							//$(this).find("h1").delay(200).fadeTo(400, 0.8);
							$(this).find("h1").animate({
							opacity: 0.8,
							top: '595px'},{duration: 400, easing: 'easeOutBack'});	  
								  
						});	
						
						
						 
					}
				 //si  dernier element de la liste on fait padding que a gauche
				else  if ($(this).hasClass("last"))
				{
					$(this).delay(500).animate({
							paddingLeft: '170px',
							marginRight: '160px'
							  }, 500, function() {
								  
							$(this).find("h1").animate({
							opacity: 0.8,
							top: '595px'},{duration: 400, easing: 'easeOutBack'});
								 
							});	
					
				}
				// sinon padding a droite et gauche
				else {
					
							
							$(this).delay(500).animate({
							paddingLeft: '100px',
							paddingRight: '100px'
							  }, 500, function() {	
							  	//$(this).find("h1").delay(200).fadeTo(400, 0.8);
							$(this).find("h1").animate({
							opacity: 0.8,
							top: '595px'},{duration: 400, easing: 'easeOutBack'});
							});	
								
							
						
				}
 }).live('mouseleave', function() {
   // on finit toutes les animation en cours 
						$(this).stop(true, true);
							 
						$(this).find("h1").animate({
						 opacity: 0,
						top: '690px'
						}, 300, function() {
							
						$(this).parent("div").animate({
							paddingLeft: '0px',
							paddingRight: '0px',
							marginRight: '0',
							marginLeft: '0'
							  }, 500, function() {
						});
					
					});	
});


 ////////////////////////////////  
// image triangle du début

	
	$("#allTriangle").click(function () { 
		$('#allTriangle').animate({top: '-3000px'}, 1000, 'easeInQuad');
		$("#slogan").fadeOut(100);
		$("#slogan").remove();
	});
	

	

	/////////////////////////////////////////
	//  Galerie produit
	
	$(".thumbs  a").click( function() {
		var monImg = $(this).attr("id");
		
		$("ul#slide li."+ monImg).css("z-index","50");
		$("ul#slide li.actif").addClass("down");
		$("ul#slide li.down").css("z-index","30");
		if (!$("ul#slide li."+ monImg).hasClass("actif"))
		{
		
		$("ul#slide li."+ monImg).animate({left: '0px' }, 500,
							 function () 
								 {
									$(this).addClass("actif");
									$("ul#slide li.down").delay(100).animate({left: '980px'}, 200,
										 function () 
											{
												$(this).removeClass("actif");
												$(this).removeClass("down");
											});
								 });	
		}
		return false;
	});
	
	
	/////////////////////////////////////
	// fonction du menu 
	
	
	$('.btn-slide').hover(
		  function () {
				
			$('#panel').stop(true, true);
			$('#panel').animate({ marginTop: "0px" }, 1100 );
		  }, 
		  function () {
			$( "#panel" ).animate( { marginTop: "0px" }, { queue: true, duration: 800 })
			 .animate({ marginTop: "-165px" }, 400 );
	});
	
	$('#panel').hover(
		  function () {
			$('#panel').stop(true, true);
		  }, 
		  function () {
			$( "#panel" ).animate( { marginTop: "0px" }, { queue: true, duration: 800 })
			 .animate({ marginTop: "-165px" }, 300 );
	  
	});

//	
//	$('#lienProduit').hover(
//		  function () {
//			$('#submenu').stop(true, true);
//			$('#submenu').fadeIn(500);
//			
//		  }, 
//		  function () {
//			$( "#submenu" ).animate( { queue: true, duration: 1000 })
//			 .fadeOut(300);
//	});
//	
//	$('#submenu').hover(
//		  function () {
//			$('#submenu').stop(true, true);
//		  }, 
//		  function () {
//			$( "#submenu" ).animate( { queue: true, duration: 1000 })
//			 .fadeOut(300);
//	  
//	});
	
	/////////////////////////////////////
	

	
	/// lien des 25 ans
//	
//	$('#lien25').click(function() {
//		if ($(this).hasClass("actif"))
//		{
//		$(this).animate({marginLeft:-455}, 800, 'swing');
//		$(this).removeClass('actif');
//			}
//			
//		else {
//		$(this).animate({marginLeft:0}, 800, 'swing');
//		$(this).addClass('actif');
//			}
//	  
//	});
	
	
	
	
	$('#lien25').hover(
		  function () {
			$('#lien25').stop(true, true);
			$(this).animate({marginLeft:0}, 800, 'swing');
		  }, 
		  function () {
			$(this).animate({marginLeft:0}, { queue: true, duration: 1500 })
			 .animate({ marginLeft: -455 }, 800 );
	});
	
	
	//Taille des images selon taille fenetre
	
	function imageresize() {
	 var contentwidth = $('#wrapper').width();
		 if ((contentwidth) < '1600'){
		 $('.thumbs').css('width','192px');
		 } else {
		 $('.thumbs').css('width','215px');
		 }
	 }
	
	 imageresize();//Triggers when document first loads    
	
	 $(window).bind("resize", function(){//Adjusts image when browser resized
	 imageresize();
	 });

/////////////////////////// fancybox exemples


$("#contact").fancybox({
				'width'				: 995,
				'height'			: 640,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

//$(".flefle").fancybox();




$(".flefle").fancybox({ 
		'onCleanup': function(){
			$('#lien25').stop(false, false);
           $('#lien25').animate({ marginLeft: -455 }, 800 );
        	}
		});



//////////////////////////////////////////////	
///////////////////// fin document ready	

});
