$(document).ready(function() {
	/*
	$('A[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});
	*/
});

var iFbCurrentIndex = -1;
var iFbCount = 0;
var oFbItems = undefined
var iDelayBetweenFb = 3000;

function showNextFbItem() {
	incrementFbIndex();
	fadeOutAnyShownFbItem();
	showFbItem();	
}

	function incrementFbIndex() {
		iFbCurrentIndex = iFbCurrentIndex + 1;
		if (iFbCurrentIndex >= iFbCount) {
			iFbCurrentIndex = 0;
		}
	}
	
	function fadeOutAnyShownFbItem() {
		var oVisibleItem = $('.featuredbiosrotator_item:visible');
		if (oVisibleItem.length > 0) {
			oVisibleItem.fadeOut(150);
		}
	}
	
	function showFbItem() {
		var oNewItem = oFbItems.get(iFbCurrentIndex);
		if (oNewItem !== undefined) {
			$(oNewItem).fadeIn(1000, function() {
				setTimeout(showNextFbItem, iDelayBetweenFb);
			});
		}
	}

function initializeFb() {
	oFbItems = $('.featuredbiosrotator_item');
	iFbCount = oFbItems.length;
	if (iFbCount > 0) {
		oFbItems.hide();
		showNextFbItem();
	}
}


