function QControl_init(parent, name) {
    this.parent = parent || self;
    this.window = (parent && parent.window) || self;
    this.document = (parent && parent.document) || self.document;
    this.name = (parent && parent.name) ? (parent.name + "." + name) : ("self." + name);
    this.id = "Q";
    var h = this.hash(this.name);
    for (var j=0; j<8; j++) {
        this.id += QControl.HEXTABLE.charAt(h & 15);
        h >>>= 4;
    }
}

function QControl_hash(str) {
    var h = 0;
    if (str) {
        for (var j=str.length-1; j>=0; j--) {
            h ^= QControl.ANTABLE.indexOf(str.charAt(j)) + 1;
            for (var i=0; i<3; i++) {
                var m = (h = h<<7 | h>>>25) & 150994944;
                h ^= m ? (m == 150994944 ? 1 : 0) : 1;
            }
        }
    }
    return h;
}

function QControl_nop() {
}

function QControl() {
    this.init = QControl_init;
    this.hash = QControl_hash;
    this.window = self;
    this.document = self.document;
    this.tag = null;
}
QControl.ANTABLE  = "w5Q2KkFts3deLIPg8Nynu_JAUBZ9YxmH1XW47oDpa6lcjMRfi0CrhbGSOTvqzEV";
QControl.HEXTABLE = "0123456789ABCDEF";
QControl.nop = QControl_nop;
QControl.event = QControl_nop;

function trans_set_ie(value) {
    this.label.innerText = (this.value = value) || "\xA0";
}

function trans_set_dom2(value) {
    with (this.label) {
        replaceChild(this.document.createTextNode((this.value = value) || "\xA0"), firstChild);
    }
}

function trans_set_ns4(value) {
    this.value = value || "";
    with (this) {
        document.open();
        document.write('<div >' + (clickable ? '<a href="#" title="' + tooltip + '" onClick="return ' +
            name + '.doEvent()" onMouseOut="window.top.status=\'\'" onMouseOver="window.top.status=' + name +
            '.tooltip;return true">' + value + '</a>' : value) + '</div>');
        document.close();
    }
}

function trans_doEvent() {
    this.onClick(this.value, this.tag);
    return false;
}

function trans(parent, name, value, clickable, tooltip) {
    this.init(parent, name);
    this.value = value || "";
    this.clickable = clickable || false;
    this.tooltip = tooltip || "";
    this.doEvent = trans_doEvent;
    this.onClick = QControl.event;
    with (this) {
        if (document.getElementById || document.all) {
            document.write(clickable ? '<div unselectable="on"><a id="' + id + '" href="#" title="' +
                tooltip + '" onClick="return ' + name + '.doEvent()" onMouseOver="window.top.status=' + name +
                '.tooltip;return true" onMouseOut="window.top.status=\'\'" hidefocus="true" unselectable="on">' +
                (value || '&nbsp;') + '</a></div>' : '<div id="' + id + '" class="trans" unselectable="on">' +
                (value || '&nbsp;') + '</div>');
		   this.label = document.getElementById ? document.getElementById(id) :
                (document.all.item ? document.all.item(id) : document.all[id]);
            this.set = (label && (label.innerText ? trans_set_ie :
                (label.replaceChild && trans_set_dom2))) || QControl.nop;
        } else if (document.layers) {
            var suffix = "";
            for (var j=value.length; j<trans.TEXTQUOTA; j++) suffix += " &nbsp;";
            document.write('<div><ilayer id="i' + id + '"><layer id="' + id + '"><div class="trans">' +
                (clickable ? '<a href="#" title="' + tooltip + '" onClick="return ' + name +
                '.doEvent()" onMouseOver="window.top.status=' + name +
                '.tooltip;return true" onMouseOut="window.top.status=\'\'">' + value + suffix + '</a>' :
                value + suffix) + '</div></layer></ilayer></div>');
            this.label = (this.label = document.layers["i" + id]) && label.document.layers[id];
            this.document = label && label.document;
            this.set = (label && document) ? trans_set_ns4 : QControl.nop;
        } else {
            document.write("Object is not supported");
        }
    }
}
trans.prototype = new QControl();
trans.TEXTQUOTA = 50;