
(function($) {
//Définition du plugin
    $.fn.moduleactu3 = function(options) {
        // définition des paramètres par défaut
        var defaults = {
            nbr: 0,
			actuelle: 1
        };
        // mélange des paramètres fournis et des paramètres par défaut
        var opts = $.extend(defaults, options);
		
		function createNavigation () {
			var fleches = '';
			fleches += '<div id="fleches">';
			fleches += '	<img src="images/moduleactu3/fleche-gauche.png" alt="" id="flecheGauche" />';
			fleches += '	<img src="images/moduleactu3/fleche-droite.png" alt="" id="flecheDroite" />';
			fleches += '</div>';
			$(this).after(fleches);
		}
		$(this).find('#voile').each(createNavigation);
		
		
		// function style () {
			var width = 679 * opts.nbr;
			$(this).find('ul').css({width: width+'px'});
		// }
		// $(this).each(style);
		
		
		
		
		$(this).find('#fleches').hover(
			function () {
				$(this).css({cursor: 'pointer'});
			}
			,
			function () {
				$(this).css({cursor: 'auto'});
			}
		);
		
		
		function defile () {
			var left = 0 - ((opts.actuelle - 1) * 679);
			var top = 0 - ((opts.actuelle - 1) * 61);
			
			$('#moduleActu3').find('ul').animate({left: left+'px'}, 500);
			$('#moduleActu3').find('ol').animate({top: top+'px'}, 500);
		}
		
		$(this).find('#flecheGauche').click(
			function () {
				if (opts.actuelle > 1) opts.actuelle--;
				$(this).each(defile);
			}
		);
		
		$(this).find('#flecheDroite').click(
			function () {
				if (opts.actuelle < opts.nbr) opts.actuelle++;
				$(this).each(defile);
			}
		);
		
		// interface fluide
        return $(this);
    };   
})(jQuery);
