function makeScrollbar() {
	this.arguments=makeScrollbar.arguments;
	this.scroll_content=arguments[0];
	this.scroll_base=arguments[1];
	this.scroll_handle=arguments[2];
	this.contentHeight=parseInt(this.scroll_content.height());
	this.baseHeight=parseInt(this.scroll_base.height());
	this.incHeight=this.contentHeight/this.baseHeight;
	if(this.incHeight<=0) {
		this.incHeight=1;
	}
	sw=this.baseHeight/this.incHeight;
	this.scroll_handle.css("height",sw+"px");
	pos=findPos(this.scroll_base.get(0));
	this.scroll_baseTop=pos[1];
	this.scroll_baseBottom=pos[1]+this.baseHeight-parseInt(this.scroll_handle.height());
	pos[0]-=((parseInt(this.scroll_handle.width())/2)-parseInt(this.scroll_base.width())/2);
	this.scroll_handle.css({left:pos[0]+"px",top:pos[1]+"px",display:"block"});
	if(this.contentHeight>this.baseHeight+2) {
		this.SC_mousewheel=SC_mousewheel;
		this.SB_click=SB_click;
		this.SH_mousedown=SH_mousedown;
		this.SH_mouseup=SH_mouseup;
		this.SH_mousemove=SH_mousemove;
		this.chkHandle=chkHandle;
		this.scroll_init=scroll_init;
		this.scroll_init()
	} else {
		this.scroll_base.css("display","none");
		this.scroll_handle.css("display","none");
	}
}
function scroll_init() {
	var scroll=this;
	scroll.scroll_content.get(0).onmousewheel=function (event) {
		scroll.SC_mousewheel(event);
	}
	if(window.addEventListener) {
		scroll.scroll_content.get(0).addEventListener('DOMMouseScroll', scroll.scroll_content.get(0).onmousewheel, false);
	}
	scroll.scroll_base.click(function(event) {
		scroll.SB_click(event);
	});
	scroll.scroll_handle.mousedown(function(event) {
		scroll.SH_mousedown(event);
		scroll.scroll_handle.mousemove(function(event) {
			scroll.SH_mousemove(event);
		});
	});
	scroll.scroll_handle.mouseup(function(event) {
		scroll.SH_mouseup(event);
		scroll.scroll_handle.get(0).mousemove="";
	});
}
function SC_mousewheel(event) {
	if (!event) event = window.event;
	if(event.wheelDelta) { // IE & Opera
		delta = event.wheelDelta / 120;
	} else if (event.detail) { // W3C
		delta = -event.detail / 3;
	}
	currenTop=parseInt(this.scroll_content.css("top"));
	this.scroll_content.css("top",((currenTop)+(delta*(30)))+"px");
	currenTop1=parseInt(this.scroll_handle.css("top"));
	dis=(parseInt(this.scroll_handle.height())/this.incHeight);
	this.scroll_handle.css("top",((currenTop1+0.5)-(delta*(dis-(dis/this.incHeight))))+"px");
	this.chkHandle();
	if(event.preventDefault){
		event.preventDefault();
	}
	event.returnValue = false;
}
function SB_click(event) {
	x=event.pageY-30;
	pos=parseInt(this.scroll_handle.css("top"));
	this.scroll_handle.css("top",x+"px");
	currenTop=x=parseInt(this.scroll_handle.css("top"));
	h=currenTop-this.scroll_baseTop;
	h=h*this.incHeight;
	h=-h;
	this.scroll_content.css("top",h+"px");
	if(x<this.scroll_baseTop) {
		x=this.scroll_baseTop;
		h=0;
		h=-h;
		this.scroll_content.css("top",h+"px");
	}
	if(x>this.scroll_baseBottom) {
		h=this.contentHeight-this.baseHeight;
		h=-h;
		this.scroll_content.css("top",h+"px");
		x=this.scroll_baseBottom;
	}
	this.scroll_handle.css("top",x+"px");
	this.chkHandle();
}
function SH_mousedown(event) {
	this.scroll_handle.css("cursor","arrow");
	this.stop=false;
	this.now=true;
	this.ycoor=event.pageY;
	this.oldTop=parseInt(this.scroll_handle.css("top"));
	this.chkHandle();
}
function SH_mousemove(event) {
	var currenTop=parseInt(this.scroll_handle.css("top"));
	if((this.scroll_baseBottom)<currenTop || this.scroll_baseTop>currenTop) {
		if(!this.now)
			this.stop=true;
		if(this.scroll_baseBottom<currenTop) {
			h=this.contentHeight-this.baseHeight;
			h=-h;
			this.scroll_content.css("top",h+"px");
		}
		if(this.scroll_baseTop>currenTop) {
			h=0;
			h=-h;
			this.scroll_content.css("top",h+"px");
		}
	}
	if(!this.stop) {
		this.now=false;
		this.scroll_handle.css("top",(this.oldTop+(event.pageY-this.ycoor))+"px");
		currenTop=parseInt(this.scroll_handle.css("top"));
		h=currenTop-this.scroll_baseTop;
		h=h*this.incHeight;
		h=-h;
		this.scroll_content.css("top",h+"px");
	}
	this.chkHandle();
}
function SH_mouseup() {
	this.stop=true;
	this.chkHandle();
}
function chkHandle() {
	chkpos=parseInt(this.scroll_handle.css("top"));
	if(chkpos>this.scroll_baseBottom) {
		this.scroll_handle.css("top",this.scroll_baseBottom);
		h=this.contentHeight-this.baseHeight;
		h=-h;
		this.scroll_content.css("top",h+"px");
		this.stop=true;
	}
	if(chkpos<this.scroll_baseTop) {
		this.scroll_handle.css("top",this.scroll_baseTop);
		h=0;
		h=-h;
		this.scroll_content.css("top",h+"px");
		this.stop=true;
	}
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}