// Trad
//======================================================================================================================
jQuery(function($){
  $.translate(function(){
	// Traduction
    function translateTo( destLang ){
		$('body').translate( 'fr', destLang, {
			alwaysReplace:true,
			fromOriginal:true
        });
    }
	
	// Click image
	$('#language')
	.find('a')
	.click(function(){
		 $.cookie('destLang', null); // Destruction du précédent cookie
		 var lang = $(this).attr('id');
		 translateTo( lang );
		 $.cookie('destLang', lang, { path: '/' } );
		 return false;		 
	});
	// Cookie  
    var destLang = $.cookie('destLang');
    
    if( destLang )
        translateTo( destLang );
	}); 
	
});

 
// Gallery
//======================================================================================================================
jQuery(document).ready(function(){  
 jQuery(".jbgallery").jbgallery(); 	
});  

// Fancybox
//======================================================================================================================
$(document).ready(function() {
	$("#resa").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
  $("#resa1").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
  $("#resa2").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $(".resa3").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $("#newsletter_fancybox").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $("#presse_fancybox").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $("#partenaires_fancybox").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $("#contact_fancybox").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
   $("#contact2_fancybox").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
    $("#various_iframe").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
});

// Dock menu Lang
//======================================================================================================================
$(document).ready(function(){
	// Stack initialize
	var openspeed = 300;
	var closespeed = 300;
	$('.link_stack_lang').toggle(function(){
		var vertical = 0;
		var horizontal = 0;
		var $el=$(this);
		$el.next().children().each(function(){
			$(this).animate({top: '+' + vertical + 'px', left: horizontal + 'px'}, openspeed);
			vertical = vertical + 55;
			horizontal = 0;
		});
		$el.next().animate({top: '60px', left: '5px'}, openspeed).addClass('openStack')
		   .find('li a>img').animate({width: '36px', marginLeft: '0px'}, openspeed);
		$el.animate({paddingTop: '0px'});
	}, function(){
		//reverse above
		var $el=$(this);
		$el.next().removeClass('openStack').children('li').animate({top: '-80px', left: '5px'}, closespeed);
		$el.next().find('li a>img').animate({width: '28px', marginLeft: '0px'}, closespeed);
		$el.animate({paddingTop: '0px'});
	});
	
	// Stacks additional animation
	$('.stack_lang li a').hover(function(){
		$("span",this).animate({marginRight: '30px'});
	},function(){
		$("span",this).animate({marginRight: '0px'});
	});
});
