function imageRota(imageList, imageDuration, fadeDuration)
{
	// Hide images first.
	imageList = $(imageList);
	var items = imageList.find('li');
	
	if (items.length == 1)
	{
		items.addClass('rota-active');
		items.show();
		return;
	}
	else
	{
		items.hide();
	}
	
	// Now start the rotation.
	var startItem = items.filter('.start-image');
	startItem = startItem.length != 0 ? startItem : items.filter(':first-child');
	startItem.addClass('rota-active');
	startItem.show();
	queue(startItem, imageDuration, fadeDuration);
}

function rotate(currentItem, imageDuration, fadeDuration)
{
	var nextItem = currentItem.next();
	nextItem = nextItem.length != 0 ? nextItem : currentItem.parent().children('li:first-child');
	currentItem.removeClass('rota-active');
	nextItem.addClass('rota-active');
	nextItem.fadeIn(fadeDuration, function()
	{
		currentItem.hide();
		queue(nextItem, imageDuration, fadeDuration);
	});
}

function queue(item, imageDuration, fadeDuration)
{
	setTimeout(function()
	{
		rotate(item, imageDuration, fadeDuration);
	}, imageDuration);
}
