(function($) { // Hubsoft.com && SebringCreative.com - Dual licensed under the MIT and GPL licenses.
	$.fn.dumbCrossFade = function(settings) {
		var config = {'index':0,'showTime':5000,'transitionTime':1000,'doHoverPause':true, 'maxZIndex':100,'startTime':0};
		var timeOut = null;
		var itemArray = [];

		function cancelCrossFade() {
			if (timeOut !== null) { window.clearTimeout(timeOut); timeOut = null; }
		}
		function doCrossFade() {
			timeOut = window.setTimeout(function() {
				var currentIndex = config.index;
				var nextIndex = (config.index >= itemArray.length - 1) ? 0 : config.index + 1;
				itemArray[currentIndex].css('z-index',(config.maxZIndex-1)+'');
				itemArray[nextIndex].css('z-index',config.maxZIndex+'');
				itemArray[nextIndex].fadeIn(config.transitionTime, function() {
					itemArray[currentIndex].hide();
				});
				config.index = nextIndex;
				doCrossFade();
			},config.showTime);
		}

		if (settings) $.extend(config, settings);

		this.each(function() {
			(itemArray.length === config.index) ? $(this).show() : $(this).hide();
			if (config.doHoverPause) { $(this).hover(
				function() {
					cancelCrossFade();
				},
				function() {
					cancelCrossFade();
					doCrossFade();
				}
			); }
			itemArray[itemArray.length] = $(this);
		});

		doCrossFade();

		return this;
	};
})(jQuery);


$(function() {
	// can use options, the values listed are by default
	// 'index' is what item to start from (zero based)
	// 'showTime' is how long to show an item,
	// 'transitionTime' is how long the fade takes,
	// 'doHoverPause' is to turn on/off (true/false) the hover pause behavior
	// 'maxZIndex' is the z-index of the element being faded into view. The faded out is maxZIndex - 1.
	var options = { 'index':0, 'showTime':6000, 'transitionTime':2000, 'doHoverPause':false, 'maxZIndex':100 };
	$('.dumbCrossFade .dumbItem').dumbCrossFade(options);
});



