const PARENT_SELECTOR = 'div.conseil_box'; 
//is a box hovered ?
var activeBoxHovered = false;

//if parent exist

if (jQuery(PARENT_SELECTOR).length > 0)
{
	new PeriodicalExecuter(function(timer)
		{
			var allBoxes = $$(PARENT_SELECTOR + ' ul li');
	
			// find index of the current active box
			var currenttestedPosition = 0;
			var activeBoxPosition = null;
			allBoxes.each(function (box)
				{
					if(box.className == 'active')
					{
						activeBoxPosition = currenttestedPosition; 
						return; 
					}
					currenttestedPosition++;
				}
			);
			var countBoxes = ++currenttestedPosition;
			//do not change if hover
			if(!activeBoxHovered)
			{
				allBoxes[activeBoxPosition].className = "";
				allBoxes[++activeBoxPosition%countBoxes].className = "active";
			}
		}, 3
	);
	
	jQuery(PARENT_SELECTOR).hover(
			function () {
			activeBoxHovered = true;
		},
		function () {
			activeBoxHovered = false;
		}
	);
}
