var reviewstory_count;
var reviewstory_interval;
var old_reviewstory = 0;
var current_reviewstory=0;

$(document).ready(function(){
  reviewstory_count = $("div.reviewstory").size();
  $("div.reviewstory:eq("+current_reviewstory+")").css('top','5px');
  
  reviewstory_interval = setInterval(reviewstory_rotate,8000); //time in milliseconds
  $('#review').hover(function() {
    clearInterval(reviewstory_interval);
  }, function() {
    reviewstory_interval = setInterval(reviewstory_rotate,8000); //time in milliseconds
    reviewstory_rotate();
  });
});

function reviewstory_rotate() {
  current_reviewstory = (old_reviewstory + 1) % reviewstory_count; //remainder will always equal old_headline until it reaches headline_count - at which point it becomes zero. clock arithmetic
  $("div.reviewstory:eq(" + old_reviewstory + ")").animate({top: -205},"slow", function() {
    $(this).css('top','210px');
    });
  $("div.reviewstory:eq(" + current_reviewstory + ")").show().animate({top: 5},"slow");  
  old_reviewstory = current_reviewstory;
}


