	function Scrollbar(id, scrollArea, cursor, cursorExt, scrollBox, scrollContent, regularStep, curMin, curPad){
	
		this.margin = 0;
		this.scrollTime = 75;
		this.scrollWTime = 250;
		
		this.id = id;
		this.scrollArea = document.getElementById (scrollArea);
		this.cursor = document.getElementById (cursor);
		this.cursorExt = document.getElementById (cursorExt);
		this.scrollBox = document.getElementById (scrollBox);
		this.scrollContent = document.getElementById (scrollContent);
		this.step = regularStep;
		this.curMin = curMin;
		this.curPad = curPad;

		this.mouseMove = scroll_move;
		this.mouseDown = scroll_mouse_down;
		this.mouseUp = scroll_mouse_up;
		this.setPos = scroll_set;
		this.setCursor = scroll_cursor;
		this.stepUp = scroll_step_up;
		this.stepDown = scroll_step_down;
		this.scrollUp = scroll_up;
		this.scrollDown = scroll_down;
		this.scrollUpClk = scroll_up_clk;
		this.scrollDownClk = scroll_down_clk;
		this.scrollUpDblClk = scroll_up_dblclk;
		this.scrollDownDblClk = scroll_down_dblclk;
		this.resetTimer = scroll_reset;
		
		this.drag = false;
		curFact = this.scrollBox.offsetHeight / this.scrollContent.offsetHeight;
		if (curFact < 1){
			this.cursorExt.style.height = Math.max (this.curMin, Math.round (this.scrollArea.offsetHeight * curFact) - this.curPad);
			this.cursor.style.display = "block";
		}
	}

	function scroll_step_up(bar){
		step = (bar)? this.scrollBox.offsetHeight - this.step : this.step;
		limit = this.scrollBox.offsetHeight - this.scrollContent.offsetHeight - this.margin;
		contTop = Math.min (0, (this.scrollContent.offsetTop + step));
		this.scrollContent.style.top = contTop + "px";
		this.setCursor (contTop / limit);
		return (contTop != 0);
	}

	function scroll_step_down(bar){
		step = (bar)? this.scrollBox.offsetHeight - this.step : this.step;
		limit = this.scrollBox.offsetHeight - this.scrollContent.offsetHeight - this.margin;
		if (limit > 0)
			return false;
		contTop = Math.max (limit, (this.scrollContent.offsetTop - step));
		this.scrollContent.style.top = contTop + "px";
		this.setCursor (contTop / limit);
		return (contTop != limit);
	}

	function scroll_set(pos){
		limit = this.scrollBox.offsetHeight - this.scrollContent.offsetHeight - this.margin;
		if (limit <= 0){
			contTop = Math.round (pos * limit);
			this.scrollContent.style.top = contTop + "px";
		} else
			this.setCursor (0);
	}

	function scroll_cursor(pos){
		curTop = Math.round (pos * (this.scrollArea.offsetHeight - this.cursor.offsetHeight));
		this.cursor.style.top = curTop + "px";
	}

	function scroll_up(bar){
		if (this.stepUp (bar))
			this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollUp(" + bar + ")", this.scrollTime);
	}

	function scroll_down(bar){
		if (this.stepDown (bar))
			this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollDown(" + bar + ")", this.scrollTime);
	}

	function scroll_up_clk(bar){
		this.stepUp (bar);
		this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollUp(" + bar + ")", this.scrollWTime);
	}

	function scroll_down_clk(bar){
		this.stepDown (bar);
		this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollDown(" + bar + ")", this.scrollWTime);
	}

	function scroll_up_dblclk(bar){
		this.stepUp (bar);
	}

	function scroll_down_dblclk(bar){
		this.stepDown (bar);
	}

	function scroll_reset(){
		window.clearTimeout(this.timer);
	}

	function scroll_move(e){
		if (this.drag){
			diff = e.screenY - this.ref;
			diff = Math.max (0, diff);
			diff = Math.min (diff, this.scrollArea.offsetHeight - this.cursor.offsetHeight);
			this.cursor.style.top = diff + "px";
			this.setPos (diff / (this.scrollArea.offsetHeight - this.cursor.offsetHeight));
		}
	}

	function scroll_mouse_down(e){
		if (e.offsetY)
			refY = e.offsetY + this.scrollArea.offsetTop;
		else if (e.layerY)
			refY = e.layerY - 1 + this.scrollArea.offsetTop;
		if (refY >= this.cursor.offsetTop && refY < this.cursor.offsetTop + this.cursor.offsetHeight){
			window.clearTimeout(this.timer);
			this.drag = true;
			this.ref = e.screenY - this.cursor.offsetTop;
		} else if (refY < this.cursor.offsetTop){
			this.stepUp(true);
			this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollUp(true)", this.scrollWTime);
		} else if (refY >= this.cursor.offsetTop + this.cursor.offsetHeight){
			this.stepDown(true);
			this.timer = window.setTimeout ("SCROLLBARS[" + this.id + "].scrollDown(true)", this.scrollWTime);
		}
	}

	function scroll_mouse_up(){
		this.drag = false;
		window.clearTimeout(this.timer);
	}

	function scrollbars_stop(){
		for (i=0; i<SCROLLBARS.length; i++)
			SCROLLBARS[i].mouseUp();
	}	
