var ticker = {
	timer:false, i:0, ct:0, t:5000,
	init : function() {
		// initialize
		$('#newsHolder li:not(:first)').hide();
		ticker.start();
		ticker.ct = $('#newsHolder li').size();
		
		// bind controls
		$('#prev').click(function() {
			ticker.tick(-1);
		});
		$('#next').click(function(){
			ticker.tick();
		});
		
		// bind auto stop/start
		$('#theNewNewsTicker').hover(
			function() {
				ticker.stop();
			},
			function() {
				ticker.start();
			}
		);
	},
	stop : function() {
		clearTimeout(ticker.timer);
	},
	start : function() {
		ticker.stop();
		ticker.timer = setTimeout('ticker.tick()', ticker.t);
	},
	tick : function(steps) {
		ticker.stop();
		if(!steps) steps = 1;

		// hide current
		$('#newsHolder li:eq(' + ticker.i + ')').hide();

		// Increment the index
		ticker.i = (ticker.i + ticker.ct + steps) % ticker.ct;
		
		// Show the next one
		if($.browser.msie && $.browser.version == '6.0') { 
			$('#viewall').css({position:'absolute', left:'768px', top:'410px'});
			$('#newsHolder li:eq(' + ticker.i + ')').animate({height:'show', width:'show'}, 500);
		} else {
			$('#newsHolder li:eq(' + ticker.i + ')').fadeIn(500);
		}
	}
}

$(function() {
	ticker.init();
});