function rotate_grants() {
	
	var $next = $('div.grant_detail:visible').next('div.grant_detail');
	if ($next.length == false) { // if we've reached the end, start over
		$next = $('div.grant_detail:first');
	}
	
	// update the main body text to show the clicked/selected item
	$('li.highlight').removeClass('highlight');
	$('a.trigger[href=#'+ $next.attr('id') +']').parent().addClass('highlight');
	
	// transition
	$('div.grant_detail:visible').fadeOut('nornal',function(){
		$next.fadeIn('fast', function(){
			timer = setTimeout('rotate_grants()', rotate_timer); // and do it again									
		});
	});

}

$().ready(function(){
	
	// activate sIFR headlines in the sidebar
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:"h5", sFlashSrc:"/albertina.swf", sColor:"#669900", sBgColor:"#EBF5D6", nPaddingTop:0, nPaddingBottom:0, sWmode:"opaque"}));
	};
	
	// pick a random grant_detail to start with
	var rand = Math.floor(Math.random()*($('div.grant_detail').length))
	$('div.grant_detail').hide().eq(rand).show();
	$('a.trigger[href=#'+ $('div.grant_detail:visible').attr('id') +']').parent().addClass('highlight');

	// start the timer
	var timer = setTimeout('rotate_grants()', 10000);
	
	// when a trigger is clicked (jump to specific, next, or last)
	$('a.trigger,a.prevArrow,a.nextArrow').click(function(){
		if ( $(this).parent().hasClass('highlight') ) return false;	// don't fade in/out if this is already visible
		clearTimeout(timer);	// swith to "manual" - clear the timer
		var ele = $(this).attr('href');
		$('li.highlight').removeClass('highlight');
		$('a.trigger[href='+ele+']').parent().addClass('highlight');
		$('div.grant_detail:visible').fadeOut('nornal',function(){
			$(ele).fadeIn('fast');	
		});
		return false;
	});
	
});