$(document).ready(function(){
		
		$('#platinum-sponsors').rotateListItems();
});

(function($){
	$.fn.rotateListItems = function(config){
		
		//Configuration Settings
		var defaults = {
			fadeSpeed:600, 				//How fast the photos fade
			interval:5000				//Autoplay interval
		}
		config = $.extend(defaults, config);

		//Initialize
		return this.each(function(){
			
			var container = $(this);
			var quotes = new Object();
			var count = 0;
			var current = 1;
			
			//Put some ID's on the items and hide them
			container.children('li').each(function(){
				count++;
				$(this).attr('id', 'item_'+count).hide();
			});
			
			//Pick a random item to be visible first
			current = Math.floor((Math.random() * count) + 1);
			$('#item_' + current).show();
			
			//Start autoplay
			if(count > 1){
				window.setInterval(showNext, config.interval);
			}

			//Method to show the next item
			function showNext(){				
				var next = current+1;
				if(next > count){ next = 1; }
				$('#item_'+current).fadeOut(config.fadeSpeed, function(){
					$('#item_'+next).fadeIn(config.fadeSpeed);
				});
				current = next;
			}
								
		});
	}
})(jQuery);
