$.fn.actusTicker = function(delay)
{
	return this.each(
		function()
		{
			if(this.nodeName.toLowerCase()!= "ul") return;
			delay = delay || 4000;
			var self = this;
			self.items = $("li", self);
			self.items.not(":lt(4)").hide().end();
			self.currentitem = 0;
			$("#actualites").append('<ol id="actu_control"></ol>');
			for ( var i = 0; i < self.items.size(); i++) {
				if (i < 4)
					$(document.createElement("li")).attr('id', 'actu' + (i + 1)).attr('class', 'current').html(i + 1).appendTo($("#actu_control"));
				else
				$(document.createElement("li")).attr('id', 'actu' + (i + 1)).html(i + 1).appendTo($("#actu_control"));
			};
			var doTick = function()
			{
				$.actusticker(self);
			}
			setInterval(doTick,delay);
		}
	)
	.hover(
		function()
		{
			this.pause = true;
		},
		function()
		{
			this.pause = false;
		}
	);
}
$.actusticker = function(el)
{
	if(el.pause) return;
	$(el.items[el.currentitem]).hide("slow",
		function()
		{
			$(this).appendTo("#actus");
			$(el.items[(el.currentitem+4) % el.items.size()]).fadeIn("slow");
			el.currentitem = ++el.currentitem % (el.items.size());
			first_aff = el.currentitem;
			if (first_aff == 0)
				first_aff = el.items.size();
			$("#actu" + first_aff).toggleClass("current");
			last_aff = (el.currentitem+4) % el.items.size();
			if (last_aff == 0)
				last_aff = el.items.size();
			$("#actu" + last_aff).toggleClass("current");
		}
	);
}
