var current = 0;
var interval = 0;
var timeoutId;
var mainItems = new Array();

function NextItem()
{
	// need to delete the current timer or it will keep firing out of sync
	clearTimeout(timeoutId);
	
	var currentFullId = "main_" + mainItems[current]["id"];
	
	//$('#' + currentFullId).hide(); // comment this out of using the fadeOut on line 75
	//$('#' + currentFullId).fadeOut("fast");
	//$('#' + currentFullId).hide();
	
	if(mainItems[current]["isFlash"])
	{
		// its flash so hide it straight away or the next one's fade in wont be seen
		$('#' + currentFullId).hide();
	}
	else
	{
		// not flash, so fade out normally
		$('#' + currentFullId).fadeOut(1500);
	}
	//$('#' + currentFullId).hide();
	
	// increment the current counter, if at the end of the array, start at beginning again
	if(current == mainItems.length -1)
	{
		current = 0;
	}
	else
	{
		current++;
	}
	
	
	var currentFullId = "main_" + mainItems[current]["id"];
	
	//$('#' + currentFullId).css("opacity", 0);
	//$('#' + currentFullId).show();
	//$('#' + currentFullId).fadeTo(1500, 1);
	$('#' + currentFullId).fadeIn(1500);
	
	// check if the current item has an interval override, if so use it
	if(mainItems[current]["intervalOverride"] > 0)
	{
		interval = mainItems[current]["intervalOverride"];
	}
	else
	{
		interval = universalInterval;
	}
	timeoutId = setInterval("NextItem()", interval);
}