// 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(id)
		{
			//initial fade-in time (in milliseconds)
			var initialFadeIn = 5000;                			
			//interval between items (in milliseconds)
			var itemInterval = 5000;                 			
			//cross-fade time (in milliseconds)
			var fadeTime = 2500;                     			
			//count number of items
			var numberOfItems = $(id).length;
			//set current item
			var currentItem = 0;                           
			//show first item
			$(id).eq(currentItem).fadeIn(initialFadeIn);
			//loop through the items		
			var infiniteLoop = setInterval(function(){
				$(id).eq(currentItem).fadeOut(fadeTime);
				if(currentItem == numberOfItems -1){
					currentItem = 0;
				}else{
					currentItem++;
				}
				$(id).eq(currentItem).fadeIn(fadeTime); 
			}, itemInterval);	
		}	
	};   
                                                         
	InfiniteRotator.init('.rotating-item');	
	InfiniteRotator.init('.rotating-item01');
	InfiniteRotator.init('.rotating-item02');
	InfiniteRotator.init('.rotating-item03');
	InfiniteRotator.init('.rotating-item04');
	InfiniteRotator.init('.rotating-item05');
	InfiniteRotator.init('.rotating-item06');
	
});
