/*
 Merci (thanks) pour le script original de Sam Collett (http://www.texotela.co.uk)
*/

jQuery.fn.diapo = function(delai)
{
	return this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			delai = delai || 4000;
			var self = this;
			self.items = jQuery("li", self);
			// hide all items (except first one)
			self.items.not(":eq(0)").hide().end();
			// current item
			self.currentitem = 0;
			var change = function()
			{
				jQuery.diapo(self);
			}
			setInterval(change,delai);
		}
	)
	.addClass("diapo")

}

jQuery.diapo = function(el)
{
	// hide current item
	jQuery(el.items[el.currentitem]).fadeOut("slow",
		function()
		{
			jQuery(this).hide();
			// move to next item and show
			el.currentitem = ++el.currentitem % (el.items.size());
			jQuery(el.items[el.currentitem]).fadeIn("slow");
		}
	);
}
