function $E(a) {
    if (!a) {
        if (typeof event != "undefined") {
            a = event
        } else {
            return null
        }
    }
    if (a.which) {
        a._button = a.which
    } else {
        a._button = a.button;
        if (Browser.ie) {
            if (a._button & 4) {
                a._button = 2
            } else {
                if (a._button & 2) {
                    a._button = 3
                }
            }
        } else {
            a._button = a.button + 1
        }
    }
    a._target = a.target ? a.target: a.srcElement;
    a._wheelDelta = a.wheelDelta ? a.wheelDelta: -a.detail;
    return a
}
function ge(a) {
    return document.getElementById(a);
}
function ce(c, b) {
    var a = document.createElement(c);
    if (b) {
        cOr(a, b)
    }
    return a
}
function ct(a) {
    return document.createTextNode(a)
}
function ae(a, b) {
    return a.appendChild(b)
}
function ns(a) {
    if (Browser.ie) {
        a.onfocus = tb;
        a.onmousedown = a.onselectstart = a.ondragstart = rf
    }
}
function tb() {
    this.blur()
}
function rf() {
    return false
}
var Browser = {
    ie: !!(window.attachEvent && !window.opera),
    opera: !!window.opera,
    safari: navigator.userAgent.indexOf("Safari") != -1,
    gecko: navigator.userAgent.indexOf("Gecko") != -1 && navigator.userAgent.indexOf("KHTML") == -1
};
Browser.ie8 = Browser.ie && navigator.userAgent.indexOf("MSIE 8.0") != -1;
Browser.ie7 = Browser.ie && navigator.userAgent.indexOf("MSIE 7.0") != -1 && !Browser.ie8;
Browser.ie6 = Browser.ie && navigator.userAgent.indexOf("MSIE 6.0") != -1 && !Browser.ie7;
Browser.ie67 = Browser.ie6 || Browser.ie7;
navigator.userAgent.match(/Gecko\/([0-9]+)/);
Browser.geckoVersion = parseInt(RegExp.$1) | 0;
var OS = {
    windows: navigator.appVersion.indexOf("Windows") != -1,
    mac: navigator.appVersion.indexOf("Macintosh") != -1,
    linux: navigator.appVersion.indexOf("Linux") != -1
};
function ac(c, d) {
    var a = 0,
    g = 0,
    b;
    while (c) {
        a += c.offsetLeft;
        g += c.offsetTop;
        b = c.parentNode;
        while (b && b != c.offsetParent && b.offsetParent) {
            if (b.scrollLeft || b.scrollTop) {
                a -= (b.scrollLeft | 0);
                g -= (b.scrollTop | 0);
                break
            }
            b = b.parentNode
        }
        c = c.offsetParent
    }
    if (Lightbox.isVisible()) {
        d = true
    }
    if (d && !Browser.ie6) {
        var f = g_getScroll();
        a += f.x;
        g += f.y
    }
    var e = [a, g];
    e.x = a;
    e.y = g;
    return e
}
var Lightbox = new
function () {
    var d, m, n, h = {},
    c = {},
    i, f;
    function o() {
        aE(d, "click", e);
        aE(document, Browser.opera ? "keypress": "keydown", g);
        aE(window, "resize", a);
        if (Browser.ie6) {
            aE(window, "scroll", j)
        }
    }
    function l() {
        dE(d, "click", e);
        dE(document, Browser.opera ? "keypress": "keydown", g);
        dE(window, "resize", a);
        if (Browser.ie6) {
            dE(window, "scroll", j)
        }
    }
    function b() {
        if (i) {
            return
        }
        i = 1;
        var p = ge("usermenulayers");
        d = ce("div");
        d.className = "lightbox-overlay";
        m = ce("div");
        m.className = "lightbox-outer";
        n = ce("div");
        n.className = "lightbox-inner";
        d.style.display = m.style.display = "none";
        ae(p, d);
        ae(m, n);
        ae(p, m)
    }
    function g(p) {
        p = $E(p);
        switch (p.keyCode) {
        case 27:
            e();
            break
        }
    }
    function a(p) {
        if (p != 1234) {
            if (c.onResize) {
                c.onResize()
            }
        }
        d.style.height = document.body.offsetHeight + "px";
        if (Browser.ie6) {
            j()
        }
    }
    function j() {
        var q = g_getScroll().y,
        p = g_getWindowSize().h;
        m.style.top = (q + p / 2) + "px"
    }
    function e() {
        l();
        if (c.onHide) {
            c.onHide()
        }
        d.style.display = m.style.display = "none";
        Ads.restoreHidden();
        g_enableScroll(true)
    }
    function k() {
        d.style.display = m.style.display = h[f].style.display = ""
    }
    this.setSize = function (p, q) {
        n.style.visibility = "hidden";
        n.style.width = p + "px";
        n.style.height = q + "px";
        n.style.left = -parseInt(p / 2) + "px";
        n.style.top = -parseInt(q / 2) + "px";
        n.style.visibility = "visible"
    };
    this.show = function (t, s, p) {
        c = s || {};
        Ads.hideAll();
        b();
        o();
        if (f != t && h[f] != null) {
            h[f].style.display = "none"
        }
        f = t;
        var r = 0,
        q;
        if (h[t] == null) {
            r = 1;
            q = ce("div");
            ae(n, q);
            h[t] = q
        } else {
            q = h[t]
        }
        if (c.onShow) {
            c.onShow(q, r, p)
        }
        a(1234);
        k();
        g_enableScroll(false)
    };
    this.reveal = function () {
        k()
    };
    this.hide = function () {
        e()
    };
    this.isVisible = function () {
        return (d && d.style.display != "none")
    }
}
function g_getWindowSize() {
    var a = 0,
    b = 0;
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        a = document.documentElement.clientWidth;
        b = document.documentElement.clientHeight
    } else {
        if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            a = document.body.clientWidth;
            b = document.body.clientHeight
        } else {
            if (typeof window.innerWidth == "number") {
                a = window.innerWidth;
                b = window.innerHeight
            }
        }
    }
    return {
        w: a,
        h: b
    }
}
function g_getScroll() {
    var a = 0,
    b = 0;
    if (typeof(window.pageYOffset) == "number") {
        a = window.pageXOffset;
        b = window.pageYOffset
    } else {
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            a = document.body.scrollLeft;
            b = document.body.scrollTop
        } else {
            if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                a = document.documentElement.scrollLeft;
                b = document.documentElement.scrollTop
            }
        }
    }
    return {
        x: a,
        y: b
    }
}
function de(a) {
    a.parentNode.removeChild(a)
}
function gE(a, b) {
    return a.getElementsByTagName(b)
}
Function.prototype.bind = function () {
    var c = this,
    a = $A(arguments),
    b = a.shift();
    return function () {
        return c.apply(b, a.concat($A(arguments)))
    }
};
function $A(c) {
    var e = [];
    for (var d = 0, b = c.length; d < b; ++d) {
        e.push(c[d])
    }
    return e
}

var Menu = {
    iframes: [],
    divs: [],
    selection: [],
    timer: 0,
    show: function () {
        try {
            clearTimeout(Menu.timer);
            if (Menu.currentLink) {
                Menu._show(this)
            } else {
                if (this.className.indexOf("open") == -1) {
                    this.className += " open"
                }
                Menu.timer = setTimeout(Menu._show.bind(0, this), 100)
            }
        } catch(a) {
        	var i = 0;
        }
    },
    _show: function (b) {
        if (Menu.currentLink != b) {
            var a = ac(b);
            Menu._hide();
            Menu.selection = [ - 1];
            Menu.currentLink = b;
            Menu.showDepth(0, b.menu, a[0], a[1] + b.offsetHeight + 1, b.offsetHeight + 8, b.offsetWidth, a[1], false);
            if (b.className.indexOf("open") == -1) {
                b.className += " open"
            }
        } else {
            Menu.truncate(0);
            Menu.clean(0)
        }
    },
    showAtCursor: function (b, a, d) {
        clearTimeout(Menu.timer);
        Menu._hide();
        Menu.selection = [ - 1];
        Menu.currentLink = null;
        if (! (a && d)) {
            b = $E(b);
            var c = g_getCursorPos(b);
            a = c.x;
            d = c.y
        }
        if (Browser.ie6) {
            a -= 2;
            d -= 2
        }
        Menu.showDepth(0, this.menu, a, d, 0, 0, 0, true)
    },
    hide: function () {
        try {
            clearTimeout(Menu.timer);
            if (Menu.currentLink) {
                Menu.timer = setTimeout(Menu._hide, 333)
            } else {
                this.className = this.className.replace("open", "")
            }
        } catch(a) {}
    },
    _hide: function () {
        for (var b = 0, a = Menu.selection.length; b < a; ++b) {
            Menu.divs[b].style.display = "none";
            Menu.divs[b].style.visibility = "hidden";
            if (Browser.ie6) {
                Menu.iframes[b].style.display = "none"
            }
        }
        Menu.selection = [];
        if (Menu.currentLink) {
            Menu.currentLink.className = Menu.currentLink.className.replace("open", "")
        }
        Menu.currentLink = null
    },
    sepOver: function () {
        var b = this.d;
        var a = b.i;
        Menu.truncate(a);
        Menu.clean(a);
        Menu.selection[a] = -1
    },
    elemOver: function () {
        var g = this.d;
        var f = g.i;
        var e = this.i;
        var a = this.k;
        var b = this.firstChild.className == "menusub";
        Menu.truncate(f + b);
        if (b && a != Menu.selection[f]) {
            var h = ac(this);
            Menu.selection[f + 1] = -1;
            Menu.showDepth(f + 1, g.menuArray[e][3], h[0], h[1] - 2, this.offsetHeight, this.offsetWidth - 3, 0, false)
        }
        Menu.clean(f);
        Menu.selection[f] = a;
        if (this.className.length) {
            this.className += " open"
        } else {
            this.className = "open"
        }
    },
    elemClick: function (a) {
        Menu._hide();
        a()
    },
    getIframe: function (a) {
        var b;
        if (Menu.iframes[a] == null) {
            b = ce("iframe");
            b.src = "javascript:0;";
            b.frameBorder = 0;
            ae(ge("userlayers"), b);
            Menu.iframes[a] = b
        } else {
            b = Menu.iframes[a]
        }
        return b
    },
    getDiv: function (a, b) {
        var c;
        if (Menu.divs[a] == null) {
            c = ce("div");
            c.className = "usermenu";
            ae(ge("usermenulayers"), c);
            Menu.divs[a] = c
        } else {
            c = Menu.divs[a]
        }
        c.i = a;
        c.menuArray = b;
        return c
    },
    showDepth: function (M, c, C, B, N, F, z, v) {
        var W, T = Menu.getDiv(M, c);
        while (T.firstChild) {
            de(T.firstChild)
        }
        var u = ce("table"),
        A = ce("tbody"),
        R = ce("tr"),
        e = ce("td"),
        P = ce("div"),
        J = ce("div");
        var I = 999;
        var b = g_getWindowSize(),
        l = g_getScroll(),
        f = b.w,
        n = b.h,
        V = l.x,
        O = l.y;
        if (N > 0 && (M > 0 || c.length > 20)) {
            if ((25 + 1) * c.length > n - 25 - z) {
                for (var L = 2; L < 4; ++L) {
                    if (N / L * c.length + 30 < n - z) {
                        break
                    }
                }
                I = Math.floor(c.length / L)
            }
        }
        var r = 0;
        var K = 0;
        for (var L = 0, t = c.length; L < t; ++L) {
            var Q = c[L];
            if (Q[0] == null) {
                var q = ce("span");
                q.className = "separator";
                ns(q);
                ae(q, ct(Q[1]));
                q.d = T;
                q.onmouseover = Menu.sepOver;
                ae(J, q)
            } else {
                var U = ce("a");
                U.d = T;
                U.k = K++;
                U.i = L;
                if (Q[2]) {
                    if (Menu.currentLink && Menu.currentLink.menuappend) {
                        if (Q[2].indexOf(Menu.currentLink.menuappend) == -1) {
                            U.href = Q[2] + Menu.currentLink.menuappend
                        } else {
                            U.href = Q[2]
                        }
                    } else {
                        if (typeof Q[2] == "function") {
                            U.href = "javascript:;";
                            U.onclick = Menu.elemClick.bind(0, Q[2]);
                            ns(U)
                        } else {
                            U.href = Q[2]
                        }
                    }
                } else {
                    U.href = "javascript:;";
                    U.style.cursor = "default";
                    ns(U)
                }
                U.onmouseover = Menu.elemOver;
                var G = ce("span"),
                S = ce("span");
                if (Q[3] != null) {
                    G.className = "menusub"
                }
                if (Q.checked) {
                    S.className = "menucheck"
                }
                if (Q.newWindow) {
                    U.target = "_blank"
                }
                if (Q.tinyIcon) {
                    S.style.background = "url(images/icons/tiny/" + Q.tinyIcon.toLowerCase() + ".gif) left center no-repeat"
                }
                ae(S, ct(Q[1]));
                ae(G, S);
                ae(U, G);
                ae(J, U)
            }
            if (r++==I) {
                P.onmouseover = Menu.divOver;
                P.onmouseout = Menu.divOut;
                ae(P, J);
                if (!Browser.ie6) {
                    var H = ce("p");
                    ae(H, ce("em"));
                    ae(H, ce("var"));
                    ae(H, ce("strong"));
                    ae(H, P);
                    ae(e, H)
                } else {
                    ae(e, P)
                }
                ae(R, e);
                e = ce("td");
                H = ce("p");
                P = ce("div");
                J = ce("div");
                r = 0
            }
        }
        P.onmouseover = Menu.divOver;
        P.onmouseout = Menu.divOut;
        ae(P, J);
        if (!Browser.ie6) {
            if (I != 999) {
                var H = ce("p");
                ae(H, ce("em"));
                ae(H, ce("var"));
                ae(H, ce("strong"));
                ae(H, P);
                ae(e, H)
            } else {
                ae(T, ce("em"));
                ae(T, ce("var"));
                ae(T, ce("strong"));
                ae(e, P)
            }
        } else {
            ae(e, P)
        }
        ae(R, e);
        ae(A, R);
        ae(u, A);
        ae(T, u);
        T.style.left = T.style.top = "-2323px";
        T.style.display = "";
        var g = u.offsetWidth,
        o = u.offsetHeight,
        E = true,
        D = true;
        if (!Browser.ie6) {
            g += 5;
            o += 6
        }
        if (C + g > f + V || c.rightAligned) {
            E = false
        }
        if (E) {
            if (C + F + g > f) {
                C = Math.max(0, C - g)
            } else {
                if (M > 0) {
                    C += F
                }
            }
        } else {
            C = C + F - g;
            if (Browser.ie) {
                C -= 3
            }
        }
        if ((M > 0 || v) && B + o > n + O) {
            B = Math.max(O + 5, n + O - o)
        }
        T.style.left = C + "px";
        T.style.top = B + "px";
        if (Browser.ie6) {
            W = Menu.getIframe(M);
            W.style.left = C + "px";
            W.style.top = B + "px";
            W.style.width = g + "px";
            W.style.height = o + "px";
            W.style.display = "";
            W.style.visibility = "visible"
        }
        T.style.visibility = "visible";
        if (Browser.opera) {
            T.style.display = "none";
            T.style.display = ""
        }
    },
    divOver: function () {
        clearTimeout(Menu.timer)
    },
    divOut: function () {
        clearTimeout(Menu.timer);
        Menu.timer = setTimeout(Menu._hide, 333)
    },
    truncate: function (b) {
        var c;
        while (Menu.selection.length - 1 > b) {
            c = Menu.selection.length - 1;
            Menu.divs[c].style.display = "none";
            Menu.divs[c].style.visibility = "hidden";
            if (Browser.ie6) {
                Menu.iframes[c].style.display = "none"
            }
            Menu.selection.pop()
        }
    },
    clean: function (b) {
        for (var c = b; c < Menu.selection.length; ++c) {
            if (Menu.selection[c] != -1) {
                var e = gE(Menu.divs[c], "a")[Menu.selection[c]];
                if (e.className.indexOf("sub") != -1) {
                    e.className = "sub"
                } else {
                    e.className = ""
                }
                Menu.selection[c] = -1
            }
        }
    },
    append: function (b, c) {
        b[2] += c;
        if (b[3] != null) {
            Menu._append(b[3], c)
        }
    },
    _append: function (b, d) {
        var e, g = 0;
        for (var c = 0; c < b.length; ++c) {
            var f = b[c][2].indexOf("&filter=");
            if (f != -1 && d.indexOf("&filter=") == 0) {
                d = Menu._fixCollision(b[c][2].substr(f), d)
            }
            b[c][2] += d;
            if (b[c][3]) {
                Menu._append(b[c][3], d)
            }
        }
    },
    _splitFilter: function (b) {
        var g = b.substr(8).split(";"),
        c = {};
        for (var e = 0, a = g.length; e < a; ++e) {
            var h = g[e].indexOf("="),
            d,
            f;
            if (h != -1) {
                d = g[e].substr(0, h);
                f = g[e].substr(h + 1)
            } else {
                d = g[e];
                f = ""
            }
            c[d] = f
        }
        return c
    },
    _fixCollision: function (d, a) {
        var b = Menu._splitFilter(d),
        c = Menu._splitFilter(a);
        a = "";
        for (var e in c) {
            if (!b[e] && e != "sl" && e != "cl") {
                a += ";";
                a += e + "=" + c[e]
            }
        }
        return a
    },
    fixUrls: function (g, c, e, b, f) {
        if (!f) {
            f = 0
        }
        for (var d = 0, a = g.length; d < a; ++d) {
            if (g[d][2] == null) {
                g[d][2] = c + g[d][0] + (e ? e: "")
            }
            if (g[d][3]) {
                if (b == true || (typeof b == "object" && b[f] == true)) {
                    Menu.fixUrls(g[d][3], c, e, b, f + 1)
                } else {
                    Menu.fixUrls(g[d][3], c + g[d][0] + ".", e, b, f + 1)
                }
            }
        }
    },
    addButtons: function (h, g) {
        for (var e = 0, b = g.length; e < b; ++e) {

        	if (g[e][0] == null) {
                continue
            }
            var c = ce("a"),
            f = ce("span");
            if (g[e][2]) {
                c.href = g[e][2]
            } else {
                c.href = "javascript:;";
                c.style.cursor = "default";
                c.style.textDecoration = "none";
                ns(c)
            }
            if (g[e][3] != null) {
                f.className = "menuarrowd";
                c.menu = g[e][3];
                c.onmouseover = Menu.show;
                c.onmouseout = Menu.hide
            } else {
                c.onmouseover = Menu._hide
            }
            ae(f, ct(g[e][1]));
            ae(c, f);
            ae(h, c)
        }
    },
    explode: function (f) {
        var d = [],
        e = null,
        c;
        for (var b = 0, a = f.length; b < a; ++b) {
            if (f[b][0] != null) {
                if (e != null) {
                    c.push(f[b])
                } else {
                    d.push(f[b])
                }
            }
            if (e != null && (f[b][0] == null || b == a - 1)) {
                d.push([0, e[1], , c])
            }
            if (f[b][0] == null) {
                e = f[b];
                c = []
            }
        }
        return d
    }
};
