// feed on home page
var speed = 4000;
var waitTime = 2000;

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

$(document).ready(function(){
    headline_count = $("#feed a").size();                   //get size of the main container
    $("#feed a").css('left',$("#feed").css("width"));       //move elements out of the container
    $("#feed a").css('width',$("#feed").css("width"));      //has to be set - so it doesn't draw smudge
    $("#feed a:eq("+current_headline+")").css('left','0');  //set first element inside container

    headline_interval = setInterval(headline_rotate, (waitTime + speed));

    $('#feed').hover(function() {
        clearInterval(headline_interval);
    }, function() {
        headline_interval = setInterval(headline_rotate, (waitTime + speed));
    });
});

function headline_rotate() {
    current_headline = (old_headline + 1) % headline_count;

    $("#feed a:eq(" + old_headline + ")").animate({left: "-"+$("#feed").css("width")},speed);
    $("#feed a:eq(" + current_headline + ")").css('left',$("#feed").css("width"));
    $("#feed a:eq(" + current_headline + ")").animate({left: 0},speed);
    old_headline = current_headline;
}