Scroller = {
    x: null,
    y: null,
    
    init: function(obj) {
        obj = $(obj);
        
        var outer = $(obj.find(".Text")[0]);
        var inner = $($(outer).find(".Inner")[0]);
        var bar = $(obj.find(".Scroller")[0]);
        var button = $(obj.find(".Scroller span")[0]);
        
        if (!outer || !inner) return;
		var textContainerHeight = outer.outerHeight();
		var textHeight = inner.outerHeight();
		var barHeight = bar.outerHeight();
        var buttonHeight = button.outerHeight();

		var maxOffsetTop = textHeight - textContainerHeight;
		var maxButtonTop = barHeight - buttonHeight;

        button.mousedown(function(e) {
			var clickedOnX = e.pageX;
			var clickedOnY = e.pageY;
			
			var iniTextTop = parseInt(inner.css("top"));
			var iniButtonTop = parseInt(button.css("top"));
			
			var f = function(e) {
				Scroller.clearDocumentSelection();
				
				var dY = iniButtonTop + e.pageY - clickedOnY;          // pixels that the mouse moved since the start of the scrollbar
				
				if (dY > maxButtonTop) dY = maxButtonTop;
				if (dY < 0) dY = 0;

				var y = dY * maxOffsetTop / maxButtonTop;
				y = (y > 0) ? y : 0;
				
				inner.css("top", Math.round(-y) + "px");
				button.css("top", Math.round(dY) + "px");
				return true;
			}

			var g = function(e) {
			    $(document).unbind("mousemove");
			    $(document).unbind("mouseup");
			}
            
            $(document).mousemove(f);
            $(document).mouseup(g);
		});
    },
    
    /* <ClearSealections> */ 
	clearDocumentSelection: function() {
		if (document.selection)	{
			if (document.selection.clear) document.selection.clear();
			else if (document.selection.empty) document.selection.empty();
		} else {
			if (window.getSelection) {
				try{
					window.getSelection().collapse();
					window.getSelection().removeAllRanges();
				} catch(e) { };
			}
		}
	}
	/* </ClearSealections> */ 
}
