$(function() {
  var ticker = $("#ticker");
  ticker.css("overflow", "hidden");

  //animator function
  function animator(currentItem) {
    var distance = currentItem.height() + 20; // add on the padding
    duration = ((distance + parseInt(currentItem.css("marginTop"))) / 0.02);
    
    currentItem.animate({ marginTop: -distance }, duration, "linear", function() {
      currentItem.appendTo(currentItem.parent()).css("marginTop", 0);
      animator(currentItem.parent().children(":first"));
    });
  }

  animator(ticker.children(":first"));

  ticker.mouseenter(function() {
    ticker.children().stop();
  });
  ticker.mouseleave(function() {
    animator(ticker.children(":first"));
  });
});


