/**
 * @compagny : Archriss, web agency & ingénérie
 * @website : www.archriss.fr
 * @author : Jean-Philippe RIVET
 * @contact : jprivet@archriss.com
 * @copyriht : Tous droits réservés
 * @purpose : ...
 */

/* *************************************** */
/* Event slide */
/* *************************************** */

(function($){
	// exemple pour "options" : {param3: 'param3', param4: 'param4'}
	$.fn.eventslide = function(options){
		// A la place de "$(this)" écrire ici "this", ce dernier étant déjà un objet jQuery.
		
		// Paramètres par defaut
		var o = {
			posLeftHide: '0',
			posLeftShow: '200'
		}
		
		// Maintient de la chainabilité avec "return"
		return this.each(function(){
			
			// Initialisation de this
			var $this = $(this);
			
			// Si les options existent...
			if(options){ 
				// Fusion aux paramètres par défaut
		        $.extend(o, options);
		    }
			
			var hide = function(){
				$this.addClass('hide').animate({ left: o.posLeftHide });
			}
		
			var show = function(){
				$this.removeClass('hide').animate({ left: o.posLeftShow });
			}
		
			var toggleElem = $this.find('.part_hide');
			var buttonElem = $this.find('.part_show, .close');
			
			buttonElem.click(function(e){
				e.preventDefault();
				if($this.hasClass('hide')) {
					show();					
				} else {
					hide();					
				}
			});
			
		});
		
	};
})(jQuery);

