function hscroll() {
	this.contDiv;
	this.bar;
	this.mouse;
	this.initX;
	this.dragging;
	this.barX;
	this.minX;
	this.maxX;
	this.ratio;
	this.clipDiv;
	this.intvl;
	this.dir;
	this.refreshRate;
	
	this.init = function() {
		this.refreshRate = 20;
		this.contDiv = document.getElementById(this.contDiv);
		this.clipDiv = document.getElementById(this.clipDiv);
		this.bar = document.getElementById(this.bar);
		this.initX = findPos(this.bar)[0];
		this.bar.style.marginLeft = this.minX+"px";
		this.mouse = new MousePosition();
		
		this.ratio = (this.contDiv.offsetWidth-this.clipDiv.offsetWidth)/(this.maxX-this.minX);
		
		if (document.addEventListener) {
			this.bar.addEventListener('mousedown', Delegate(this, startDrag), false);
			document.addEventListener('mouseup', Delegate(this, stopDrag), false);
			document.addEventListener('mousemove', Delegate(this, move), false);
		} else if (document.attachEvent) {
			this.bar.attachEvent('onmousedown', Delegate(this, startDrag));
			document.attachEvent('onmouseup', Delegate(this, stopDrag));
			document.attachEvent('onmousemove', Delegate(this, move));
		}
		
		document.onmousedown = function() { return false; };
		document.onmousemove = function() { return false; };
	}
	
	
	var startDrag = function(e) {
		this.barX = this.mouse.x-findPos(this.bar)[0];
		this.dragging = true;
	};
	
	var stopDrag = function(e) {
		this.dragging = false;
	};
	
	var move = function(e) {
		if(this.dragging) {
			this.setPos(this.mouse.x-this.initX-this.barX);
		}
	};
	
	this.setPos = function(margin) {
		var cont;
		
		if(margin < this.minX) {
			margin = this.minX;
		} else if(margin > this.maxX) {
			margin = this.maxX;
		}
		
		cont = Math.floor((this.minX-margin)*this.ratio);
		
		this.bar.style.marginLeft = margin+"px";
		this.contDiv.style.marginLeft = cont+"px";
	};
	
	var scrollNow = function() {
		this.stop();
		this.setPos(parseInt(this.bar.style.marginLeft)+3*this.dir);
		this.intvl = setTimeout(Delegate(this, scrollNow), this.refreshRate);
	};
	
	this.scroll = function(dir) {
		this.dir = dir;
		this.intvl = setTimeout(Delegate(this, scrollNow), this.refreshRate);
	};
	
	this.stop = function() {
		clearTimeout(this.intvl);
	};

}



function MousePosition() {
	this.x;
	this.y;
	this.IE;
	
	this.MousePosition = function() {
		this.IE = (document.all)? true: false;
		
		if (document.addEventListener) {
			document.addEventListener('mousemove', Delegate(this, this.getPosition), false); 
		} else if (document.attachEvent) {
			document.attachEvent('onmousemove', Delegate(this, this.getPosition));
		}
	};
	
	
	this.getPosition = function(e) {
		if (this.IE) {
			this.x = event.clientX;
			this.y = event.clientY;
		} else {
			this.x = e.pageX;
			this.y = e.pageY;
		}
		
		//showMsg("x:"+this.x+", y:"+this.y);
	};
	
	this.MousePosition();
}




