(function($) {
	$.fn.listScroller = function(options)
	{
		// Extend our default options with those provided.
		var opts = $.extend({}, $.fn.listScroller.defaults, options);

		return this.each(function() {
			$this = $(this);

			// build element specific options
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

			// ensure that there is a child actually found
			$scrollable = $this.children(o.scrollable);
			if ($scrollable.length > 0)
			{
				$this.css('overflow', 'hidden');
				var inactiveMargin = 100;

				var wrapperHeight = $this.height();

				var scrollableHeight = $this.children(o.scrollable).outerHeight() + 2*inactiveMargin;

				$this.mousemove(function(e){
					var wrapperOffset = $this.offset();

					// Scroll menu
					var top = (e.pageY -  wrapperOffset.top) * (scrollableHeight - wrapperHeight) / wrapperHeight  - inactiveMargin;

					// sanity check for M$ Browsers
					if (top < 0){
						top = 0;
					}

					$this.scrollTop(top);
				});
			}
		});
	};
	function debug($message){
		if (window.console && window.console.log)
		{
			window.console.log($message);
		}
	};

	$.fn.listScroller.defaults = {
		scrollable: '.scrollable'
	};
})(jQuery);
