(function($) {
	$.fn.rotator = function(options) {

		var defaults = {
			ms : 2000,
			n : 1			
		};
		var options = $.extend(defaults, options);
		var run = true;

		return this.each(function(index) {
			var $this = $(this);
			var initialHeight = 0;
			$this.children().filter(":lt(" + options.n + ")").each(
					function(index, item) {
						initialHeight += $(item).height();
					});
			$this.height(initialHeight);
			setInterval(function() {
				var childHeight = $this.children().filter(":first-child")
						.height();
				var animParams = {
					scrollTop : (childHeight) + "px"
				};
				$this.mouseover(function() {
					run = false;
				});
				$this.mouseout(function() {
					run = true;
				});
				if (run) {
					$this.animate(animParams, 800, function() {
						var first = $this.find("li:first");
						var last = $this.find("li:last");
						first.insertAfter(last);
						last.show();
						$this.scrollTop(0);
						$this.css("overflow", "hidden");
					});
				}
			}, options.ms);
		});
	}
})(jQuery);
