/*
    ---------------------------------------------------------------------------
    Name: User Defined Class c_toc
    File: UDC.c_toc.js
    ---------------------------------------------------------------------------
*/

function c_toc() {
    this.length = 0;
    return this;
}

function _TocAid_TocItem(name, out, over, click, width, height) {
    this.name = name;
    this.isClicked = 0;
    this.out = new Image(width, height);
    this.out.src = out;
    this.over = new Image(width, height);
    this.over.src = over;
    this.click = new Image(width, height);
    this.click.src = click;
    return this;
}

function _TocAid_SwitchImage(img, state) {
    if (!document.images) return false;
    var i = 0;
    while (i < this.length && this[i].name != img) i++;
    if (i < this.length) {
        if (this[i].isClicked) return false;
        if (state == 'click') {
            document[img].src = this[i].click.src;
            this[i].isClicked = 1;
        }
        if (state == 'over') document[img].src = this[i].over.src;
        if (state == 'out') document[img].src = this[i].out.src;
    }
}
c_toc.prototype.switchImage = _TocAid_SwitchImage;

function _TocAid_AddImage(name, out, over, click, width, height) {
    this[this.length] = new _TocAid_TocItem(name, out, over, click, width, height);
    this.length++;
}
c_toc.prototype.addImage = _TocAid_AddImage;
