jQuery.fn.marquee = function(options) {
  if (options)
  {
    settings = jQuery.extend({
      speed: 5000,
      animation: 'hide',
      parent_selector: '',
      matching_children: '*',
      show: 1
    }, options);
  }

  this.each(function() {
    var children = jQuery(this).children(settings.matching_children);

    var height     = 0;
    var max_height = 0;

    children.each(function(index) {
      if (index < settings.show)
      {
        height += jQuery(this).height();
      }

      max_height = max_height < jQuery(this).height() ? jQuery(this).height() : max_height;
    });

    if (max_height > height)
    {
      height = max_height;
    }

    // Restrict container's size and viewport area
    jQuery(this).css({ height: height + 'px', overflow: 'hidden' });

    setInterval("jQuery('" + settings.parent_selector + " " + settings.matching_children + ":eq(0)')." + settings.animation + "(750, function() { jQuery(this).appendTo('" + settings.parent_selector + "'); jQuery(this).show(); });", settings.speed);
  });

  return this;
};
