$(document).ready(function(){
	setInterval('swapFade()',wait);
});

// this array consists of the id attributes of the divs we wish to alternate between
var divs_to_fade;

// the starting index in the above array.
var i=0;
// the ending index in the divs_to_fade array - populated in populateDivsToFade function
var iMax=0;

// the number of milliseconds between swaps. Default is five seconds.
var wait=5000;

function populateDivsToFade(strIDs){
	divs_to_fade=strIDs.split(',');
	iMax=divs_to_fade.length;
	$('div.newsstory').not('.first').addClass('fader');
}

// the function that performs the fade
function swapFade() {
	$('#news'+divs_to_fade[i]).fadeOut(1000);
	i++;
	if (i==iMax) i=0;
	$('#news'+divs_to_fade[i]).fadeIn(1000);
}
