Function.prototype.bind = function (d) {
    var f = this,
        e = function () {
            return f.apply(d, arguments)
        };
    return (e)
};
SEMods = function () {};
SEMods.TextAreaControl = function (d) {
    this.obj = d;
    this.obj.style.overflow = "hidden";
    this.originalHeight = this.obj.getStyle("height").toInt();
    var c = this.update.bind(this);
    d.addEvent("focus", this.onFocus.bind(this));
    d.addEvent("blur", this.onBlur.bind(this));
    this.update()
};
SEMods.TextAreaControl.prototype = {
    obj: null,
    updating: false,
    autoGrow: false,
    originalHeight: null,
    shadowElement: null,
    increment: 0,
    timer: null,
    lastLength: 0,
    setAutoGrow: function (b) {
        this.autoGrow = b;
        this.createShadowElement();
        this.update()
    },
    onUpdate: function () {
        if (this.autoGrow && this.lastLength != this.obj.value.length) {
            this.lastLength = this.obj.value.length;
            this.updateShadowElement();
            this.obj.style.height = Math.max(this.originalHeight, this.shadowElement.offsetHeight + this.increment) + "px"
        }
    },
    beginUpdate: function () {
        if (this.updating) {
            return false
        }
        this.updating = true;
        return true
    },
    endUpdate: function () {
        this.updating = false
    },
    update: function () {
        if (!this.beginUpdate()) {
            return
        }
        this.onUpdate();
        this.endUpdate()
    },
    createShadowElement: function () {
        if (this.shadowElement) {
            return
        }
        this.shadowElement = document.createElement("DIV");
        this.shadowElement.style.position = "absolute";
        this.shadowElement.style.top = "-99999px";
        this.shadowElement.style.left = "-99999px";
        document.body.appendChild(this.shadowElement)
    },
    updateShadowElement: function () {
        if (this.shadowElement) {
            text = this.obj.value + "<br>";
            this.shadowElement.innerHTML = text.toString().replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#039;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br />");
            var c = this.getPXMetrics(this.obj.getStyle("font-size"), 10);
            var d = this.obj.getStyle("line-height");
            if ((/Opera/i.test(navigator.userAgent))) {
                d = this.getPXMetrics(d, 0) + 3 + "px"
            }
            this.increment = c + 10;
            this.shadowElement.style.width = this.obj.offsetWidth + "px";
            this.shadowElement.style.lineHeight = d;
            this.shadowElement.style.fontSize = this.obj.getStyle("font-size");
            this.shadowElement.style.fontFamily = this.obj.getStyle("font-family");
            this.shadowElement.style.paddingLeft = this.obj.getStyle("padding-left");
            this.shadowElement.style.paddingRight = this.obj.getStyle("padding-right")
        }
    },
    onFocus: function () {
        this.timer = setInterval(this.update.bind(this), 500)
    },
    onBlur: function () {
        if (this.timer) {
            clearInterval(this.timer);
            this.timer = null
        }
    },
    getPXMetrics: function (f, d) {
        var e = parseFloat(f);
        if (isNaN(e)) {
            return d != null ? d : e
        }
        return /px/i.test(f) ? e : /pt/i.test(f) ? 1.3333 * e : e
    }
};

function textarea_autogrow(d) {
    var c = $(d);
    if (c && !c._controlled) {
        c._controlled = true;
        new SEMods.TextAreaControl(c).setAutoGrow(true);
        return c.getStyle("height").toInt()
    }
}
TB_WIDTH = 0;
TB_HEIGHT = 0;
var TB_doneOnce = 0;
var TB_ready = false;
var TB_useReady = true;

function TB_init() {
    TB_ready = true;
    $$("a.smoothbox").each(function (b) {
        b.onclick = TB_bind
    })
}
window.addEvent("domready", TB_init);

function TB_bind(d) {
    if (TB_useReady && !TB_ready) {
        return
    }
    var d = new Event(d);
    d.preventDefault();
    this.blur();
    var e = this.title || this.name || "";
    var f = this.rel || false;
    TB_show(e, this.href, f);
    this.onclick = TB_bind;
    return false
}
function TB_show(n, v, m, s, p) {
    if (TB_useReady && !TB_ready) {
        return
    }
    if (!p) {
        p = 0
    }
    if (!$("TB_overlay")) {
        (new Element("div").setProperty("id", "TB_overlay")).inject($("smoothbox_container") || document.body);
        $("TB_overlay").setOpacity(0.6);
        TB_overlaySize()
    }
    if (!$("TB_window")) {
        (new Element("div").setProperty("id", "TB_window")).inject($("smoothbox_container") || document.body);
        $("TB_window").setOpacity(0)
    } else {
        $("TB_window").destroy();
        (new Element("div").setProperty("id", "TB_window")).inject($("smoothbox_container") || document.body);
        $("TB_window").setOpacity(0)
    }
    if (p == 0) {
        $("TB_overlay").onclick = TB_remove
    } else {
        $("TB_overlay").onclick = ""
    }
    window.onscroll = TB_position;
    var u = v.match(/(.+)?/)[1] || v;
    var w = v.match(/\?(.+)/)[1];
    var r = TB_parseQuery(w);
    TB_WIDTH = (r.width * 1) + 30;
    TB_HEIGHT = (r.height * 1) + 40;
    var t = TB_WIDTH - 30,
        o = TB_HEIGHT - 45;
    if (v.indexOf("TB_iframe") != -1) {
        urlNoQuery = v.split("TB_");
        $("TB_window").innerHTML += "<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + n + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>X</a></div></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "&in_smoothbox=true' id='TB_iframeContent' name='TB_iframeContent' scrolling='auto' style='width:" + (t + 29) + "px;height:" + (o + 17) + "px;' onload='TB_showWindow()'> </iframe>"
    } else {
        $("TB_window").innerHTML += "<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + n + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>X</a></div></div><div id='TB_ajaxContent' style='width:" + t + "px;height:" + o + "px;'></div>"
    }
    $("TB_closeWindowButton").onclick = TB_remove;
    if (v.indexOf("TB_inline") != -1) {
        $("TB_ajaxContent").innerHTML = ($(r.inlineId).innerHTML);
        TB_position();
        TB_showWindow()
    } else {
        if (v.indexOf("TB_iframe") != -1) {
            TB_position();
            if (frames.TB_iframeContent == undefined) {
                $(document).keyup(function (a) {
                    var b = a.keyCode;
                    if (b == 27) {
                        TB_remove()
                    }
                });
                TB_showWindow()
            }
        } else {
            var q = function () {
                TB_position();
                TB_showWindow()
            };
            new Request.HTML({
                method: "get",
                update: $("TB_ajaxContent"),
                onComplete: q
            }).get(v)
        }
    }
    window.onresize = function () {
        TB_position();
        TB_overlaySize()
    };
    document.onkeyup = function (a) {
        var a = new Event(a);
        if (a.code == 27) {
            TB_remove()
        }
    }
}
function TB_showWindow() {
    if (TB_useReady && !TB_ready) {
        return
    }
    if (TB_doneOnce == 0) {
        TB_doneOnce = 1;
        $("TB_window").set("tween", {
            duration: 250
        });
        $("TB_window").tween("opacity", 0, 1)
    } else {
        $("TB_window").setStyle("opacity", 1)
    }
}
function TB_remove() {
    if (TB_useReady && !TB_ready) {
        return
    }
    $("TB_overlay").onclick = null;
    document.onkeyup = null;
    document.onkeydown = null;
    if ($("TB_closeWindowButton")) {
        $("TB_closeWindowButton").onclick = null
    }
    $("TB_window").set("tween", {
        duration: 250,
        onComplete: function () {
            $("TB_window").destroy()
        }
    });
    $("TB_window").tween("opacity", 1, 0);
    $("TB_overlay").set("tween", {
        duration: 400,
        onComplete: function () {
            $("TB_overlay").destroy()
        }
    });
    $("TB_overlay").tween("opacity", 0.6, 0);
    window.onscroll = null;
    window.onresize = null;
    TB_init();
    TB_doneOnce = 0;
    return false
}
function TB_position() {
    if (TB_useReady && !TB_ready) {
        return
    }
    $("TB_window").set("morph", {
        duration: 75
    });
    $("TB_window").morph({
        width: TB_WIDTH + "px",
        left: (window.getScrollLeft() + (window.getWidth() - TB_WIDTH) / 2) + "px",
        top: (window.getScrollTop() + (window.getHeight() - TB_HEIGHT) / 2) + "px"
    })
}
function TB_overlaySize() {
    if (TB_useReady && !TB_ready) {
        return
    }
    $("TB_overlay").setStyles({
        height: "0px",
        width: "0px"
    });
    $("TB_overlay").setStyles({
        height: window.getScrollHeight() + "px",
        width: window.getScrollWidth() + "px"
    })
}
function TB_parseQuery(k) {
    if (TB_useReady && !TB_ready) {
        return
    }
    if (!k) {
        return {}
    }
    var h = {};
    var f = k.split(/[;&]/);
    for (var g = 0; g < f.length; g++) {
        var j = f[g].split("=");
        if (!j || j.length != 2) {
            continue
        }
        h[unescape(j[0])] = unescape(j[1]).replace(/\+/g, " ")
    }
    return h
}
if (typeof(bsn) == "undefined") {
    _b = bsn = {}
}
if (typeof(_b.Autosuggest) == "undefined") {
    _b.Autosuggest = {}
} else {
    alert("Autosuggest is already set!")
}
_b.AutoSuggest = function (h, j) {
    if (!document.getElementById) {
        return 0
    }
    this.fld = _b.DOM.gE(h);
    if (!this.fld) {
        return 0
    }
    this.sInp = "";
    this.nInpC = 0;
    this.aSug = [];
    this.iHigh = 0;
    this.oP = j ? j : {};
    var g, f = {
        minchars: 1,
        meth: "get",
        varname: "input",
        className: "autosuggest",
        timeout: 2500,
        delay: 0,
        offsety: -5,
        shownoresults: true,
        noresults: "No results!",
        maxheight: 250,
        cache: true,
        maxentries: 25,
        blurtrigger: false,
        multisuggest: true
    };
    for (g in f) {
        if (typeof(this.oP[g]) != typeof(f[g])) {
            this.oP[g] = f[g]
        }
    }
    var k = this;
    this.fld.onkeypress = function (a) {
        return k.onKeyPress(a)
    };
    this.fld.onkeyup = function (a) {
        return k.onKeyUp(a)
    };
    if (typeof(this.oP.callback) == "function" && this.oP.blurtrigger) {
        this.fld.onblur = function (a) {
            if (document.activeElement && typeof(a) === "undefined") {
                var b = document.activeElement
            } else {
                var b = a.explicitOriginalTarget;
                while (b.parentNode) {
                    if (b.tagName == "A" && typeof(b.id) == "string") {
                        if (b.id.substring(0, 10) == "bsnsuggest") {
                            break
                        }
                    }
                    b = b.parentNode
                }
                if (typeof(b.id) != "string") {
                    b.id = ""
                }
            }
            if (b.id.substring(0, 10) != "bsnsuggest") {
                k.oP.callback({
                    id: k.fld.value,
                    value: k.fld.value
                });
                k.clearSuggestions()
            }
        }
    }
    this.fld.setAttribute("autocomplete", "off")
};
_b.AutoSuggest.prototype.onKeyPress = function (m) {
    var n = (window.event) ? window.event.keyCode : m.keyCode;
    var o = 13;
    var p = 9;
    var k = 27;
    var h = 186;
    var j = 1;
    switch (n) {
    case o:
        if (this.aSug.length != 0 && this.iHigh) {
            this.setHighlightedValue();
            j = false
        } else {
            if (this.fld.value.length > 0) {
                if (typeof(this.oP.callback) == "function") {
                    this.clearSuggestions();
                    this.oP.callback({
                        id: this.fld.value,
                        value: this.fld.value
                    })
                }
                j = false
            } else {
                j = false
            }
        }
        break;
    case k:
        this.clearSuggestions();
        break
    }
    return j
};
_b.AutoSuggest.prototype.onKeyUp = function (j) {
    var m = (window.event) ? window.event.keyCode : j.keyCode;
    var n = 38;
    var k = 40;
    var h = 1;
    switch (m) {
    case n:
        this.changeHighlight(m);
        h = 0;
        break;
    case k:
        this.changeHighlight(m);
        h = 0;
        break;
    default:
        var g = this.fld.value.split(/[;]+/ig);
        this.getSuggestions(g[g.length - 1])
    }
    return h
};
_b.AutoSuggest.prototype.getSuggestions = function (k) {
    if (k == this.sInp) {
        return 0
    }
    _b.DOM.remE(this.idAs);
    this.sInp = k;
    if (k.length < this.oP.minchars) {
        this.aSug = [];
        this.nInpC = k.length;
        return 0
    }
    var o = this.nInpC;
    this.nInpC = k.length ? k.length : 0;
    var h = this.aSug.length;
    if (this.nInpC > o && h && h < this.oP.maxentries && this.oP.cache) {
        var j = [];
        for (var n = 0; n < h; n++) {
            if (this.aSug[n].value.substr(0, k.length).toLowerCase() == k.toLowerCase() || this.aSug[n].info.substr(0, k.length).toLowerCase() == k.toLowerCase()) {
                j.push(this.aSug[n])
            }
        }
        this.aSug = j;
        if (this.aSug.length < h) {
            var m = this;
            var p = this.sInp;
            clearTimeout(this.ajID);
            this.ajID = setTimeout(function () {
                m.doAjaxRequest(p)
            }, this.oP.delay)
        } else {
            this.createList(this.aSug)
        }
        return false
    } else {
        var m = this;
        var p = this.sInp;
        clearTimeout(this.ajID);
        this.ajID = setTimeout(function () {
            m.doAjaxRequest(p)
        }, this.oP.delay)
    }
    return false
};
_b.AutoSuggest.prototype.doAjaxRequest = function (r) {
    var p = this.fld.value.split(/[;]+/ig);
    if (r != p[p.length - 1]) {
        return false
    }
    var m = this;
    if (typeof(this.oP.script) == "function") {
        var q = this.oP.script(encodeURIComponent(this.sInp))
    } else {
        var q = this.oP.script + this.oP.varname + "=" + encodeURIComponent(this.sInp)
    }
    if (!q) {
        return false
    }
    var j = this.oP.meth;
    var r = this.sInp;
    var k = function (a) {
        m.setSuggestions(a, r)
    };
    var o = function (a) {};
    var n = new _b.Ajax();
    n.makeRequest(q, j, k, o)
};
_b.AutoSuggest.prototype.setSuggestions = function (req, input) {
    var new_value = this.fld.value.split(/[;]+/ig);
    if (input != new_value[new_value.length - 1]) {
        return false
    }
    this.aSug = [];
    if (this.oP.json) {
        var jsondata = eval("(" + req.responseText + ")");
        for (var i = 0; i < jsondata.results.length; i++) {
            this.aSug.push({
                id: jsondata.results[i].id,
                value: jsondata.results[i].value,
                info: jsondata.results[i].info,
                photo: jsondata.results[i].photo,
                photo_width: jsondata.results[i].photo_width
            })
        }
    } else {
        var xml = req.responseXML;
        var results = xml.getElementsByTagName("results")[0].childNodes;
        for (var i = 0; i < results.length; i++) {
            if (results[i].hasChildNodes()) {
                this.aSug.push({
                    id: results[i].getAttribute("id"),
                    value: results[i].childNodes[0].nodeValue,
                    info: results[i].getAttribute("info")
                })
            }
        }
    }
    this.idAs = "as_" + this.fld.id;
    this.createList(this.aSug)
};
_b.AutoSuggest.prototype.createList = function (W) {
    var H = this;
    _b.DOM.remE(this.idAs);
    this.killTimeout();
    if (W.length == 0 && !this.oP.shownoresults) {
        return false
    }
    var M = _b.DOM.cE("div", {
        id: this.idAs,
        className: this.oP.className
    });
    var T = _b.DOM.cE("div", {
        className: "as_corner"
    });
    var Q = _b.DOM.cE("div", {
        className: "as_bar"
    });
    var F = _b.DOM.cE("div", {
        className: "as_header"
    });
    F.appendChild(T);
    F.appendChild(Q);
    M.appendChild(F);
    var N = _b.DOM.cE("ul", {
        id: "as_ul"
    });
    for (var E = 0; E < W.length; E++) {
        var a = W[E].value;
        var B = W[E].info;
        var I = a.toLowerCase().indexOf(this.sInp.toLowerCase());
        var V = B.toLowerCase().indexOf(this.sInp.toLowerCase());
        if (I != -1) {
            var P = a.substring(0, I) + "<em>" + a.substring(I, I + this.sInp.length) + "</em>" + a.substring(I + this.sInp.length);
            var J = B
        } else {
            var P = a;
            var J = B.substring(0, V) + "<em>" + B.substring(I, V + this.sInp.length) + "</em>" + B.substring(V + this.sInp.length)
        }
        if (a != B) {
            P = J + " (" + P + ")"
        }
        var G = _b.DOM.cE("span", {}, P, true);
        var L = _b.DOM.cE("img", {
            src: W[E].photo,
            width: W[E].photo_width,
            border: "0"
        });
        L.removeAttribute("height");
        G.insertBefore(L, G.childNodes[0]);
        var C = _b.DOM.cE("a", {
            href: "javascript:void(0);"
        });
        var S = _b.DOM.cE("span", {
            className: "tl"
        }, " ");
        var U = _b.DOM.cE("span", {
            className: "tr"
        }, " ");
        C.appendChild(S);
        C.appendChild(U);
        C.appendChild(G);
        C.name = E + 1;
        C.id = "bsnsuggest_" + (E + 1);
        C.onclick = function () {
            H.setHighlightedValue();
            return false
        };
        C.onmouseover = function () {
            H.setHighlight(this.name)
        };
        var O = _b.DOM.cE("li", {}, C);
        N.appendChild(O)
    }
    if (W.length == 0 && this.oP.shownoresults) {
        var O = _b.DOM.cE("li", {
            className: "as_warning"
        }, this.oP.noresults);
        N.appendChild(O)
    }
    M.appendChild(N);
    var D = _b.DOM.cE("div", {
        className: "as_corner"
    });
    var A = _b.DOM.cE("div", {
        className: "as_bar"
    });
    var K = _b.DOM.cE("div", {
        className: "as_footer"
    });
    K.appendChild(D);
    K.appendChild(A);
    M.appendChild(K);
    var R = _b.DOM.getPos(this.fld);
    M.style.left = R.x + "px";
    M.style.top = (R.y + this.fld.offsetHeight + this.oP.offsety) + "px";
    M.style.width = this.fld.offsetWidth + "px";
    M.onmouseover = function () {
        H.killTimeout()
    };
    M.onmouseout = function () {
        H.resetTimeout()
    };
    document.getElementsByTagName("body")[0].appendChild(M);
    this.iHigh = 0;
    var H = this;
    this.toID = setTimeout(function () {
        H.clearSuggestions()
    }, this.oP.timeout)
};
_b.AutoSuggest.prototype.changeHighlight = function (e) {
    var d = _b.DOM.gE("as_ul");
    if (!d) {
        return false
    }
    var f;
    if (e == 40) {
        f = this.iHigh + 1
    } else {
        if (e == 38) {
            f = this.iHigh - 1
        }
    }
    if (f > d.childNodes.length) {
        f = d.childNodes.length
    }
    if (f < 1) {
        f = 1
    }
    this.setHighlight(f)
};
_b.AutoSuggest.prototype.setHighlight = function (c) {
    var d = _b.DOM.gE("as_ul");
    if (!d) {
        return false
    }
    if (this.iHigh > 0) {
        this.clearHighlight()
    }
    this.iHigh = Number(c);
    d.childNodes[this.iHigh - 1].className = "as_highlight";
    this.killTimeout()
};
_b.AutoSuggest.prototype.clearHighlight = function () {
    var b = _b.DOM.gE("as_ul");
    if (!b) {
        return false
    }
    if (this.iHigh > 0) {
        b.childNodes[this.iHigh - 1].className = "";
        this.iHigh = 0
    }
};
_b.AutoSuggest.prototype.setHighlightedValue = function () {
    if (this.iHigh) {
        var d = this.fld.value.split(/[;]+/ig);
        d.pop();
        d.push(this.aSug[this.iHigh - 1].value);
        if (this.oP.multisuggest) {
            var c = ";"
        } else {
            var c = ""
        }
        this.sInp = this.fld.value = d.join(";") + c;
        this.fld.focus();
        if (this.fld.selectionStart) {
            this.fld.setSelectionRange(this.sInp.length, this.sInp.length)
        }
        if (typeof(this.oP.callback) == "function") {
            this.oP.callback(this.aSug[this.iHigh - 1])
        }
        this.clearSuggestions()
    }
};
_b.AutoSuggest.prototype.killTimeout = function () {
    clearTimeout(this.toID)
};
_b.AutoSuggest.prototype.resetTimeout = function () {
    clearTimeout(this.toID);
    var b = this;
    this.toID = setTimeout(function () {
        b.clearSuggestions()
    }, 1000)
};
_b.AutoSuggest.prototype.clearSuggestions = function () {
    this.killTimeout();
    this.aSug = [];
    var e = _b.DOM.gE(this.idAs);
    var f = this;
    if (e) {
        var d = new _b.Fader(e, 1, 0, 250, function () {
            _b.DOM.remE(f.idAs)
        })
    }
};
if (typeof(_b.Ajax) == "undefined") {
    _b.Ajax = {}
}
_b.Ajax = function () {
    this.req = {};
    this.isIE = false
};
_b.Ajax.prototype.makeRequest = function (k, f, g, j) {
    if (f != "POST") {
        f = "GET"
    }
    this.onComplete = g;
    this.onError = j;
    var h = this;
    if (window.XMLHttpRequest) {
        this.req = new XMLHttpRequest();
        this.req.onreadystatechange = function () {
            h.processReqChange()
        };
        this.req.open("GET", k, true);
        this.req.send(null)
    } else {
        if (window.ActiveXObject) {
            this.req = new ActiveXObject("Microsoft.XMLHTTP");
            if (this.req) {
                this.req.onreadystatechange = function () {
                    h.processReqChange()
                };
                this.req.open(f, k, true);
                this.req.send()
            }
        }
    }
};
_b.Ajax.prototype.processReqChange = function () {
    if (this.req.readyState == 4) {
        if (this.req.status == 200) {
            this.onComplete(this.req)
        } else {
            this.onError(this.req.status)
        }
    }
};
if (typeof(_b.DOM) == "undefined") {
    _b.DOM = {}
}
_b.DOM.cE = function (k, p, a, m) {
    var j = document.createElement(k);
    if (!j) {
        return 0
    }
    for (var o in p) {
        j[o] = p[o]
    }
    var n = typeof(a);
    if (n == "string" && !m) {
        j.appendChild(document.createTextNode(a))
    } else {
        if (n == "string" && m) {
            j.innerHTML = a
        } else {
            if (n == "object") {
                j.appendChild(a)
            }
        }
    }
    return j
};
_b.DOM.gE = function (f) {
    var e = typeof(f);
    if (e == "undefined") {
        return 0
    } else {
        if (e == "string") {
            var d = document.getElementById(f);
            if (!d) {
                return 0
            } else {
                if (typeof(d.appendChild) != "undefined") {
                    return d
                } else {
                    return 0
                }
            }
        } else {
            if (typeof(f.appendChild) != "undefined") {
                return f
            } else {
                return 0
            }
        }
    }
};
_b.DOM.remE = function (d) {
    var c = this.gE(d);
    if (!c) {
        return 0
    } else {
        if (c.parentNode.removeChild(c)) {
            return true
        } else {
            return 0
        }
    }
};
_b.DOM.getPos = function (h) {
    var h = this.gE(h);
    var e = h;
    var g = 0;
    if (e.offsetParent) {
        while (e.offsetParent) {
            g += e.offsetLeft;
            e = e.offsetParent
        }
    } else {
        if (e.x) {
            g += e.x
        }
    }
    var e = h;
    var f = 0;
    if (e.offsetParent) {
        while (e.offsetParent) {
            f += e.offsetTop;
            e = e.offsetParent
        }
    } else {
        if (e.y) {
            f += e.y
        }
    }
    return {
        x: g,
        y: f
    }
};
if (typeof(_b.Fader) == "undefined") {
    _b.Fader = {}
}
_b.Fader = function (g, j, k, h, m) {
    if (!g) {
        return 0
    }
    this.e = g;
    this.from = j;
    this.to = k;
    this.cb = m;
    this.nDur = h;
    this.nInt = 50;
    this.nTime = 0;
    var n = this;
    this.nID = setInterval(function () {
        n._fade()
    }, this.nInt)
};
_b.Fader.prototype._fade = function () {
    this.nTime += this.nInt;
    var e = Math.round(this._tween(this.nTime, this.from, this.to, this.nDur) * 100);
    var f = e / 100;
    if (this.e.filters) {
        try {
            this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity = e
        } catch (d) {
            this.e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + e + ")"
        }
    } else {
        this.e.style.opacity = f
    }
    if (this.nTime == this.nDur) {
        clearInterval(this.nID);
        if (this.cb != undefined) {
            this.cb()
        }
    }
};
_b.Fader.prototype._tween = function (h, b, c, d) {
    return b + ((c - b) * (h / d))
};
var vsprintf = function (r, t) {
    if (!t || !t.length) {
        return r
    }
    var x = "";
    var A;
    var y = 0;
    var v;
    var m;
    var q;
    var u;
    var B;
    while (r.length > 0) {
        if (!r.match(/[%]/)) {
            x += r;
            break
        }
        A = r.match(/^([^%]+?)([%].+)?$/);
        if (A) {
            x += A[1];
            r = typeof(A[2]) ? A[2] : "";
            if (r == "") {
                break
            }
        }
        if (r.substring(0, 2) == "%%") {
            r = r.substring(2);
            x += "%";
            continue
        }
        A = r.match(/^[%](?:([0-9]+)\x24)?(\x2B)?(\x30|\x27[^$])?(\x2D)?([0-9]+)?(?:\x2E([0-9]+))?([bcdeEfosuxX])/);
        if (A) {
            q = A[7];
            u = A[6] || false;
            B = A[2] || false;
            v = (A[1] ? A[1] - 1 : y++);
            if (t[v]) {
                m = t[v]
            } else {
                throw ("Undefined argument for index " + v)
            }
            switch (typeof(m)) {
            case "number":
            case "string":
            case "boolean":
                break;
            case "undefined":
                if (m == null) {
                    m = "";
                    break
                }
            default:
                throw ("Unknown argument type: " + typeof(m));
                break
            }
            switch (q) {
            case "b":
                if (typeof(m) != "number") {
                    m = parseInt(m)
                }
                m = m.toString(2);
                break;
            case "c":
                m = String.fromCharCode(m);
                break;
            case "d":
                m = parseInt(m);
                break;
            case "E":
            case "e":
                if (typeof(m) != "number") {
                    m = parseFloat(m)
                }
                if (u) {
                    m = m.toExponential(u)
                } else {
                    m = m.toExponential()
                }
                if (q == "E") {
                    m = m.toUpperCase()
                }
                break;
            case "u":
                m = Math.abs(parseInt(m));
                break;
            case "f":
                if (u) {
                    m = parseFloat(m).toFixed(u)
                } else {
                    m = parseFloat(m)
                }
                break;
            case "o":
                if (typeof(m) != "number") {
                    m = parseInt(m)
                }
                m = m.toString(8);
                break;
            case "s":
                if (typeof(m) != "string") {
                    m = String(m)
                }
                if (u) {
                    m = m.substring(0, u)
                }
                break;
            case "x":
            case "X":
                if (typeof(m) != "number") {
                    m = parseInt(m)
                }
                m = m.toString(8);
                if (q == "X") {
                    m = m.toUpperCase()
                }
                break
            }
            if ((q == "d" || q == "e" || q == "f") && B && m > 0) {
                m = "+" + m
            }
            var z, w;
            if (A[3]) {
                z = A[3]
            } else {
                z = " "
            }
            if (A[5]) {
                w = A[5]
            } else {
                w = 0
            }
            w -= m.length;
            if (w > 0) {
                var s = function (b, c) {
                    var a = "";
                    while (c > 0) {
                        a += b;
                        c--
                    }
                    return a
                }(z, w);
                if (A[4]) {
                    x += m + s
                } else {
                    x += s + m
                }
            } else {
                x += m
            }
            r = r.substring(A[0].length)
        } else {
            throw ("Malformed expression in string: " + r)
        }
    }
    return x
};
var sprintf = function () {
    var d = [];
    var c = arguments[0];
    for (i = 1, l = arguments.length; i < l; i++) {
        d[i - 1] = arguments[i]
    }
    return vsprintf(c, d)
};
var SocialEngineAPI = {
    version: "0.1.0alpha"
};
SocialEngineAPI.Base = new Class({
    initialize: function () {
        this.version = SocialEngineAPI.version
    },
    RegisterModule: function (b) {
        b.Base = this
    }
});
SocialEngineAPI.Core = new Class({
    Base: {},
    settings: {},
    plugins: {},
    options: {
        ajaxURL: "js_api.php"
    },
    initialize: function () {},
    ImportSettings: function (b) {
        this.settings = b
    },
    ImportPlugins: function (b) {
        this.plugins = b
    }
});
if (typeof(SocialEngineAPI) == "undefined") {
    var SocialEngineAPI = {}
}
SocialEngineAPI.Language = new Class({
    Base: {},
    initialize: function () {
        this.languageVariables = new Hash()
    },
    Translate: function (c) {
        var d = this.languageVariables.get(c) || "Missing Language Variable #" + c;
        return d
    },
    TranslateFormatted: function (g, h) {
        var e = this.languageVariables.get(g) || "Missing Language Variable #" + g;
        h.unshift(e);
        var f = sprintf.run(h);
        return f
    },
    Import: function (b) {
        if ($type(b) == "object") {
            this.languageVariables.extend(b)
        }
    }
});
var SocialEngineLanguage = SocialEngineAPI.Language;
SocialEngineAPI.URL = new Class({
    Base: {},
    url_base: null,
    url_info: {},
    initialize: function () {},
    url_create: function (n, h, k, m, g) {
        var j = (SocialEngine.Core.settings.setting_url ? this.url_info[n].url_subdirectory : this.url_info[n].url_regular);
        if (!j) {
            return false
        }
        j = j.replace("$user", h);
        j = j.replace("$id1", k);
        j = j.replace("$id2", m);
        j = j.replace("$id3", g);
        return this.url_base + j
    },
    url_userdir: function (b) {
        return "uploads_user/" + (b + 999 - ((b - 1) % 1000)).toString() + "/" + b + "/"
    },
    ImportURLBase: function (b) {
        this.url_base = b
    },
    ImportURLInfo: function (b) {
        this.url_info = b
    }
});
SocialEngineAPI.Comments = new Class({
    Implements: [Options],
    Base: {},
    page: 1,
    total: 0,
    changed: false,
    isEditing: false,
    options: {
        ajaxURL: "misc_js.php",
        ajaxMethod: "post",
        ajaxSecure: false,
        canComment: false,
        commentHTML: false,
        commentCode: false,
        originalHeight: 70,
        type: false,
        typeIdentifier: false,
        typeID: false,
        paginate: false,
        cpp: false,
        commentLinks: {
            reply: false,
            walltowall: false
        },
        object_owner: false,
        object_owner_id: false,
        typeTab: false,
        typeCol: false,
        typeTabParent: false,
        typeColParent: false,
        typeChild: false
    },
    initialize: function (d) {
        this.setOptions(d);
        if (this.options.initialTotal) {
            this.total = this.options.initialTotal
        }
        var c = this;
        window.addEvent("domready", function () {
            c.showPostComment();
            c.options.originalHeight = textarea_autogrow("comment_body");
            c.getComments(1)
        })
    },
    showPostComment: function () {
        var f = "";
        f += "<div class='comment_headline'>" + this.Base.Language.Translate(854) + " (<span class='tc' id='" + this.options.type + "_" + this.options.typeID + "_totalcomments'>" + this.total + "</span>)</div>";
        if (this.options.canComment) {
            f += "<form action='misc_js.php' method='post' target='ajaxframe' name='comment_post_form'><div class='profile_postcomment'><textarea name='comment_body' id='comment_body' cols='15' class='comment_area'>" + this.Base.Language.Translate(829) + "</textarea>";
            if (this.options.commentHTML) {
                f += "<div style='margin-top: 5px;'>" + this.Base.Language.TranslateFormatted(1034, [this.options.commentHTML]) + "</div>"
            }
            if (this.options.commentCode) {
                f += "<div style='float: left; margin-top: 5px;'><a href='javascript:void(0);' onClick=\"this.blur();$('secure_image').src=$('secure_image').src+'?'+(new Date()).getTime();\"><img src='./images/secure.php' id='secure_image' border='0' height='20' width='67' class='signup_code'></a> <input type='text' name='comment_secure' id='comment_secure' class='text' size='6' maxlength='10' /> <img src='./images/icons/tip.gif' border='0' class='Tips1' style='vertical-align: middle;' title='" + this.Base.Language.Translate(856) + "' /></div>"
            }
            f += "<div style='text-align: right; margin-top: 5px;'><input type='submit' id='comment_submit' class='button' value='" + this.Base.Language.Translate(833) + "' /><input type='hidden' name='task' value='comment_post' /><input type='hidden' name='type' value='" + this.options.type + "' /><input type='hidden' name='iden' value='" + this.options.typeIdentifier + "' /><input type='hidden' name='value' value='" + this.options.typeID + "' />";
            if (this.options.object_owner && this.options.object_owner_id) {
                f += '<input type="hidden" name="object_owner" value="' + this.options.object_owner + '"><input type="hidden" name="object_owner_id" value="' + this.options.object_owner_id + '">'
            } else {
                f += '<input type="hidden" name="user" value="' + this.Base.Owner.user_info.user_username + '">'
            }
            if (this.options.typeTab) {
                f += "<input type='hidden' name='tab' value='" + this.options.typeTab + "'>"
            }
            if (this.options.typeCol) {
                f += "<input type='hidden' name='col' value='" + this.options.typeCol + "'>"
            }
            if (this.options.typeTabParent) {
                f += '<input type="hidden" name="tab_parent" value="' + this.options.typeTabParent + '">'
            }
            if (this.options.typeColParent) {
                f += '<input type="hidden" name="col_parent" value="' + this.options.typeColParent + '">'
            }
            if (this.options.typeChild) {
                f += '<input type="hidden" name="child" value="1">'
            }
            f += "</div><div id='comment_error' style='color: #FF0000; display: none;'></div></div></form>"
        }
        f += '<div style="display: none;" id="confirmcommentdelete"><div style="margin-top: 10px;">' + this.Base.Language.Translate(1026) + '</div><br /><form action="misc_js.php" method="post" target="ajaxframe"><input type="submit" class="button" value="' + this.Base.Language.Translate(175) + '" onClick="parent.TB_remove();"> <input type="button" class="button" value="' + this.Base.Language.Translate(39) + '" onClick="parent.TB_remove();"><input type="hidden" name="task" value="comment_delete"><input type="hidden" name="comment_id" id="del_comment_id" value="0"><input type="hidden" name="type" value="' + this.options.type + '"><input type="hidden" name="iden" value="' + this.options.typeIdentifier + '"><input type="hidden" name="value" value="' + this.options.typeID + '">';
        if (this.options.object_owner && this.options.object_owner_id) {
            f += '<input type="hidden" name="object_owner" value="' + this.options.object_owner + '"><input type="hidden" name="object_owner_id" value="' + this.options.object_owner_id + '">'
        } else {
            f += '<input type="hidden" name="user" value="' + this.Base.Owner.user_info.user_username + '">'
        }
        if (this.options.typeTab) {
            f += '<input type="hidden" name="tab" value="' + this.options.typeTab + '">'
        }
        if (this.options.typeCol) {
            f += '<input type="hidden" name="col" value="' + this.options.typeCol + '">'
        }
        if (this.options.typeTabParent) {
            f += '<input type="hidden" name="tab_parent" value="' + this.options.typeTabParent + '">'
        }
        if (this.options.typeColParent) {
            f += '<input type="hidden" name="col_parent" value="' + this.options.typeColParent + '">'
        }
        if (this.options.typeChild) {
            f += '<input type="hidden" name="child" value="1">'
        }
        f += "</form></div>";
        var e = $(this.options.type + "_" + this.options.typeID + "_postcomment");
        e.innerHTML = f;
        var d = this;
        if (this.options.canComment) {
            e.getElement("form").addEvent("submit", function (a) {
                d.checkText(a)
            });
            e.getElement("textarea").addEvent("focus", function () {
                d.removeText(this)
            });
            e.getElement("textarea").addEvent("blur", function () {
                d.addText(this)
            });
            e.getElement("form").addEvent("submit", function (a) {
                d.doCommentPost(a)
            })
        }
    },
    doCommentPost: function (j) {
        var k = new Event(j);
        var g = {
            task: "comment_post",
            type: this.options.type,
            iden: this.options.typeIdentifier,
            value: this.options.typeID,
            tab: this.options.typeTab,
            col: this.options.typeCol
        };
        if (this.options.typeTabParent) {
            g.tab_parent = this.options.typeTabParent
        }
        if (this.options.typeColParent) {
            g.col_parent = this.options.typeColParent
        }
        if (this.options.typeChild) {
            g.child = this.options.typeChild
        }
        if (this.options.object_owner && this.options.object_owner_id) {
            g.object_owner = this.options.object_owner;
            g.object_owner_id = this.options.object_owner_id
        } else {
            g.user = this.Base.Owner.user_info.user_username
        }
        if ($type(document.comment_post_form.comment_body)) {
            g.comment_body = document.comment_post_form.comment_body.value
        }
        if ($type(document.comment_post_form.comment_secure)) {
            g.comment_secure = document.comment_post_form.comment_secure.value
        }
        var h = this;
        var e = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: g,
            onComplete: function (b, a) {
                h.addComment(b.is_error, b.comment_body, b.comment_date)
            }
        }).send();
        k.stop()
    },
    doCommentEdit: function () {
        var e = {
            task: "comment_edit",
            type: this.options.type,
            iden: this.options.typeIdentifier,
            value: this.options.typeID,
            user: this.Base.Owner.user_info.user_username
        };
        if ($type(document.editCommentForm.comment_id)) {
            e.comment_id = document.editCommentForm.comment_id.value
        }
        if ($type(document.editCommentForm.comment_edit)) {
            e.comment_edit = document.editCommentForm.comment_edit.value
        }
        var f = this;
        var d = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: e,
            onComplete: function (b, a) {
                f.getComments()
            }
        }).send()
    },
    doCommentDelete: function (k, e) {
        var m = new Event(k);
        var h = {
            task: "comment_delete",
            comment_id: e,
            type: this.options.type,
            iden: this.options.typeIdentifier,
            value: this.options.typeID,
            tab: this.options.typeTab,
            col: this.options.typeCol,
            user: this.Base.Owner.user_info.user_username
        };
        if (this.options.typeTabParent) {
            h.tab_parent = this.options.typeTabParent
        }
        if (this.options.typeColParent) {
            h.col_parent = this.options.typeColParent
        }
        if (this.options.typeChild) {
            h.child = this.options.typeChild
        }
        if (this.options.object_owner) {
            h.object_owner = this.options.object_owner
        }
        if (this.options.object_owner_id) {
            h.object_owner_id = this.options.object_owner_id
        }
        if ($type(document.commentDeleteForm.comment_body)) {
            h.comment_body = document.commentDeleteForm.comment_body.value
        }
        if ($type(document.commentDeleteForm.comment_secure)) {
            h.comment_secure = document.commentDeleteForm.comment_secure.value
        }
        var j = this;
        var n = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: h,
            onComplete: function (b, a) {
                j.getComments()
            }
        }).send();
        m.stop()
    },
    
    getComments: function (k) {
        if (k == "next") {
            this.page++
        } else {
            if (k == "previous") {
                this.page--
            } else {
                if ($type(k)) {
                    this.page = k
                }
            }
        }
        if (this.options.paginate) {
            window.scroll(0, 0)
        } else {
            this.options.cpp = this.total
        }
        if (this.options.object_owner && this.options.object_owner_id) {
            var m = this.options.object_owner;
            var h = this.options.object_owner_id;
            var g = ""
        } else {
            var m = "";
            var h = "";
            var g = this.Base.Owner.user_info.user_username
        }
        var j = this;
        var n = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "comment_get",
                user: g,
                object_owner: m,
                object_owner_id: h,
                type: this.options.type,
                iden: this.options.typeIdentifier,
                value: this.options.typeID,
                cpp: this.options.cpp,
                p: this.page
            },
            onComplete: function (b, a) {
                j.updateComments(b)
            }
        });
        n.send()
    },
    updateComments: function (A) {
        if ($type(A) != "object") {
            return false
        }
        this.total = parseInt(A.total_comments) || 0;
        this.page = A.p;
        var B = A.maxpage;
        var o = A.p_start;
        var p = A.p_end;
        var u = $(this.options.type + "_" + this.options.typeID + "_totalcomments");
        var v = $(this.options.type + "_" + this.options.typeID + "_comments");
        var r = $H(A.comments);
        u.innerHTML = this.total;
        var w = document.createElement("div");
        v.empty();
        var q = this;
        if (q.Base.Core.settings.setting_url) {
            var x = "?"
        } else {
            var x = "&"
        }
        r.each(function (e, c) {
            var b = new Element("div", {
                id: "comment_" + c
            });
            var a = "<div style='margin-top: 10px; margin-bottom: 20px;'>";
            if (e.comment_authoruser_id && e.comment_authoruser_exists) {
                a += "<div style='float: left; text-align: center; width: 90px;'><a href='" + e.comment_authoruser_url + "'><img src='" + e.comment_authoruser_photo + "' class='photo' width='" + e.comment_authoruser_photo_width + "' border='0'></a></div>"
            } else {
                a += "<div style='float: left; text-align: center; width: 90px;'><img src='./images/nophoto.gif' class='photo' width='75' border='0'></div>"
            }
            a += "<div style='overflow: hidden;'>";
            if (!e.comment_authoruser_id) {
                a += "<div class='profile_comment_author'><b>" + q.Base.Language.Translate(835) + "</b></div>"
            } else {
                if (!e.comment_authoruser_exists) {
                    a += "<div class='profile_comment_author'><b>" + q.Base.Language.Translate(1071) + "</b></div>"
                } else {
                    a += "<div class='profile_comment_author'><a href='" + e.comment_authoruser_url + "'><b>" + e.comment_authoruser_displayname + "</b></a></div>"
                }
            }
            
            a += "<div class='profile_comment_date'>" + e.comment_date + "</div>";
            b.setProperty("html", e.comment_body);
            a += "<div class='profile_comment_body' id='profile_comment_body_" + c + "'>" + e.comment_body + "&nbsp;</div>";
            a += "<div class='profile_comment_links'>";
            var d = new Array();
            if (q.Base.Viewer.user_exists && e.comment_authoruser_id && e.comment_authoruser_exists) {
                if (q.options.commentLinks.reply && q.Base.Viewer.user_info.user_id == q.Base.Owner.user_info.user_id && q.Base.Viewer.user_info.user_id != e.comment_authoruser_id) {
                    d.push("<a href='profile.php?user=" + e.comment_authoruser_username + "&v=comments'>" + q.Base.Language.Translate(787) + "</a>")
                }
                if (q.options.commentLinks.walltowall && e.comment_authoruser_id != q.Base.Owner.user_info.user_id && e.comment_authoruser_private == false) {
                    d.push("<a href=\"javascript:TB_show('" + q.Base.Language.Translate(1032) + "', 'profile_comments.php?user=" + q.Base.Owner.user_info.user_username + "&user2=" + e.comment_authoruser_username + "&TB_iframe=true&height=450&width=550', '', './images/trans.gif');\">" + q.Base.Language.Translate(891) + "</a>")
                }
                if (e.comment_authoruser_id != q.Base.Viewer.user_info.user_id) {
                    d.push("<a href=\"javascript:TB_show('" + q.Base.Language.Translate(784) + "', 'user_messages_new.php?to_user=" + e.comment_authoruser_displayname + "&to_id=" + e.comment_authoruser_username + "&TB_iframe=true&height=400&width=450', '', './images/trans.gif');\">" + q.Base.Language.Translate(834) + "</a>")
                }
                if (e.comment_authoruser_id == q.Base.Viewer.user_info.user_id) {
                    d.push('<a class="commentEditLink" href="javascript:void(0);" id=\'comment_edit_link_' + c + "'>" + q.Base.Language.Translate(187) + "</a>")
                }
            }
            if ((e.comment_authoruser_exists && e.comment_authoruser_id == q.Base.Viewer.user_info.user_id) || (q.Base.Viewer.user_exists && q.Base.Viewer.user_info.user_id == q.Base.Owner.user_info.user_id)) {
                d.push('<a class="commentDeleteLink" href="javascript:void(0);" id=\'comment_delete_link_' + c + "'>" + q.Base.Language.Translate(155) + "</a>")
            }
            a += d.join("&nbsp;-&nbsp;");
            a += "&nbsp;</div></div></div>";
            b.setProperty("html", a);
            b.inject(v);
            if (b.getElement(".commentEditLink")) {
                b.getElement(".commentEditLink").addEvent("click", function () {
                    q.editComment(c)
                })
            }
            if (b.getElement(".commentDeleteLink")) {
                b.getElement(".commentDeleteLink").addEvent("click", function () {
                    q.confirmDelete(c)
                })
            }
        });
        if (this.options.paginate && this.total > this.options.cpp) {
            var t = new Element("div", {
                styles: {
                    "text-align": "center"
                }
            });
            var s = new Element("div", {
                styles: {
                    "text-align": "center"
                }
            });
            if (this.page > 1) {
                var y = "<a href='javascript:void(0);' id='comment_last_page_top'>&#171; " + q.Base.Language.Translate(182) + "</a>";
                var z = "<a href='javascript:void(0);' id='comment_last_page_bottom'>&#171; " + q.Base.Language.Translate(182) + "</a>"
            } else {
                var y = "<font class='disabled'>&#171; " + q.Base.Language.Translate(182) + "</font>";
                var z = "<font class='disabled'>&#171; " + q.Base.Language.Translate(182) + "</font>"
            }
            if (o == p) {
                y += "&nbsp;|&nbsp; " + this.Base.Language.TranslateFormatted(184, [o, this.total]) + "&nbsp;|&nbsp;";
                z += "&nbsp;|&nbsp; " + this.Base.Language.TranslateFormatted(184, [o, this.total]) + "&nbsp;|&nbsp;"
            } else {
                y += "&nbsp;|&nbsp; " + this.Base.Language.TranslateFormatted(185, [o, p, this.total]) + "&nbsp;|&nbsp;";
                z += "&nbsp;|&nbsp; " + this.Base.Language.TranslateFormatted(185, [o, p, this.total]) + "&nbsp;|&nbsp;"
            }
            if (this.page != B) {
                y += "<a href='javascript:void(0);' id='comment_next_page_top'>" + q.Base.Language.Translate(183) + " &#187;</a>";
                z += "<a href='javascript:void(0);' id='comment_next_page_bottom'>" + q.Base.Language.Translate(183) + " &#187;</a>"
            } else {
                y += "<font class='disabled'>" + q.Base.Language.Translate(183) + " &#187;</font>";
                z += "<font class='disabled'>" + q.Base.Language.Translate(183) + " &#187;</font>"
            }
            t.setProperty("html", y);
            s.setProperty("html", z);
            t.inject(v, "top");
            s.inject(v);
            if (t.getElement("a[id=comment_last_page_top]")) {
                t.getElement("a[id=comment_last_page_top]").addEvent("click", function () {
                    q.getComments("previous")
                })
            }
            if (s.getElement("a[id=comment_last_page_bottom]")) {
                s.getElement("a[id=comment_last_page_bottom]").addEvent("click", function () {
                    q.getComments("previous")
                })
            }
            if (t.getElement("a[id=comment_next_page_top]")) {
                t.getElement("a[id=comment_next_page_top]").addEvent("click", function () {
                    q.getComments("next")
                })
            }
            if (s.getElement("a[id=comment_next_page_bottom]")) {
                s.getElement("a[id=comment_next_page_bottom]").addEvent("click", function () {
                    q.getComments("next")
                })
            }
        }
    },
    addComment: function (f, e, d) {
        if (!this.options.canComment) {
            return false
        }
        if (f) {
            $("comment_error").style.display = "block";
            if (!e.trim()) {
                this.addText($("comment_body"));
                $("comment_error").innerHTML = this.Base.Language.Translate(831)
            } else {
                $("comment_error").innerHTML = this.Base.Language.Translate(832)
            }
            $("comment_submit").value = this.Base.Language.Translate(833);
            $("comment_submit").disabled = false
        } else {
            $("comment_error").style.display = "none";
            $("comment_error").innerHTML = "";
            $("comment_body").value = "";
            $("comment_body").style.height = this.options.originalHeight + "px";
            this.addText($("comment_body"));
            $("comment_submit").value = this.Base.Language.Translate(833);
            $("comment_submit").disabled = false;
            if ($("comment_secure")) {
                $("comment_secure").value = "";
                $("secure_image").src = $("secure_image").src + "?" + (new Date()).getTime()
            }
            this.page = 1;
            this.total++;
            this.getComments()
        }
    },
    editComment: function (n) {
        var j = this;
        if (this.isEditing) {
            return false
        }
        this.isEditing = true;
        var g = $("profile_comment_body_" + n);
        var h = g.offsetHeight + 10;
        var m = g.innerHTML.replace(/<br>/gi, "\r\n").replace(/>/gi, "&gt;");
        var k = "";
        k += "<form action='misc_js.php' method='post' target='ajaxframe' name='editCommentForm'>";
        k += "<textarea name='comment_edit' id='comment_edit_" + n + "' style='height: " + h + " px; width: 100%;'>" + m + "</textarea>";
        k += "<input type='hidden' name='task' value='comment_edit'>";
        k += "<input type='hidden' name='comment_id' value='" + n + "'>";
        k += "<input type='hidden' name='type' value='" + this.options.type + "'>";
        k += "<input type='hidden' name='iden' value='" + this.options.typeIdentifier + "'>";
        k += "<input type='hidden' name='value' value='" + this.options.typeID + "'>";
        if (this.options.typeTab) {
            k += '<input type="hidden" name="tab" value="' + this.options.typeTab + '">'
        }
        if (this.options.typeCol) {
            k += '<input type="hidden" name="col" value="' + this.options.typeCol + '">'
        }
        if (this.options.typeTabParent) {
            k += '<input type="hidden" name="tab_parent" value="' + this.options.typeTabParent + '">'
        }
        if (this.options.typeColParent) {
            k += '<input type="hidden" name="col_parent" value="' + this.options.typeColParent + '">'
        }
        if (this.options.typeChild) {
            k += '<input type="hidden" name="child" value="1">'
        }
        k += "</form>";
        g.innerHTML = k;
        textarea_autogrow("comment_edit_" + n);
        $("comment_edit_" + n).focus();
        $("comment_edit_" + n).addEvent("blur", function () {
            j.doCommentEdit();
            j.isEditing = false
        })
    },
    confirmDelete: function (d) {
        $("del_comment_id").value = d;
        TB_show(this.Base.Language.Translate(1025), "#TB_inline?height=100&width=300&inlineId=confirmcommentdelete", "", "../images/trans.gif");
        var c = this;
        $("TB_window").getElement("form").name = "commentDeleteForm";
        $("TB_window").getElement("form").addEvent("submit", function (a) {
            c.doCommentDelete(a, d)
        })
    },
    removeText: function (b) {
        if (!this.changed) {
            b.value = "";
            b.style.color = "#000000";
            this.changed = true
        }
    },
    addText: function (b) {
        if (!b.value.trim()) {
            b.value = this.Base.Language.Translate(829);
            b.style.color = "#888888";
            this.changed = false
        }
    },
    checkText: function (b) {
        if (!this.changed) {
            $("comment_body").value = ""
        }
        $("comment_submit").value = this.Base.Language.Translate(830);
        $("comment_submit").disabled = true
    }
});
SocialEngineAPI.Tags = new Class({
    Implements: [Options],
    Base: {},
    isTagging: false,
    newtag: false,
    tags: [],
    options: {
        ajaxURL: "misc_js.php",
        ajaxMethod: "post",
        ajaxSecure: false,
        canTag: false,
        type: false,
        media_id: false,
        media_dir: false,
        object_owner: false,
        object_owner_id: false
    },
    initialize: function (d) {
        this.setOptions(d);
        if (this.options.initialTotal) {
            this.total = this.options.initialTotal
        }
        var c = this;
        window.addEvent("domready", function () {
            c.showTagForm()
        })
    },
    showTagForm: function () {
        var h = "";
        var j = this;
        if (this.options.canTag) {
            h += "<div class='media_photo_tagform_titlebar'><img src='images/icons/photos16.gif' class='icon' />" + this.Base.Language.Translate(1212) + "</div><div style='padding: 7px;'><div style='text-align: left;'><div style='font-size: 7pt; margin-bottom: 5px;'>" + this.Base.Language.Translate(1213) + "</div><div style='text-align: center;'><input type='text' style='width: 130px; padding-left: 4px; font-size: 8pt;' name='media_photo_tag' id='media_photo_tag' class='text' maxlength='40'/></div></div><div id='media_photo_friendlist' class='media_photo_friendlist'>";
            if (j.Base.Viewer.user_exists) {
                h += "<div><a href='javascript:void(0)' id='tag_me'>" + j.Base.Viewer.user_displayname + j.Base.Language.Translate(1214) + "</a></div>"
            }
            h += "</div><div><input type='button' class='button' name='save' id='tag_save' value='" + j.Base.Language.Translate(1215) + "' />&nbsp;&nbsp;<input type='button' class='button' id='tag_cancel' name='cancel' value='" + j.Base.Language.Translate(39) + "' /></div></div>";
            var g = new Element("div", {
                id: "media_photo_tagform",
                "class": "media_photo_tagform",
                html: h
            });
            var k = $("media_photo_div");
            g.inject(k);
            if (g.getElement("input[id=tag_cancel]")) {
                g.getElement("input[id=tag_cancel]").addEvent("click", function () {
                    j.cancelTag()
                })
            }
            if (g.getElement("input[id=tag_save]")) {
                g.getElement("input[id=tag_save]").addEvent("click", function () {
                    j.saveTag(0)
                })
            }
            if (g.getElement("a[id=tag_me]")) {
                g.getElement("a[id=tag_me]").addEvent("click", function () {
                    j.saveTag(j.Base.Viewer.user_info.user_id)
                })
            }
            var f = new Request.JSON({
                url: "misc_js.php?task=friends_all",
                secure: this.options.ajaxSecure,
                onComplete: function (a) {
                    j.addFriendToList(a.friends)
                }
            }).send()
        }
    },
    addFriendToList: function (d) {
        var c = this;
        d.each(function (a) {
            for (var h in a) {
                var b = new Element("div", {
                    id: "friend_div_" + h
                });
                var g = new Element("a", {
                    href: "javascript:void(0)",
                    id: "friend_link_" + h,
                    html: a[h]
                }).inject(b);
                b.inject($("media_photo_friendlist"));
                $("friend_link_" + h).addEvent("click", function () {
                    c.saveTag(h)
                })
            }
        })
    },
    insertTag: function (z, o, n, q, s, p, r, x) {
        var u = "";
        var t = this;
        if ($("media_tags").style.display == "none") {
            $("media_tags").style.display = "block"
        } else {
            if (t.tags.length != 0) {
                u = '<span id="tag_comma_' + z + '">, </span>'
            }
        }
        var w = new Element("span", {
            id: "full_tag_" + z,
            html: u
        });
        if (o != "") {
            var v = new Element("a", {
                href: o,
                id: "tag_link_" + z,
                html: n
            }).inject(w)
        } else {
            var v = new Element("span", {
                id: "tag_link_" + z,
                html: n,
                styles: {
                    cursor: "pointer"
                }
            }).inject(w)
        }
        if (t.Base.Viewer.user_exists && (t.Base.Viewer.user_info.user_username == x || t.Base.Viewer.user_info.user_username == t.Base.Owner.user_info.user_username)) {
            var y = $(w).get("html");
            $(w).set("html", y, " (<a href='javascript:void(0);' id='new_removetag_link'>" + t.Base.Language.Translate(1228) + "</a>)")
        }
        w.inject($("media_tags"));
        t.createTag(z, n, q, s, p, r);
        $("tag_link_" + z).addEvent("mouseover", function () {
            t.showTag(z)
        });
        $("tag_link_" + z).addEvent("mouseout", function () {
            t.hideTag(z)
        });
        if ($("new_removetag_link")) {
            $("new_removetag_link").addEvent("click", function () {
                t.removeTag(z)
            });
            $("new_removetag_link").set("id", "removetag_link_" + z)
        }
        t.tags.push(z)
    },
    createTag: function (m, o, p, h, n, j) {
        var k = this;
        new Element("div", {
            id: "tag_" + m,
            html: '<img src="./images/trans.gif" width="100%" height="100%" />',
            "class": "tag_div_hidden",
            styles: {
                width: (parseInt(n) - 4) + "px",
                height: (parseInt(j) - 4) + "px",
                top: p + "px",
                left: h + "px"
            }
        }).inject($("media_photo_div"));
        new Element("div", {
            id: "tag_label_" + m,
            html: o,
            "class": "tag_label",
            styles: {
                display: "none",
                top: (parseInt(p) + parseInt(j) + 10) + "px",
                left: h + "px"
            }
        }).inject($("media_photo_div"));
        $("tag_" + m).addEvent("mouseover", function () {
            k.showTag(m)
        });
        $("tag_" + m).addEvent("mouseout", function () {
            k.hideTag(m)
        })
    },
    showTag: function (b) {
        $("tag_" + b).className = "tag_div";
        $("tag_label_" + b).style.display = "block"
    },
    hideTag: function (b) {
        $("tag_" + b).className = "tag_div_hidden";
        $("tag_label_" + b).style.display = "none"
    },
    addTag: function () {
        if (!this.isTagging) {
            this.isTagging = true;
            this.newtag = new MooCrop("media_photo");
            var c = this;
            var d = $("media_photo_tagform").inject(c.newtag.wrapper);
            d.setStyles({
                top: this.newtag.crop.bottom + 10,
                left: this.newtag.crop.right + 10,
                display: "block"
            });
            this.newtag.addEvent("onBegin", function (a, b, g, h) {
                d.setStyle("display", "none")
            });
            this.newtag.addEvent("onCrop", function (a, b, g, h) {
                d.setStyles({
                    top: b.bottom + 10,
                    left: b.right + 10,
                    display: "none"
                })
            });
            this.newtag.addEvent("onComplete", function (a, b, g, h) {
                d.setStyle("display", "block")
            })
        }
    },
    cancelTag: function () {
        if (this.isTagging) {
            $("media_photo_tag").value = "";
            $("media_photo_tagform").inject("media_photo_div").setStyle("display", "none");
            var b = this.newtag.removeOverlay.bind(this.newtag);
            b();
            this.isTagging = false
        }
    },
    saveTag: function (o) {
        if (this.isTagging) {
            if (this.options.object_owner && this.options.object_owner_id) {
                var m = this.options.object_owner;
                var h = this.options.object_owner_id;
                var p = ""
            } else {
                var m = "";
                var h = "";
                var p = this.Base.Owner.user_info.user_username
            }
            var k = this;
            var n = new Request.JSON({
                url: this.options.ajaxURL,
                method: this.options.ajaxMethod,
                secure: this.options.ajaxSecure,
                data: {
                    task: "tag_do",
                    ajax: true,
                    mediatag_user_id: o,
                    mediatag_text: $("media_photo_tag").value,
                    mediatag_x: this.newtag.crop.top,
                    mediatag_y: this.newtag.crop.left,
                    mediatag_height: this.newtag.crop.height,
                    mediatag_width: this.newtag.crop.width,
                    user: p,
                    object_owner: m,
                    object_owner_id: h,
                    type: this.options.type,
                    media_id: this.options.media_id,
                    media_dir: this.options.media_dir
                },
                onComplete: function (a) {
                    if ($type(a.mediatag_id)) {
                        k.insertTag(a.mediatag_id, a.mediatag_link, a.mediatag_text, a.mediatag_x, a.mediatag_y, a.mediatag_width, a.mediatag_height, a.mediatag_user_username)
                    }
                }
            }).send();
            $("media_photo_tag").value = "";
            $("media_photo_tagform").inject("media_photo_div").setStyle("display", "none");
            var j = this.newtag.removeOverlay.bind(this.newtag);
            j();
            this.isTagging = false
        }
    },
    removeTag: function (k) {
        if (this.options.object_owner && this.options.object_owner_id) {
            var m = this.options.object_owner;
            var h = this.options.object_owner_id;
            var g = ""
        } else {
            var m = "";
            var h = "";
            var g = this.Base.Owner.user_info.user_username
        }
        var j = this;
        var n = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "tag_remove",
                ajax: true,
                mediatag_id: k,
                user: g,
                object_owner: m,
                object_owner_id: h,
                type: this.options.type,
                media_id: this.options.media_id
            }
        }).send();
        $("tag_" + k).destroy();
        $("tag_label_" + k).destroy();
        $("full_tag_" + k).destroy();
        if (this.tags.indexOf(k) == 0 && $("tag_comma_" + this.tags[1])) {
            $("tag_comma_" + this.tags[1]).destroy()
        }
        this.tags.splice(this.tags.indexOf(k), 1);
        if (this.tags.length == 0) {
            $("media_tags").style.display = "none"
        }
    }
});
var MooCrop = new Class({
    calculateHandles: true,
    current: {},
    options: {
        maskColor: "black",
        maskOpacity: ".3",
        handleColor: "#FFFFFF",
        handleWidth: "5px",
        handleHeight: "5px",
        cropBorder: "1px dashed #FFFFFF",
        min: {
            width: 50,
            height: 50
        },
        showMask: true,
        showHandles: false
    },
    initialize: function (c, d) {
        this.setOptions(d);
        this.img = $(c);
        if (this.img.get("tag") != "img") {
            return false
        }
        this.resizeFunc = this.refresh.bindWithEvent(this);
        this.removeFunc = this.removeListener.bind(this);
        this.buildOverlay();
        this.setup()
    },
    setup: function () {
        $(this.cropArea).setStyles({
            width: this.options.min.width,
            height: this.options.min.height,
            top: (this.img.height - this.options.min.height) / 2,
            left: (this.img.width - this.options.min.width) / 2
        });
        this.current.crop = this.crop = this.getCropArea();
        this.handleWidthOffset = this.options.handleWidth.toInt() / 2;
        this.handleHeightOffset = this.options.handleHeight.toInt() / 2;
        this.fixBoxModel();
        this.drawMasks();
        this.positionHandles()
    },
    getCropArea: function () {
        var b = this.cropArea.getCoordinates();
        b.left -= this.offsets.x;
        b.right -= this.offsets.x;
        b.top -= this.offsets.y;
        b.bottom -= this.offsets.y;
        return b
    },
    fixBoxModel: function () {
        var d = this.boxDiff = (this.crop.width - this.options.min.width) / 2;
        var b = this.bounds = {
            top: d,
            left: d,
            right: this.img.width + (d * 2),
            bottom: this.img.height + (d * 2),
            width: this.options.min.width + (d * 2),
            height: this.options.min.height + (d * 2)
        };
        this.wrapper.setStyles({
            width: b.right,
            height: b.bottom,
            background: "url(" + this.img.src + ") no-repeat " + d + "px " + d + "px"
        });
        this.north.setStyle("width", b.right);
        this.south.setStyle("width", b.right)
    },
    activate: function (d, c) {
        d.stop();
        this.current = {
            x: d.page.x,
            y: d.page.y,
            handle: c,
            crop: this.current.crop
        };
        if (this.current.handle == "NESW" && !this.options.showHandles) {
            this.hideHandles()
        }
        this.fireEvent("onBegin", [this.img.src, this.getCropInfo(), this.bounds, c]);
        document.addEvent("mousemove", this.resizeFunc);
        document.addEvent("mouseup", this.removeFunc)
    },
    removeListener: function () {
        if (this.current.handle == "NESW" && !this.options.showHandles) {
            this.showHandles()
        }
        document.removeEvent("mousemove", this.resizeFunc);
        document.removeEvent("mouseup", this.removeFunc);
        this.crop = this.current.crop;
        this.fireEvent("onComplete", [this.img.src, this.getCropInfo(), this.bounds, this.current.handle])
    },
    refresh: function (s) {
        var q = this.current.x - s.page.x;
        var r = this.current.y - s.page.y;
        var m = this.bounds;
        var n = this.crop;
        var p = this.current.handle;
        var b = {};
        var c = (p.length > 2) ? true : false;
        if (p.contains("S")) {
            if (n.bottom - r > m.bottom) {
                r = n.bottom - m.bottom
            }
            if (!c) {
                if ((n.height - r) < m.height) {
                    r = n.height - m.height
                }
                b.height = n.height - r
            }
        }
        if (p.contains("N")) {
            if (n.top - r < m.top) {
                r = n.top
            }
            if (!c) {
                if ((n.height + r) < m.height) {
                    r = m.height - n.height
                }
                b.height = n.height + r
            }
            b.top = n.top - r
        }
        if (p.contains("E")) {
            if (n.right - q > m.right) {
                q = n.right - m.right
            }
            if (!c) {
                if ((n.width - q) < m.width) {
                    q = n.width - m.width
                }
                b.width = n.width - q
            }
        }
        if (p.contains("W")) {
            if (n.left - q < m.left) {
                q = n.left
            }
            if (!c) {
                if ((n.width + q) < m.width) {
                    q = m.width - n.width
                }
                b.width = n.width + q
            }
            b.left = n.left - q
        }
        var o = $merge(b);
        if ($defined(b.width)) {
            b.width -= this.boxDiff * 2
        }
        if ($defined(b.height)) {
            b.height -= this.boxDiff * 2
        }
        this.cropArea.setStyles(b);
        this.getCurrentCoords(o);
        this.drawMasks();
        this.positionHandles();
        this.fireEvent("onCrop", [this.img.src, this.getCropInfo(), m, p])
    },
    getCurrentCoords: function (c) {
        var d = $merge(this.crop);
        if ($defined(c.left)) {
            d.left = c.left;
            if ($defined(c.width)) {
                d.width = c.width
            } else {
                d.right = d.left + d.width
            }
        }
        if ($defined(c.top)) {
            d.top = c.top;
            if ($defined(c.height)) {
                d.height = c.height
            } else {
                d.bottom = d.top + d.height
            }
        }
        if ($defined(c.width) && !$defined(c.left)) {
            d.width = c.width;
            d.right = d.left + d.width
        }
        if ($defined(c.height) && !$defined(c.top)) {
            d.height = c.height;
            d.bottom = d.top + d.height
        }
        this.current.crop = d
    },
    drawMasks: function () {
        if (!this.options.showMask) {
            return
        }
        var b = this.bounds;
        var c = this.current.crop;
        var f = this.current.handle;
        this.north.setStyle("height", c.top + "px");
        this.south.setStyle("height", b.bottom - c.bottom + "px");
        this.east.setStyles({
            height: c.height + "px",
            width: b.right - c.right + "px",
            top: c.top + "px",
            left: c.right + "px"
        });
        this.west.setStyles({
            height: c.height + "px",
            width: c.left + "px",
            top: c.top + "px"
        })
    },
    positionHandles: function () {
        if (!this.calculateHandles) {
            return
        }
        var f = this.current.crop;
        var e = this.handleWidthOffset;
        var c = this.handleHeightOffset;
        this.handles.get("N").setStyles({
            left: f.width / 2 - e + "px",
            top: -c + "px"
        });
        this.handles.get("NE").setStyles({
            left: f.width - e + "px",
            top: -c + "px"
        });
        this.handles.get("E").setStyles({
            left: f.width - e + "px",
            top: f.height / 2 - c + "px"
        });
        this.handles.get("SE").setStyles({
            left: f.width - e + "px",
            top: f.height - c + "px"
        });
        this.handles.get("S").setStyles({
            left: f.width / 2 - e + "px",
            top: f.height - c + "px"
        });
        this.handles.get("SW").setStyles({
            left: -e + "px",
            top: f.height - c + "px"
        });
        this.handles.get("W").setStyles({
            left: -e + "px",
            top: f.height / 2 - c + "px"
        });
        this.handles.get("NW").setStyles({
            left: -e + "px",
            top: -c + "px"
        })
    },
    hideHandles: function () {
        this.calculateHandles = false;
        this.handles.each(function (b) {
            b.setStyle("display", "none")
        })
    },
    showHandles: function () {
        this.calculateHandles = true;
        this.positionHandles();
        this.handles.each(function (b) {
            b.setStyle("display", "block")
        })
    },
    buildOverlay: function () {
        var c = this.options;
        this.wrapper = new Element("div", {
            styles: {
                "z-index": 100,
                position: "relative",
                width: this.img.width,
                height: this.img.height,
                background: "url(" + this.img.src + ") no-repeat",
                "float": this.img.getStyle("float"),
                "margin-left": "auto",
                "margin-right": "auto"
            }
        }).injectBefore(this.img);
        this.img.setStyle("display", "none");
        this.offsets = {
            x: this.wrapper.getLeft(),
            y: this.wrapper.getTop()
        };
        this.wrapper.addEvent("mouseover", function (a) {
            return false
        });
        if (this.options.showMask) {
            var d = {
                position: "absolute",
                overflow: "hidden",
                "background-color": c.maskColor,
                opacity: c.maskOpacity
            };
            this.north = new Element("div", {
                styles: $merge(d, {
                    left: "0px"
                })
            }).injectInside(this.wrapper);
            this.south = new Element("div", {
                styles: $merge(d, {
                    bottom: "0px",
                    left: "0px"
                })
            }).injectInside(this.wrapper);
            this.east = new Element("div", {
                styles: d
            }).injectInside(this.wrapper);
            this.west = new Element("div", {
                styles: $merge(d, {
                    left: "0px"
                })
            }).injectInside(this.wrapper)
        }
        this.cropArea = new Element("div", {
            styles: {
                position: "absolute",
                top: "0px",
                left: "0px",
                border: c.cropBorder,
                cursor: "move"
            },
            events: {
                dblclick: function () {
                    this.fireEvent("onDblClk", [this.img.src, this.getCropInfo(), this.bounds])
                }.bind(this),
                mousedown: this.activate.bindWithEvent(this, "NESW")
            }
        }).injectInside(this.wrapper);
        this.handles = new Hash();
        ["N", "NE", "E", "SE", "S", "SW", "W", "NW"].each(function (a) {
            this.handles.set(a, new Element("div", {
                styles: {
                    position: "absolute",
                    "background-color": c.handleColor,
                    width: c.handleWidth,
                    height: c.handleHeight,
                    overflow: "hidden",
                    cursor: (a.toLowerCase() + "-resize")
                },
                events: {
                    mousedown: this.activate.bindWithEvent(this, a)
                }
            }).injectInside(this.cropArea))
        }, this)
    },
    getCropInfo: function () {
        var b = $merge(this.current.crop);
        b.width -= this.boxDiff * 2;
        b.height -= this.boxDiff * 2;
        return b
    },
    removeOverlay: function () {
        this.wrapper.destroy();
        this.img.setStyle("display", "")
    }
});
MooCrop.implement(new Events, new Options);
SocialEngineAPI.User = new Class({
    Base: {},
    user_exists: false,
    user_displayname: false,
    user_displayname_short: false,
    user_info: {},
    profile_info: {},
    level_info: {},
    usersetting_info: {},
    options: {
        ajaxURL: "misc_js.php",
        ajaxMethod: "post",
        ajaxSecure: false,
        displayname_order: "standard"
    },
    user_status: "",
    user_notify_cookie: {},
    user_notify_count: 0,
    initialize: function () {},
    userPhotoFullPath: function () {
        if (!this.Base.URL) {
            return false
        }
        if (!this.user_info.user_photo) {
            return this.Base.URL.url_base + "images/nophoto.gif"
        }
        return this.Base.URL.url_base + this.Base.URL.url_userdir(this.user_info.user_id) + this.user_info.user_photo
    },
    userStatusChange: function () {
        if (!$("ajax_status")) {
            return false
        }
        var c = this.user_status.replace(/<wbr>/g, "").replace(/&shy;/g, "");
        var d = this.user_displayname_short + " <input type='text' class='text_small' name='status_new' id='status_new' maxlength='100' value='";
        d += (c == "" ? this.Base.Language.Translate(744) : c);
        d += "' size='10' style='width: 140px; margin: 2px 0px 2px 0px;' onkeypress='return ( (new Event(event)).key==\"enter\" ? SocialEngine.Viewer.userStatusChangeSubmit() : true );'><br /><a href='javascript:void(0);' onclick='SocialEngine.Viewer.userStatusChangeSubmit(); return false;'>" + this.Base.Language.Translate(746) + "</a> | <a href='javascript:void(0);' onclick='SocialEngine.Viewer.userStatusChangeReturn(); return false;'>" + this.Base.Language.Translate(747) + "</a>";
        $("ajax_status").innerHTML = d;
        $("status_new").focus();
        $("status_new").select()
    },
    userStatusChangeReturn: function () {
        if (!$("ajax_status")) {
            return false
        }
        if (this.user_status == "") {
            $("ajax_status").innerHTML = "<a href='javascript:void(0);' onclick='SocialEngine.Viewer.userStatusChange(); return false;'>" + this.Base.Language.Translate(743) + "</a>"
        } else {
            $("ajax_status").innerHTML = "<div id='ajax_status'>" + this.user_displayname_short + " <span id='ajax_currentstatus_value'>" + this.user_status + "</span><br /><div style='padding-top: 5px;'><div style='float: left; padding-right: 5px;'>[ <a href='javascript:void(0);' onClick='SocialEngine.Viewer.userStatusChange(); return false;'>" + this.Base.Language.Translate(745) + "</a> ]</div><div class='home_updated'><span id='ajax_currentstatus_date'>" + this.Base.Language.Translate(1113) + " " + this.Base.Language.TranslateFormatted(773, [1]) + "</span></div><div style='clear: both; height: 0px;'></div></div></div>"
        }
    },
    userStatusChangeSubmit: function () {
        if (!$("ajax_status")) {
            return false
        }
        var c = this;
        var d = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "status_change",
                status: $("status_new").value
            },
            onComplete: function (b, a) {
                c.user_status = b.status;
                c.userStatusChangeReturn()
            }
        }).send()
    },
    userDelete: function () {
        TB_show(this.Base.Language.Translate(759), "#TB_inline?height=100&width=300&inlineId=confirmdelete", "", "../images/trans.gif")
    },
    userDeleteConfirm: function (d) {
        var f = this;
        var e = new Request.JSON({
            url: "user_account_delete.php",
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "dodelete",
                token: d
            },
            onComplete: function (b, a) {
                window.location = "home.php"
            }
        }).send()
    },
    userActionDelete: function (e) {
        var f = this;
        var d = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "action_delete",
                action_id: e
            },
            onComplete: function (b, a) {
                if ($("action_" + e)) {
                    $("action_" + e).style.display = "none";
                    total_actions--;
                    if (total_actions == 0) {
                        $("actions").style.display = "none"
                    }
                }
            }
        }).send()
    },
    userNotifyShow: function () {
        this.user_notify_cookie = new Hash.Cookie("se_show_newupdates", {
            duration: 3600
        });
        var b = parseInt(this.user_notify_cookie.get("total"));
        if (!$type(b)) {
            b = 0
        }
        if (b < this.user_notify_count) {
            this.user_notify_cookie.set("total", 0);
            $("newupdates").style.display = "block";
            $("newupdates").fade("in")
        }
    },
    userNotifyPopup: function () {
        TB_show(this.Base.Language.Translate(1198), "#TB_inline?height=150&width=300&inlineId=newupdates_popup", "", "./images/trans.gif")
    },
    userNotifyUpdate: function () {
        var c = this;
        var d = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "notify_get"
            },
            onComplete: function (b, a) {
                c.userNotifyGenerate(b);
                c.userNotifyShow()
            }
        }).send()
    },
    userNotifyGenerate: function (d) {
        if (!$type(d.notifys) || d.notifys.length == 0 || !$("newupdates_popup")) {
            $("notify_total").innerHTML = this.user_notify_count = 0;
            return
        }
        $("notify_total").innerHTML = this.user_notify_count = d.total;
        var c = "<div style='margin-top: 10px;'>" + this.Base.Language.TranslateFormatted(1199, ["<span id='notifyscount'>" + d.total_grouped + "</span>"]) + "</div>";
        d.notifys.each(function (a) {
            c += "<div style='font-weight: bold; padding-top: 5px;' id='notify_" + a.notifytype_id + "_" + a.notify_grouped + "'><a href='javascript:void(0);' onClick=\"SocialEngine.Viewer.userNotifyDelete('" + a.notifytype_id + "', '" + a.notify_grouped + "');\">X</a><img src='./images/icons/" + a.notify_icon + "' border='0' style='border: none; margin: 0px 5px 0px 5px; display: inline; vertical-align: middle;' class='icon' /><a href='" + a.notify_url + "'>" + a.notify_text_output + "</a></div>"
        });
        $("newupdates_popup").innerHTML = c
    },
    userNotifyDelete: function (f, h) {
        var g = this;
        var e = new Request.JSON({
            url: this.options.ajaxURL,
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "notify_delete",
                notifytype_id: f,
                notify_grouped: h
            },
            onComplete: function (b, a) {
                $("TB_window").getElements("div[id=notify_" + f + "_" + h + "]").each(function (c) {
                    if (c.id == "notify_" + f + "_" + h) {
                        c.style.display = "none";
                        g.user_notify_count--
                    }
                });
                $("newupdates_popup").getElements("div[id=notify_" + f + "_" + h + "]").each(function (c) {
                    if (c.id == "notify_" + f + "_" + h) {
                        c.style.display = "none"
                    }
                });
                $("notify_total").innerHTML = g.user_notify_count;
                $("TB_window").getElements("span[id=notifyscount]").each(function (c) {
                    if (c.id == "notifyscount") {
                        c.innerHTML = g.user_notify_count
                    }
                });
                if (g.user_notify_count == 0) {
                    TB_remove();
                    $("newupdates").style.display = "none"
                }
            }
        }).send()
    },
    userNotifyHide: function () {
        $("newupdates").fade("out");
        this.user_notify_cookie.set("total", this.user_notify_count)
    },
    userPhotoRemove: function () {
        var c = this;
        var d = new Request.JSON({
            url: "user_editprofile_photo.php",
            method: this.options.ajaxMethod,
            secure: this.options.ajaxSecure,
            data: {
                task: "remove"
            }
        }).send();
        if ($("userEditRemovePhotoLink") && $("userEditPhotoImg")) {
            $("userEditRemovePhotoLink").destroy();
            $("userEditPhotoImg").src = "images/nophoto.gif"
        } else {
            window.location.reload(false)
        }
    },
    ImportUserInfo: function (b) {
        if (!b || $type(b) != "object" || !b.user_exists) {
            this.user_exists = false;
            return
        }
        this.user_exists = true;
        b.user_id = parseInt(b.user_id);
        delete b.user_exists;
        this.user_info = b;
        this.user_info.user_fname = this.user_info.user_fname.trim();
        this.user_info.user_lname = this.user_info.user_lname.trim();
        if (this.user_info.user_fname && this.user_info.user_lname) {
            if (this.options.displayname_order == "asian") {
                this.user_displayname_short = this.user_info.user_lname;
                this.user_displayname = this.user_info.user_lname + " " + this.user_info.user_fname
            } else {
                this.user_displayname_short = this.user_info.user_fname;
                this.user_displayname = this.user_info.user_fname + " " + this.user_info.user_lname
            }
        } else {
            if (this.user_info.user_fname) {
                this.user_displayname = this.user_displayname_short = this.user_info.user_fname
            } else {
                if (this.user_info.user_lname) {
                    this.user_displayname = this.user_displayname_short = this.user_info.user_lname
                } else {
                    if (this.user_info.user_username) {
                        this.user_displayname = this.user_displayname_short = this.user_info.user_username
                    }
                }
            }
        }
    }
});
