/**
 * @author Sebastian Felling
 */
var ticker_timerNextHandle;
var ticker_intShowItems = 15;
var ticker_intShowTime = 8000;
var ticker_intRotationSpeed = 800;
var ticker_intStep = 0;
var ticker_intCurrentIndex = -1;
var ticker_intLastIndex = 0;
var ticker_intCount;
	
function ticker_start() {
	// count tweets
	ticker_intCount = $('div.twitter_ticker ul li').size();
	
	// set max
	ticker_intShowItems = Math.min(ticker_intShowItems, ticker_intCount);
	
	// move in first item
	item_move_in(0);
}

function item_move_in(intNewIndex) {
	// hide last
	$('div.twitter_ticker ul li:eq(' + ticker_intLastIndex + ')').fadeOut('slow', function() { 
		// fadeout finished
		// move last item back to original position
		$('div.twitter_ticker ul li:eq(' + ticker_intLastIndex + ')').css('top', '40px');
		
		// display next
		$('div.twitter_ticker ul li:eq(' + intNewIndex + ')').show();
		
		// move in next
		$('div.twitter_ticker ul li:eq(' + intNewIndex + ')').animate({top: '0' }, ticker_intRotationSpeed);
	});	
	
	// save current index
	ticker_intCurrentIndex = intNewIndex;
	
	// goto next
	ticker_timerNextHandle = window.setTimeout('item_next()', ticker_intShowTime);
}

function item_next() {
	// save last index
	ticker_intLastIndex = ticker_intCurrentIndex;
	
	// get next index
	ticker_intCurrentIndex = (ticker_intCurrentIndex + 1) % ticker_intShowItems;
	
	// goto next
	item_move_in(ticker_intCurrentIndex);
}