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

$(document).ready(function(){
  headline_count = $("div.headline2").size();
  headline_interval = setInterval(headline_rotate,10000);
    
  $('#scrollup_wrap').hover(function() {
    clearInterval(headline_interval);
  }, function() {
    headline_interval = setInterval(headline_rotate,10000);
  });
});
  
function headline_rotate(step) {
  headcount = headcount + 1;
  if (step) { var step = -1; } else { var step = 1; }
  current_headline = (old_headline + step) % headline_count;
  if (current_headline<0) { current_headline = (headline_count - 1); }
  if ($.browser.msie) {
    $("div.headline2:eq(" + old_headline + ")").css('top','5px').animate({top: -425},"slow", function() {
    $(this).css('top','420px');
    });
    $("div.headline2:eq(" + current_headline + ")").show().css('top','420px').animate({top: 5},"slow");
  } else {
    $("div.headline2:eq("+old_headline+")").fadeOut(400);
    $("div.headline2:eq("+current_headline+")").fadeIn(1000);
  }
  old_headline = current_headline;
  if (headcount > 25) { clearInterval(headline_interval); }
}
  
function headline_next() {
  headline_rotate();
}
  
function headline_prev() {
  headline_rotate('1');
}
