
(function($) {
//Définition du plugin
    $.fn.defileMaitrise = function(options) {
        // définition des paramètres par défaut
        var defaults = {
			width: 900,
			nbDecalMax: 2
        };
        // mélange des paramètres fournis et des paramètres par défaut
        var opts = $.extend(defaults, options);
		var objet = "#"+$(this).attr('id');
		
		var decalage = 0;
		var nbDecal = 1;
		
		$(this).find('.flecheGauche').hover(
			function() {
				if (nbDecal > 1) $(this).css({cursor: 'pointer'});
				else $(this).css({cursor: 'auto'});
			}
			,
			function() {
				if (nbDecal > 1) $(this).css({cursor: 'auto'});
			}
		);
		$(this).find('.flecheDroite').hover(
			function() {
				if (nbDecal < opts.nbDecalMax) $(this).css({cursor: 'pointer'});
				else $(this).css({cursor: 'auto'});
			}
			,
			function() {
				if (nbDecal < opts.nbDecalMax) $(this).css({cursor: 'auto'});
			}
		);
		
		
		$(this).find('.flecheGauche').click(
			function() {
				if (nbDecal > 1) {
					decalage = decalage + opts.width;
					$(objet).find('ul').animate({left: decalage+'px'}, 500);
					nbDecal--;
				}
			}
		);
		
		$(this).find('.flecheDroite').click(
			function() {
				if (nbDecal < opts.nbDecalMax) {
					decalage = decalage - opts.width;
					$(objet).find('ul').animate({left: decalage+'px'}, 500);
					nbDecal++;
				}
			}
		);
		
		
		
		// interface fluide
        return $(this);
    };   
})(jQuery);
