jQuery.animation = {
	currentL : '#visuel1',
	currentR : '#txt1',
	bool : 1,
	leftMin:-350,
	leftMax:60,
	rightMin:350,
	rightMax:750,
	callback:150,
	returnCall:400,
	midCallBack:20
};

(function($){
$.fn.animation = function(options){
		
		var defaults = {

		 };
		 
		var opts = $.extend(defaults, options);
		
		return this.each(function()
			{	
				$.animation.leftMax = opts.leftMax;
				$.animation.rightMin = opts.rightMin;
				
				getLeft();
			//	getRight();
				
				if($.animation.currentL == opts.currentL) return;
				else{
					if($.animation.bool == 1){
					$.animation.bool = 0;
					hide($.animation.currentL,$.animation.currentR);
					}else return;
				}
			}
		);
		
		function getLeft(){
			var x = parseInt($($.animation.currentL).css('width')) + parseInt($($.animation.currentL).css('left'));
			$.animation.leftMin = '-'+x+'px';
			//alert ($.animation.leftMin);
		};

		function getRight(){
			var x = parseInt($($.animation.currentR).css('left'));
			x = 676 - x;
			$.animation.rightMax = x + 676 + 50+'px';
			//alert($.animation.rightMax);
		};
		
		function hide(elm1,elm2){
			$(elm1).animate({left:$.animation.leftMin},$.animation.callback,function() {
				$.animation.currentL = opts.currentL;
				setTimeout(function(){show(opts.currentL,$.animation.leftMax)},$.animation.midCallBack);
			
			});
			$(elm2).animate({left:$.animation.rightMax},$.animation.callback,function() {
				$.animation.currentR = opts.currentR;
				setTimeout(function(){show(opts.currentR,$.animation.rightMin)},$.animation.midCallBack);
			
			});
		};
		
		function show(elm,x){
			$(elm).animate({left:x},$.animation.returnCall,function(){$.animation.bool = 1;});
		};
};
})(jQuery);




