/**
 * A primitive ticker. Endlessly rotates the items in a list.
 *
 * Usage: $('ul').ticker();
 *
 * HTML: Any list (ul or ol) with a's inside.
 */
(function($) {
	$.fn.ticker = function() {
		return this.each(function() {
			var children = $(this).find("li a");
			var total    = children.length;
			var current  = 0;

			children.hide();

			function next() {
				$(children[current]).fadeOut("slow", function() {
					$(children[current]).parent().css('z-index', 0);

					if(++current >= total)
						current = 0;
	
					$(children[current]).parent().css('z-index', 100); // adjust z-index so this appears at the top of the stack
					$(children[current]).fadeIn("slow");
				});
			}

			$(children[current]).parent().css('z-index', 100);
			$(children[current]).fadeIn("slow");

			window.setInterval(next, 6000); // 6 second delay
		});
	};
})(jQuery);
