(function($) {

	$.fn.akaiRotate = function(options) {
		
		$.fn.akaiRotate.defaults = {
			dynamic: true,
			duration: 8000
		};
		
		var o = $.extend({}, $.fn.akaiRotate.defaults, options);
		
		return this.each(function() {
			
			var current = $(this).children('li:first');
		
			function rotate() {
			
				current.parent().children().hide();
				
				current.show();
			
				if ( current.next().is('li') ) {
				
					current = current.next();
				
				} else {
				
					current = current.parent().children('li:first');
			
				}
			
			};
			
			function random() {
			
				var rand = Math.floor(Math.random()*(current.parent().length + 1));
				
				current.parent().children().hide();
				
				current.parent().children("li:eq(" + rand + ")").show();
			
			}
			
			if ( o.dynamic ) {
				
				rotate();
				
				setInterval( rotate, o.duration );
				
			} else {
			
				random();
				
			}
				
		});
	
	};
	
})(jQuery);