// JavaScript Document

/* --- showSlider --- */
/* ------------------ */
/* - Auteur : NaruT - */

(function($)
{
	$.fn.showSlider = function(params)
	{
		function prec()
		{
			var temp = obj_this.find(".showPanel[title=sel]");
				
			temp.fadeOut(1000, function()
			{
				if(jQuery.param(temp.next()) == "")
				{
					temp = obj_this.children(".showPanel:first");
					temp.attr("title", "sel").fadeIn(1000);
				}
				else
				{
					temp.next().attr("title", "sel").fadeIn(1000);
				}
			}).removeAttr("title");
		}
		
		function suiv()
		{
			var temp = obj_this.find(".showPanel[title=sel]");
				
			temp.fadeOut(1000, function()
			{
				if(jQuery.param(temp.prev()) == "")
				{
					temp = obj_this.children(".showPanel:last");
					temp.attr("title", "sel").fadeIn(1000);
				}
				else
				{
					temp.prev().attr("title", "sel").fadeIn(1000);
				}
			}).removeAttr("title");
		}
		
		function autoSlide()
		{
			var inte = setTimeout(function()
			{
				prec();
				autoSlide();
				clearTimeout(inte);
			}, opts.speed);
		}
		
		var settings = 
		{ 
			navID:"aucun-showNav-de-present",
			speed:3000,
			auto:true 
		};
		
		var opts = jQuery.extend(settings, params);
		
		var obj_this = $(this);
		
		obj_this.addClass("showSlider");
		
		obj_this.find(".showPanel:last").attr("title", "sel").show();
		
		if(jQuery("#"+opts.navID+" .showNavS").size() > 0)
		{
			jQuery("#"+opts.navID+" .showNavS").click(function(){ prec(); });
		}
		
		if(jQuery("#"+opts.navID+" .showNavP").size() > 0)
		{
			jQuery("#"+opts.navID+" .showNavP").click(function(){ suiv(); });
		}
		
		if(opts.auto)
		{
			obj_this.ready(function()
			{
				autoSlide();
			});
		}
		
		return $(this);
	};
})(jQuery);
