var headline_count;
var headline_interval;
var current_headline = 0;
var old_headline = 0;
var delay = 1000

$(document).ready(function(){
  headline_count = $("div.scroller-item").size();
  //console.log("There are "+headline_count+" items");
  //$("div.scroller-item:eq(" + current_headline + ")").css("left", '0px');
  $("div.scroller-item:eq(" + current_headline + ")").fadeIn(500);
  headline_interval = setInterval(headline_rotate,delay);
});

function headline_rotate() {

	current_headline = (old_headline + 1) % headline_count;
	//console.log("Rotating: " + current_headline);
	/*
	$("div.scroller-item:eq(" + old_headline + ")").animate({left: -500},"slow",function() {$(this).css('left', '500px');} )	
	$("div.scroller-item:eq(" + current_headline + ")").animate({left: 0},"slow")	
	/**/
	$("div.scroller-item:eq(" + old_headline + ")").fadeOut(500, function() {
	  $("div.scroller-item:eq(" + current_headline + ")").fadeIn(500);
	});
	old_headline = current_headline;
	
}





