function cycleMarquee(speed) {
  speed = speed === undefined ? 30 : speed;
  
  var marquee = $('#marquee');
  marquee.css({
    position: 'relative',
    overflow: 'hidden',
    height: marquee.height() + 'px'
  });
  marquee.children().css('position', 'relative');
  $(marquee.children().get(0)).clone().appendTo(marquee);
  
  var scroll = function() {
    $('#marquee').children().each(function(i) {
      var topNum = $(this).css('top').substr(0, $(this).css('top').length - 2);
      var top = topNum == 'au' ? 0 : Number(topNum);
      if (i == 0 && top == -($(this).height() + 2)) {
        $($('#marquee').children().get(1)).clone().css('top', '0px').appendTo($('#marquee'));
        $(this).remove();
        $('#marquee').children().css('top', '0px');
      } else {
        $(this).css('top', (top - 1) + 'px');
      }
    });
  };
  
  var scroll_timer = setInterval(scroll, speed);
  marquee.hover(function() {
    clearInterval(scroll_timer);
  }, function() {
    scroll_timer = setInterval(scroll, speed);
  });
}

$(function() {
  cycleMarquee(60);
});