function scroller(name, container, type, delay, increment, pause, size) {
    this.name = name;
    this.div = document.getElementById(container);
    this.type = type;
    if (this.type == "horizontal" || this.type == "h" || this.type == 1) {
        this.type = "horizontal";
    } else {
        this.type = "vertical";
    }
    if (this.type == "horizontal") {
        this.size = size ? size : Math.abs(parseInt(this.div.style.width));
    } else {
        this.size = size ? size : Math.abs(parseInt(this.div.style.height));
    }
    this.pos = 0;
    this.nextPos = 0;
    this.delay = delay;
    this.pause = pause;
    this.increment = increment;
    this.timer = 0;
    this.pauseTimer = 0;
    this.wait = true;
    if (this.type == "horizontal") {
        this.relativeX = false;
    } else {
        this.relativeY = false;
    }
    this.mouseIsDown = false;
    this.fixedMode = false;
    if (this.type == "horizontal") {
        this.cursor = "e-resize";
    } else {
        this.cursor = "s-resize";
    }
    this.run = function () {if (this.pos <= this.nextPos) {var increment;if (this.nextPos - this.pos <= this.increment) {increment = Math.ceil((this.nextPos - this.pos) / 2);if (increment > this.increment) {increment = this.increment;} else if (increment == 0) {increment = 1;}} else {increment = this.increment;}this.pos += increment;if (this.type == "horizontal") {this.div.scrollLeft = this.pos;if (this.div.scrollLeft != this.pos) {window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.start();}} else {this.div.scrollTop = this.pos;if (this.div.scrollTop != this.pos) {window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.start();}}} else {window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.wait = true;this.pauseTimer = window.setTimeout(this.name + ".next()", this.pause);}};
    this.start = function () {this.pos = 0;this.nextPos = 0;window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.pauseTimer = window.setTimeout(this.name + ".next()", this.pause);};
    this.next = function () {this.wait = false;this.pos = this.nextPos;this.nextPos += this.size;window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.timer = window.setInterval(this.name + ".run()", this.delay);};
    this.stop = function () {window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);};
    this.restart = function () {if (this.type == "horizontal") {this.pos = Math.abs(this.div.scrollLeft);} else {this.pos = Math.abs(this.div.scrollTop);}this.nextPos = 0;while (this.nextPos < this.pos) {this.nextPos += this.size;}this.wait = false;window.clearInterval(this.timer);window.clearInterval(this.pauseTimer);this.timer = window.setInterval(this.name + ".run()", this.delay);};
    this.mouseover = function (e) {if (!this.fixedMode) {var eventElt;if (!e) {eventElt = window.event.fromElement;} else {eventElt = e.relatedTarget;}if (!this.eventSubElt(eventElt)) {this.div.style.cursor = this.cursor;this.stop();}}};
    this.mouseout = function (e) {if (!this.fixedMode) {var eventElt;if (!e) {eventElt = window.event.toElement;} else {eventElt = e.relatedTarget;}if (!this.eventSubElt(eventElt)) {this.div.style.cursor = "default";this.restart();}}};
    this.mousedown = function (e) {if (!e) {var e = window.event;}if (this.type == "horizontal") {this.relativeX = e.clientX;} else {this.relativeY = e.clientY;}this.mouseIsDown = true;return false;};
    this.mouseup = function (e) {if (this.type == "horizontal") {this.relativeX = false;} else {this.relativeY = false;}this.mouseIsDown = false;return false;};
    this.mousemove = function (e) {if (this.mouseIsDown && !this.fixedMode) {if (!e) {var e = window.event;}if (this.type == "horizontal") {this.scroll(this.relativeX - e.clientX);this.relativeX = e.clientX;} else {this.scroll(this.relativeY - e.clientY);this.relativeY = e.clientY;}}};
    this.mouseWheel = function (e, ref) {if (e) {this.scroll(10 * e.detail);e.preventDefault();} else {if (ref == this.div) {this.scroll(- window.event.wheelDelta);}return false;}};
    this.scroll = function (l) {if (this.type == "horizontal") {var newPos = this.div.scrollLeft + l;this.div.scrollLeft += l;if (newPos > this.div.scrollLeft) {this.div.scrollLeft = newPos - this.div.scrollLeft;} else if (newPos < this.div.scrollLeft) {this.div.scrollLeft = this.div.scrollWidth - (this.div.scrollLeft - newPos);}} else {var newPos = this.div.scrollTop + l;this.div.scrollTop += l;if (newPos > this.div.scrollTop) {this.div.scrollTop = newPos - this.div.scrollTop;} else if (newPos < this.div.scrollTop) {this.div.scrollTop = this.div.scrollHeight - (this.div.scrollTop - newPos);}}};
    this.dblclick = function (e) {if (this.fixedMode) {if (this.type == "horizontal") {this.cursor = "e-resize";} else {this.cursor = "s-resize";}this.fixedMode = false;this.div.style.MozUserSelect = "none";this.div.onselectstart = function () {return false;};this.restart();} else {this.cursor = "text";this.fixedMode = true;this.div.style.MozUserSelect = "";this.div.onselectstart = function () {return true;};this.stop();}this.div.style.cursor = this.cursor;};
    this.eventSubElt = function (elt) {while (elt && elt != this.div && elt.nodeName != "BODY") {elt = elt.parentNode;}if (elt && elt == this.div) {return true;}return false;};
    this.div.style.MozUserSelect = "none";
    this.div.onselectstart = function () {return false;};
    if (document.addEventListener) {
        eval("this.div.addEventListener('DOMMouseScroll', function(e){" + this.name + ".mouseWheel(e);}, false)");
    } else {
        eval("this.div.onmousewheel = function(){return " + this.name + ".mouseWheel(0, this);};");
    }
    var events = ["mouseover", "mouseout", "mousedown", "mouseup", "mousemove", "dblclick"];
    for (ev in events) {
        try {
            eval("this.div.on" + events[ev] + " = function(e){" + this.name + "." + events[ev] + "(e);}");
        } catch (e) {
        }
    }
    this.start();
}
