function hscroll (tableName,spaceoftime,speed,period,times) 
{
	this.spaceoftime = spaceoftime? spaceoftime: 100;
    this.speed = speed? speed: 1;
    this.period = period;
    this.times = times?times:5;
    this.count = 0;
    this.serial = hscroll.instances.length;
    hscroll.instances[this.serial] = this;
    this.interval = null;
    this.m = 0;
    this.table = $(tableName);
    this.originalWidth = parseInt(this.table.offsetWidth);

    var tr;
    this.table.getParent().setStyle('overflow','hidden');
    tr = this.table.getFirst().getFirst();
    while(parseInt(this.table.offsetWidth)!=0 && parseInt(this.table.offsetWidth)<=parseInt(this.table.getParent().getStyle('width'))){
        tds = tr.getChildren();
        tds.each(function(el){
           tr.appendChild(el.clone());
        });
    }
    tds = tr.getChildren();
    tds.each(function(el){
       tr.appendChild(el.clone());
    });
}

hscroll.instances = new Array();

hscroll.prototype.scroll = function () {
    if (this.period && parseInt(this.table.getParent().scrollLeft)%this.period==0) {
        if (this.count == this.times) { 
            this.count = 0;
        } else {
            this.count++;
            return true;
        }
    }
    if (parseInt(this.table.getParent().scrollLeft)>=this.originalWidth) {
        this.table.getParent().scrollLeft = parseInt(this.table.getParent().scrollLeft)-this.originalWidth+this.speed;
    } else {
        this.table.getParent().scrollLeft = parseInt(this.table.getParent().scrollLeft)+this.speed;
    }
}

hscroll.prototype.start = function () {
    if (parseInt(this.table.offsetWidth)!=0)
        this.interval = setInterval("hscroll.instances["+this.serial+"].scroll()",this.spaceoftime);
}

hscroll.prototype.pause = function () {
	if (this.interval)
    	clearInterval(this.interval);
}