var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;
var scrollspeed = 2000;
var pauseduration = 30000;

$(document).ready(function(){
  headline_count = $("div.scrollheadline").size();
  $("div.scrollheadline:eq("+current_headline+")").css('top', '0px');
  
  headline_interval = setInterval(headline_rotate,pauseduration); 
  $('#scrollup').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,pauseduration); 
    headline_rotate();
  });
});
function headline_rotate() {
  current_headline = (old_headline + 1) % headline_count; 
  $("div.scrollheadline:eq(" + old_headline + ")")
    .animate({top: dispheight},scrollspeed, function() {
      $(this).css('top', hiddenheight);
    });
  $("div.scrollheadline:eq(" + current_headline + ")")
    .animate({top: 0},scrollspeed);  
  old_headline = current_headline;
}

