
// Cycle through the homepage banners
$('#homepage-banner').cycle({
	fx : 'fade',
	timeout: 4000,
	speedIn:  800, 
	speedOut: 300,
	nowrap : 0
});

// News ticker
// First, we hide all news items:
$('#home-news li').hide();

// Then, we define the function that animates a news item into view
function showNewsItem(iCurrent, iPrevious) {
	// Show current item in the list:
	if(typeof(iPrevious) != 'undefined') {
		$('#home-news li:eq('+ iPrevious +')').fadeOut(200, function() {
			$('#home-news li:eq('+ iCurrent +')').fadeIn(500);
		});
	} else {
		$('#home-news li:eq('+ iCurrent +')').fadeIn(500);
	}
	
	// Define the javascript to be executed in the next loop of the animation
	var js = '';
	if((iCurrent + 1) == $('#home-news li').length) {
		js = 'showNewsItem(0, '+ iCurrent +')';
	} else {
		js = 'showNewsItem('+ (iCurrent + 1) +', '+ iCurrent +')';
	}
	
	// Set the interval, with the javascript:
	setTimeout(js, 6000);
}

// Start animating
showNewsItem(0);
