var eScroll = function(id,ea,width){
	if (!arguments[1]) ea = 4;
	if (!arguments[2]) width = 222;

	/***** user vars ****/
	this.speed = 2;
	this.delay = 100;
	/********************/

	var _self = this;
	var box = document.getElementById(id);
	var drt = 1;
	var sleep = 0;
	var move_stop = 0;
	var cutline = 0;

	/*** mouse event ***/
	box.onmouseover = function(){_self.stop_move(1)}
	box.onmouseout = function(){_self.stop_move(0)}

	this.scroll = function(){
		var posX = box.scrollLeft;
		if (move_stop || (posX%width==0 && ++sleep<this.delay)) return;
		sleep = 0; posX = posX + drt * this.speed;
		if (posX>=cutline) posX = 0;
		else if (posX<=0) posX = cutline;
		box.scrollLeft = posX;
	}
	this.setLayout = function(){
		var tmp = box.innerHTML;
		var innerDiv = document.createElement('div');
		innerDiv.style.width = cutline * 2;
		box.innerHTML = "";
		box.appendChild(innerDiv);
		innerDiv.innerHTML = tmp + tmp;
	}
	this.setDirection = function(idx){ sleep = this.delay; drt = idx; }
	this.stop_move = function(idx){ move_stop = idx; }
	this.init = function(){
		cutline = ea * width;
		this.setLayout();
		setInterval(function(){_self.scroll()},1);
	}
	this.init();
}
