// Copyright (c) 2010 TrendMedia Technologies, Inc., Brian McNitt. 
// All rights reserved.
//
// Released under the GPL license
// http://www.opensource.org/licenses/gpl-license.php
//
// **********************************************************************
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
// **********************************************************************

$(window).load(function() {	//start after HTML, images have loaded

	var InfiniteRotator = 
	{
		init: function()
		{
			var initialFadeIn = 4000;//initial fade-in time (in milliseconds)
			var itemInterval = 4500;//interval between items (in milliseconds)
			var fadeTime = 4500;//cross-fade time (in milliseconds)
			var numberOfItems = $('.rotate-item').length;//count number of items
			var currentItem = 0;//set current item
			$('.rotate-item').eq(currentItem).fadeIn(initialFadeIn);//show first item
			//loop through the items		
			var infiniteLoop = setInterval(function()
			{
				$('.rotate-item').eq(currentItem).fadeOut(fadeTime);

				if(currentItem == numberOfItems -1)
				{currentItem = 0;}
				else
				{currentItem++;}
				$('.rotate-item').eq(currentItem).fadeIn(fadeTime);
			}, itemInterval);	
		}	
	};
	InfiniteRotator.init();
});
