/**
 * QLIB 1.0 Dynamic Anchor
 * Serge Dolgov (C) 2002
 * studio.quazzle.com
 */

function QAnchor_set_dom2(value) {
    with (this.anchor) {
        replaceChild(document.createTextNode((this.value = value) || "\xA0"), firstChild);
    }
}

function QAnchor_set_ie(value) {
    this.anchor.innerText = (this.value = value) || "\xA0";
}

function QAnchor_set_ns4(value) {
    with (this.anchor.document) {
        open();
        write('<div class="anchor"><a href="#" title="' + this.tip + '" onClick="return ' +
            this.name + '.doEvent()" onMouseOver="window.top.status=' + this.name +
            '.tip;return true">' + ((this.value = value) || "") + '</a></div>');
        close();
    }
}

function QAnchor_nop() {
}

function QAnchor_doEvent() {
    if (this.onClick) this.onClick(this.value, this.tag);
    return false;
}

function QAnchor(parent, name, value, tip) {
    this.init(parent, name);
    this.value = value || "&nbsp;";
    this.tip = tip || "";
    this.doEvent = QAnchor_doEvent;
    if (document.getElementById || document.all) {
        document.write('<div class="anchor"><a id="' + this.name + '" href="#" title="' + this.tip +
            '" onClick="return ' + this.name + '.doEvent()" onMouseOver="window.top.status=' + this.name +
            '.tip;return true">' + this.value + '</a></div>');
        this.anchor = document.getElementById ? document.getElementById(this.name) : document.all[this.name];
        if (this.anchor.innerText) {
            this.set = QAnchor_set_ie;
        } else if (this.anchor.replaceChild) {
            this.set = QAnchor_set_dom2;
        } else {
            this.set = QAnchor_nop;
        }
    } else if (document.layers) {
        document.write('<div><ilayer><layer onLoad="self.document.layers[\'' + this.name +
            '\']=this"><div class="anchor"><a href="#" title="' + this.tip + '" onClick="return ' +
            this.name + '.doEvent()" onMouseOver="window.top.status=' + this.name +
            '.tip;return true">' + this.value + '</a></div></layer></ilayer></div>');
        this.set = QAnchor_set_ns4;
        this.anchor = document.layers[this.name];
    } else {
        document.write("No support for dynamic anchor");
    }
}
QAnchor.prototype = new QControl();