/**
 * This document is protect by international copyright law.
 * Unauthorized uses, modifications, and/or distributions are punishable offenses.
 *
 * @copyright © 2007 WebZack.com LLC
 * @author Cody Craven
 * @link http://www.webzack.com/
 *
 * TODO:
 *  Find a way to make QScroll.prototype.scroll function without absolutely
 *  declaring the object instance.
 */

function QScroll(subject) {
    this._subject = subject;
}

QScroll.prototype._interval;
QScroll.prototype._subject;
QScroll.prototype._speed;
QScroll.prototype._slow_speed = 4;
QScroll.prototype._fast_speed = 20;

QScroll.prototype.scrollUp = function () {
    this._speed = this._slow_speed;
    this._interval = window.setInterval(this.scroll, 40);
}

QScroll.prototype.scrollDown = function () {
    this._speed = -this._slow_speed;
    this._interval = window.setInterval(this.scroll, 40);
}

QScroll.prototype.toggleFast = function () {
    if (this._speed > 0) {
        if (this._speed == this._slow_speed) {
            this._speed = this._fast_speed;
        } else {
            this._speed = this._slow_speed;
        }
    } else {
        if (this._speed == -this._slow_speed) {
            this._speed = -this._fast_speed;
        } else {
            this._speed = -this._slow_speed;
        }
    }
    this.stopScroll();
    this._interval = window.setInterval(this.scroll, 40);
}

QScroll.prototype.stopScroll = function () {
    clearInterval(this._interval);
}

QScroll.prototype.scroll = function () {
    document.getElementById(scr._subject).scrollTop -= scr._speed;
}