// Manejo de un scroll basico

function ScrollLayer(name, objname, ssize, incr) {
	this.name = name;
	this.scroll_size = ssize;
	this.scroll_inc = incr;
	this.scroll_stat = 0;
	this.obj = document.getElementById(objname);
	this.scroll_length = this.obj.scrollHeight - this.scroll_size;
	this.scroll_pos = this.scroll_length;
	this.ready = 1 ;
}

// Realiza el movimiento en si...
ScrollLayer.prototype.doScroll = function(d) {
var scrollpos = new Number(this.obj.style.top.replace(/px/, ""));
	if (this.ready!=1) return;
	switch (d) {
		case 1: // Down
			if ((this.scroll_pos < this.scroll_length) && this.ready!=0) {
				this.obj.style.top = scrollpos + this.scroll_inc + "px";
				this.scroll_pos += this.scroll_inc;
			}
			break ;
		case 2: // Up
			if ((this.scroll_pos >= 0) && this.ready!=0) {
				this.obj.style.top = scrollpos - this.scroll_inc + "px";
				this.scroll_pos -= this.scroll_inc;
			}
			break ;
	}
	if (this.scroll_stat!=0)
		eval ("setTimeout('" + this.name + ".doScroll(" + d + ")',20);") ;
}

ScrollLayer.prototype.addRate = function(rate) {
	if ( rate > 0 || (rate <0 && this.scroll_inc > 1) )
		this.scroll_inc = this.scroll_inc + rate;
}