Scroller = Class.create();

Scroller.prototype = {
    initialize: function(el, initial, start, end, step, frequency)
    {
        this.element = $(el);
        this.doscroll = true;
        this.start = start;
        this.pos = initial;
        this.end = end;
        this.frequency = frequency;
        this.step = step;

        this.timer = setInterval(this.scroll.bind(this),this.frequency);
    },
    
    scroll: function()
    {

        // recalculate the position
        if (this.doscroll)
            this.pos = this.pos + this.step;

        // check of outside of range
        if (((this.step > 0) && (this.pos > this.end)) || ((this.step < 0) && (this.pos < this.end)))
            this.pos = this.start;

        // update the position
        this.element.style.left = this.pos + "px";
    
    }
}