document.onmousemove=mouseMove;
document.onmouseup=mouseUp;
document.onmousedown=mouseDown;
if(chk.ns){document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);}

var X=null;
var Y=null;

var mouseUpX=null;
var mouseUpY=null;

var mouseDownX=null;
var mouseDownY=null;

var dragBar=false;
var scrollActive=true;

function mouseMove(e){
	X=(chk.ie)?event.x+document.body.scrollLeft:(chk.ns)?e.pageX:null;
	Y=(chk.ie)?event.y+document.body.scrollTop:(chk.ns)?e.pageY:null;
	if(limits!=null){
		if( (Y<limits[0]) || (Y>limits[2]) || (X<limits[3]) || (X>limits[1]) ){
			resetMenuElements();
		}
	}
	if(dragBar && !scrollActive){
		newBarY=Y-baren.offsetY;
		if(newBarY<scrollBarTop){newBarY=scrollBarTop;}
		if((newBarY+scrollBar.clipBottom)>(scrollBarHeight+scrollBarTop)){newBarY=(scrollBarHeight-scrollBar.clipBottom)+scrollBarTop;}
		ratio=(newBarY-scrollBarTop)/(scrollBarHeight-scrollBar.clipBottom);
		baren.move(baren.posx,(newBarY));
		scrollContent.move(scrollContent.posx,(lowerLimit*ratio));
		return false;
	}
	else{
		return true;
	}
}

function mouseUp(e){
	var mouseUpX=(chk.ie)?event.x+document.body.scrollLeft:(chk.ns)?e.pageX:null;
	var mouseUpY=(chk.ie)?event.y+document.body.scrollTop:(chk.ns)?e.pageY:null;
	//baren.over=false;
	//killScroll();
	dragBar=false;
	scrollActive=false;
	//default action:
	return true;
}

function mouseDown(e){
	var mouseDownX=(chk.ie)?event.x+document.body.scrollLeft:(chk.ns)?e.pageX:null;
	var mouseDownY=(chk.ie)?event.y+document.body.scrollTop:(chk.ns)?e.pageY:null;
	//default action:
	return true;
}
