﻿$(window).load(function() {
    var InfiniteRotator =
	    {
	        init: function() {
	            //initial fade-in time (in milliseconds)
	            var initialFadeIn = 0; //1000;

	            //interval between items (in milliseconds)
	            var itemInterval = 6000;

	            //cross-fade time (in milliseconds)
	            var fadeTime = 1000; //2500;

	            //count number of items
	            var numberOfItems = $('.boxhomeoilist').children().length;

	            //set current item
	            var currentItem = 0;

	            //show first item
	            $('.boxhomeoilist').children().eq(currentItem).show(); //fadeIn(initialFadeIn);

	            //loop through the items		
	            var infiniteLoop = setInterval(function() {
	                $('.boxhomeoilist').children().eq(currentItem).hide(); //fadeOut(fadeTime);

	                if (currentItem == numberOfItems - 1) {
	                    currentItem = 0;
	                } else {
	                    currentItem++;
	                }
	                $('.boxhomeoilist').children().eq(currentItem).fadeIn(fadeTime); //fadeIn(fadeTime);

	            }, itemInterval);
	        }
	    };

    InfiniteRotator.init();
});
