var Application = {
    _globals: $H({}),
    alertOnError: false,
    ajaxResponseProcess: function (f, b, c) {
        try {
            var a = f.responseText.evalJSON()
        } catch (d) {
            if (Application.alertOnError) {
                alert("The action returned an error. Please contact the administrator")
            }
            return false
        }

        if (a.authenticationRequired != undefined && a.authenticationRequired) {
            Application.ajaxAuthenticationRequired(c);
            return false
        }
        if (a.redirectTo != undefined && a.redirectTo) {
            window.location = a.redirectTo
        }
        if (b !== null && a.message != undefined && a.message != [] && a.message != "") {
            try {
                if (b.handleMessageSet) {
                    b.handleMessageSet(a.message)
                } else {
                    b.set(a.message)
                }
            } catch (d) {
                try {
                    Application.message.set(a.message)
                } catch (d) {
                    alert(a.message)
                }
            }
        }
        if (a.error == undefined) {
            return false
        }
        return a
    },
    ajaxAuthenticationRequired: function () {
        alert("Please authenticate.")
    },
    domReady: Element.observe.curry(document, "dom:loaded"),
    setMessageController: function (a) {
        Application.message = new SimpleMessage(a);
        Event.observe(document, "message:set", function (b) {
            Application.message.set(b.memo.message)
        })
    },
    onLoginStatusChangedRegister: function (a) {
        if (typeof this.onLoginStatusChangedActions == "undefined") {
            this.onLoginStatusChangedActions = $A({})
        }
        this.onLoginStatusChangedActions.push(a);
        return true
    },
    onLoginStatusChanged: function () {
        if (typeof this.onLoginStatusChangedActions == "undefined") {
            return
        }
        this.onLoginStatusChangedActions.each(function (a) {
            a()
        })
    }
};
Event.observe(document, "application:loginStatusChanged", Application.onLoginStatusChanged.bind(Application));
var SimpleMessage = Class.create({
    initialize: function (a, b) {
        if (!$(a)) {
            return
        }
        if (!$(a).id) {
            $(a).identify()
        }
        this.container = $(a);
        this.key = Math.round(Math.random() * 1000000);
        this.last_id = 0;
        this.timeouts = $A([]);
        this.timeoutTime = 2000;
        this.options = b || {};
        SimpleMessage.instances.set($(a).id, this)
    },
    clear: function () {
        this.clearTimeouts();
        this.container.descendants().invoke("stopObserving");
        this.container.update();
        this.container.hide()
    },
    clearTimeouts: function () {
        this.timeouts.each(function (b, a) {
            clearTimeout(this.timeouts[a])
        }, this);
        this.timeouts.clear()
    },
    add: function (b) {
        if (this.options.add) {
            this.options.add.call(this, b);
            return
        }
        this.last_id++;
        var a = this.last_id;
        this.container.insert(new Element("div", {
            id: "message[" + this.key + "]id_" + a
        }).addClassName("simple-message").update(b));
        this.container.pulsate({
            pulses: 2,
            duration: 1.5
        });
        this.container.show();
        this.timeouts[a] = setTimeout(function () {
            try {
                $("message[" + this.key + "]id_" + a).removeClassName("simple-message").addClassName("simple-message-viewed")
            } catch (c) {}
        }.bind(this), this.timeoutTime)
    },
    set: function (a) {
        this.clear();
        if (typeof(a) == "string") {
            this.add(a)
        } else {
            if (typeof(a) == "object" && a.length) {
                $A(a).each(this.add, this)
            }
        }
        return true
    },
    remove: function (b) {
        try {
            $("message[" + this.key + "]id_" + b).remove()
        } catch (a) {}
        if (this.timeouts[b]) {
            clearTimeout(this.timeouts[b])
        }
        if (this.container.immediateDescendants().size() === 0) {
            this.container.hide()
        }
    }
});
var SimpleModalMessage = Class.create({
    initialize: function (a) {
        this.reset();
        this.options = {
            modalClassName: "",
            closeLink: true,
            width: "",
            padding: 10,
            margin: 10,
            formatMessage: function () {
                return this.messages.join("<br />")
            }
        };
        this.options = Object.extend(Object.clone(this.options), a || {})
    },
    reset: function () {
        this.messages = $A([])
    },
    add: function (a) {
        this.messages.push(a);
        this.display()
    },
    display: function () {
        new DefaultDialog({
            className: this.options.modalClassName,
            width: this.options.width,
            padding: this.options.padding,
            margin: this.options.margin,
            content: this.options.formatMessage.bind(this),
            close: {
                link: this.options.closeLink,
                overlay: true,
                esc: true
            },
            onClose: this.reset.bind(this)
        }).open()
    },
    set: function (a) {
        this.reset();
        this.add(a);
        return true
    },
    handleMessageSet: function (a) {
        if (typeof(a) == "string") {
            this.set(a)
        } else {
            try {
                this.reset();
                $A(a).each(function (c) {
                    this.messages.push(c)
                }.bind(this));
                this.display()
            } catch (b) {}
        }
    }
});
Object.extend(SimpleMessage, {
    instances: $H({}),
    getInstance: function (b) {
        if (!$(b)) {
            return
        }
        if (!$(b).id) {
            $(b).identify()
        }
        var a = SimpleMessage.instances.get($(b).id);
        return a !== undefined ? a : new SimpleMessage(b)
    }
});
var dateFromatISORegexp = /(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})/;
var dateFromatISO = "Y-m-d H:i:s";
Date.prototype.format = function (e) {
    var d = "";
    var c = Date.replaceChars;
    for (var b = 0; b < e.length; b++) {
        var a = e.charAt(b);
        if (c[a]) {
            d += c[a].call(this)
        } else {
            d += a
        }
    }
    return d
};
Date.replaceChars = {
    shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    longMonths: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    shortDays: ["Sun", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    longDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    d: function () {
        return (this.getDate() < 10 ? "0" : "") + this.getDate()
    },
    D: function () {
        return Date.replaceChars.shortDays[this.getDay()]
    },
    j: function () {
        return this.getDate()
    },
    l: function () {
        return Date.replaceChars.longDays[this.getDay()]
    },
    N: function () {
        return this.getDay() + 1
    },
    S: function () {
        return (this.getDate() % 10 == 1 && this.getDate() != 11 ? "st" : (this.getDate() % 10 == 2 && this.getDate() != 12 ? "nd" : (this.getDate() % 10 == 13 && this.getDate() != 1 ? "rd" : "th")))
    },
    w: function () {
        return this.getDay()
    },
    z: function () {
        return "Not Yet Supported"
    },
    W: function () {
        return "Not Yet Supported"
    },
    F: function () {
        return Date.replaceChars.longMonths[this.getMonth()]
    },
    m: function () {
        return (this.getMonth() < 11 ? "0" : "") + (this.getMonth() + 1)
    },
    M: function () {
        return Date.replaceChars.shortMonths[this.getMonth()]
    },
    n: function () {
        return this.getMonth() + 1
    },
    t: function () {
        return "Not Yet Supported"
    },
    L: function () {
        return "Not Yet Supported"
    },
    o: function () {
        return "Not Supported"
    },
    Y: function () {
        return this.getFullYear()
    },
    y: function () {
        return ("" + this.getFullYear()).substr(2)
    },
    a: function () {
        return this.getHours() < 12 ? "am" : "pm"
    },
    A: function () {
        return this.getHours() < 12 ? "AM" : "PM"
    },
    B: function () {
        return "Not Yet Supported"
    },
    g: function () {
        return this.getHours() === 0 ? 12 : (this.getHours() > 12 ? this.getHours() - 12 : this.getHours())
    },
    G: function () {
        return this.getHours()
    },
    h: function () {
        return (this.getHours() < 10 || (12 < this.getHours() < 22) ? "0" : "") + (this.getHours() < 10 ? this.getHours() + 1 : this.getHours() - 12)
    },
    H: function () {
        return (this.getHours() < 10 ? "0" : "") + this.getHours()
    },
    i: function () {
        return (this.getMinutes() < 10 ? "0" : "") + this.getMinutes()
    },
    s: function () {
        return (this.getSeconds() < 10 ? "0" : "") + this.getSeconds()
    },
    e: function () {
        return "Not Yet Supported"
    },
    I: function () {
        return "Not Supported"
    },
    O: function () {
        return (this.getTimezoneOffset() < 0 ? "-" : "+") + (this.getTimezoneOffset() / 60 < 10 ? "0" : "") + (this.getTimezoneOffset() / 60) + "00"
    },
    T: function () {
        return "Not Yet Supported"
    },
    Z: function () {
        return this.getTimezoneOffset() * 60
    },
    c: function () {
        return "Not Yet Supported"
    },
    r: function () {
        return this.toString()
    },
    U: function () {
        return this.getTime() / 1000
    }
};
var ScriptInclude = Class.create({
    initialize: function (a, b) {
        if (Application._globals.get("includedExternals") === undefined) {
            Application._globals.set("includedExternals", $H({}))
        }
        this.sources = $A((typeof(a) == "string" ? [a] : a));
        this.callback = b || Prototype.emptyFunction;
        if (this.includeOnce === true) {
            this.sources = this.sources.findAll(function (c) {
                return (Application._globals.get("includedExternals").get(c) === undefined)
            })
        }
        this.queueStart()
    },
    queueStart: function () {
        if (this.sources.size() === 0) {
            this.callback();
            return
        }
        var d = this.sources.shift();
        if (!this.includeOnce) {
            d += (d.indexOf("?") == -1 ? "?" : "&") + "scriptIncludeTS=" + new Date().getTime()
        }
        var a = this._createElement(d);
        $$("head").shift().appendChild(a);
        var c = arguments.callee.bind(this);
        if (document.addEventListener) {
            if (Prototype.Browser.Opera) {
                var b = new Element("iframe", {
                    src: d
                }).setStyle({
                    display: "none"
                });
                $$("body").first().insert(b);
                Event.observe(b, "load", c)
            } else {
                Event.observe(a, "load", c)
            }
        } else {
            a.onreadystatechange = function () {
                if (a.readyState == "complete" || a.readyState == "loaded") {
                    a.onreadystatechange = null;
                    c()
                }
            }
        }
    },
    _createElement: function (a) {
        return new Element("script", {
            language: "javascript",
            type: "text/javascript",
            src: a
        })
    }
});
var SimpleAjaxForm = Class.create({
    initialize: function (b, a) {
        this.form = $(b);
        this.options = {
            message: window.message,
            formAction: this.form.readAttribute("action") || "",
            formMethod: "post",
            ajaxResponseProcess: Application.ajaxResponseProcess,
            afterAuthenticationCallback: Prototype.emptyFunction,
            onBeforeSubmit: function () {},
            onAfterSubmit: function () {},
            onResponseReceived: function () {},
            customCallback: function () {},
            labelErrorClassName: "flderr",
            inputErrorClassName: "inputerr",
            listenForMessages: false,
            parameters: {}
        };
        Object.extend(this.options, a || {});
        this.form.stopObserving();
        this.submitFunctionReference = this.submitEvent.bindAsEventListener(this);
        this.form.observe("submit", this.submitFunctionReference);
        this.form.submit = this.submitFunctionReference;
        if (this.options.listenForMessages) {
            this.form.observe("message:set", this.messageEvent.bindAsEventListener(this))
        }
        this.fixFormAction()
    },
    destroy: function () {
        this.form.descendants.invoke("stopObserving");
        this.form.stopObserving()
    },
    setAction: function (a) {
        this.options.formAction = a;
        this.fixFormAction()
    },
    fixFormAction: function () {
        var a = this.form.down('input[name="action"]');
        if (a) {
            document.body.appendChild(a)
        }
        this.form.writeAttribute("action", this.options.formAction);
        if (a) {
            this.form.appendChild(a)
        }
    },
    submitEvent: function (a) {
        try {
            a.stop()
        } catch (b) {}
        this.options.onBeforeSubmit();
        this.submit();
        this.options.onAfterSubmit()
    },
    submit: function (a, b) {
        if (this.form.isSubmiting) {
            return
        }
        this.clearRequiredStyle();
        this.form.isSubmiting = true;
        this.form.request({
            method: this.options.formMethod,
            parameters: Object.extend(this.options.parameters, a || {}),
            onComplete: function (d) {
                var c = this.options.ajaxResponseProcess(d, this.options.message, this.options.afterAuthenticationCallback);
                this.options.onResponseReceived(c);
                this.form.isSubmiting = false;
                if (!c) {
                    return
                }
                if (c.required) {
                    $A(c.required).each(this.setInputAsRequired.bind(this))
                }
                if (c.error) {
                    return
                }
                if (typeof b == "function") {
                    b.call(this, c)
                } else {
                    this.options.customCallback.call(this, c)
                }
            }.bind(this)
        })
    },
    messageEvent: function (a) {
        a.stop();
        if (a.memo.message) {
            this.options.message.set(a.memo.message)
        }
    },
    setInputAsRequired: function (a) {
        try {
            this.form.select("label#" + a + "Label").shift().addClassName(this.options.labelErrorClassName);
            $(a).addClassName(this.options.inputErrorClassName)
        } catch (b) {}
    },
    clearRequiredStyle: function () {
        this.form.select("label").invoke("removeClassName", this.options.labelErrorClassName);
        this.form.select(".inputerr").invoke("removeClassName", this.options.inputErrorClassName)
    }
});
window.simpleUIBlocker = {
    builded: false,
    IE6: (Prototype.Browser.IE && parseInt(navigator.appVersion) == 4 && navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1),
    isBlocking: false,
    defaultMessage: '<div style="text-align:center;background:#fff; padding:10px;"><h1>Please wait...</h1><img src="/img/admin/loading.gif" width="31" height="31"></div>',
    timeout: null,
    window: null,
    autoclose: true,
    block: function (b, c, a) {
        b = b || this.defaultMessage;
        clearTimeout(this.timeout);
        this.timeout = setTimeout(this.launchBlock.bind(this, b, a), (c || 0.2) * 1000)
    },
    launchBlock: function (b, a) {
        if (!this.builded) {
            this.createElements()
        }
        this.overlay.show();
        this.content.show();
        this.content.update(b);
        this.fixDimensions();
        if (this.IE6) {
            Event.observe(window, "scroll", function () {
                this.fixScroll()
            }.bind(this))
        }
        Event.observe(window, "resize", function () {
            this.fixDimensions()
        }.bind(this));
        clearTimeout(this.timeout);
        if (this.autoclose) {
            this.timeout = setTimeout(this.unblock.bind(this), (a || 10) * 1000)
        }
    },
    unblock: function () {
        clearTimeout(this.timeout);
        if (!this.builded) {
            return
        }
        this.overlay.stopObserving();
        this.overlay.hide();
        this.content.hide()
    },
    createElements: function () {
        this.builded = true;
        this.overlay = new Element("div");
        $(document.body).insert(this.overlay);
        this.overlay.setStyle({
            position: this.IE6 ? "absolute" : "fixed",
            width: "100%",
            height: "100%",
            backgroundColor: "#fff",
            top: 0,
            left: 0,
            zIndex: 10000,
            display: "none"
        });
        this.overlay.setOpacity(0.5);
        this.content = new Element("div");
        this.content.setStyle({
            position: this.IE6 ? "absolute" : "fixed",
            zIndex: 10001,
            overflow: "hidden",
            display: "none"
        });
        this.content.setOpacity(1);
        $(document.body).insert(this.overlay);
        $(document.body).insert(this.content)
    },
    fixDimensions: function () {
        var a = document.viewport.getDimensions(),
            b = this.content;
        s = {
            w: b.scrollWidth,
            h: b.scrollHeight
        };
        b.setStyle("width:" + s.w + "px;height:" + s.h + "px;top:50%;left:50%;margin:-" + parseInt(s.h / 2) + "px 0 0 -" + parseInt(s.w / 2) + "px;");
        if (this.IE6) {
            this.overlay.setStyle("width:" + a.width + "px;height:" + a.height + "px")
        }
    },
    fixScroll: function () {
        if (this.IE6) {
            s = document.viewport.getScrollOffsets();
            this.overlay.setStyle("margin-top:" + s.top + "px;margin-left:" + s.left + "px")
        }
        var b = document.viewport.getDimensions(),
            g = this.content,
            f = g.getDimensions(),
            e = s.top + parseInt((b.height - f.height) / 2, 10),
            a = s.left + parseInt((b.width - f.width) / 2, 10);
        g.setStyle("margin:0;top:" + e + "px;left:" + a + "px")
    }
};

function popup(c, g, e, a, d) {
    var b = "width=" + e + ",height=" + a;
    if (screen) {
        b += ",left=" + (screen.width - e) / 2 + ",top=" + (screen.height - a) / 2
    }
    if (d) {
        b += "," + d
    }
    var f = window.open(c, g, b);
    if (!f || !f.top) {
        if (confirm("Este necesara deschiderea unui popup pentru a continua. ")) {
            var f = window.open(c, g, b);
            f.focus();
            return f
        }
    } else {
        f.focus();
        return f
    }
}
function openURLInPopup(c, d, a, b) {
    if (typeof(d) == "undefined") {
        d = 800;
        a = 600
    }
    if (typeof(a) == "undefined") {
        a = 600
    }
    popup(c, b || "window" + Math.floor(Math.random() * 10000 + 1), d, a, "menubar=0,location=0,toolbar=0,status=0,scrollbars=1")
}
function set_cookie(b, d, a, f, c, e) {
    document.cookie = b + "=" + escape(d) + ((a) ? "; expires=" + a.toGMTString() : "") + ((f) ? "; path=" + f : "") + ((c) ? "; domain=" + c : "") + ((e) ? "; secure" : "")
}
function get_cookie(b) {
    var e = b + "=";
    var a = document.cookie.split(";");
    for (var d = 0; d < a.length; d++) {
        var f = a[d];
        while (f.charAt(0) == " ") {
            f = f.substring(1, f.length)
        }
        if (f.indexOf(e) == 0) {
            return f.substring(e.length, f.length)
        }
    }
    return null
}
function delete_cookie(a, c, b) {
    if (get_cookie(a)) {
        document.cookie = a + "=" + ((c) ? "; path=" + c : "") + ((b) ? "; domain=" + b : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"
    }
}
Array.prototype.sum = function () {
    var b = 0;
    for (var a = 0; a < this.length; a++) {
        b += this[a]
    }
    return b
};
SimpleBox = Class.create({
    initialize: function (a) {
        this.id = a
    },
    callMethod: function (c, a, b) {
        b = b || Prototype.emptyFunction.bind(this);
        this.ajaxOnLoading();
        new Ajax.Request(Application.boxURL, {
            parameters: {
                jsondata: $H({
                    _action: "box_method",
                    box_id: this.id,
                    method: c,
                    parameters: [a]
                }).toJSON()
            },
            onComplete: function (e) {
                this.ajaxOnLoaded();
                var d = Application.ajaxResponseProcess(e);
                if (!d || d.error) {
                    return
                }
                b.call(this, d)
            }.bind(this)
        })
    },
    ajaxOnLoading: function () {
        window.simpleUIBlocker.block('<div style="text-align:center; margin:10px;"><h1 style="display:block; margin:10px;">Asteptati...</h1><img src="/img/admin/loading.gif" width="31" height="31"></div>', 0.5);
        return
    },
    ajaxOnLoaded: function () {
        window.simpleUIBlocker.unblock();
        return
    }
});
ColapsabileImageGallery = Class.create({
    initialize: function (b, c, a, d) {
        this.container = $(b);
        this.dummyContainer = $(c);
        if (!this.container || !this.dummyContainer) {
            return false
        }
        this.waitingClass = a;
        this.toggler = $(d);
        this.container.observe("click", this.clickOnMainContainerEvent.bindAsEventListener(this));
        this.containerOnAllImageLoaded(this.container, this.initToggler.bind(this))
    },
    containerOnAllImageLoaded: function (a, c) {
        var b = a.select("img").pluck("complete").uniq();
        if (b.length == 1 && b.shift() === true) {
            c();
            return
        }
        arguments.callee.delay(0.03, a, c)
    },
    initToggler: function () {
        this.originalHeight = this.container.getHeight();
        this.toggler.show();
        var a = this.toggler.innerHTML;
        this.toggler.observe("click", function (e) {
            e.stop();
            var c = this.toggler.href;
            var b = this.toggler;
            if (this.toggler.hasClassName("toggler_link_off")) {
                this.toggler.removeClassName("toggler_link_off");
                this.toggler.addClassName("toggler_link_on");
                this.toggler.update("Ascunde");
                this.currentStatus = "on"
            } else {
                this.toggler.removeClassName("toggler_link_on");
                this.toggler.addClassName("toggler_link_off");
                this.toggler.update(a);
                this.currentStatus = "off"
            }
            if (!c.endsWith("#")) {
                this.container.startWaiting(this.waitingClass);
                new Ajax.Request(c, {
                    onComplete: function (g) {
                        var f = Application.ajaxResponseProcess(g);
                        if (!f || f.error === true) {
                            return
                        }
                        this.dummyContainer.update(f.html);
                        this.containerOnAllImageLoaded(this.dummyContainer, this.updateGalleryFromDummy.bind(this))
                    }.bind(this)
                });
                b.href = "#"
            }
            var d = this.container.scrollHeight;
            new Effect.Morph(this.container, {
                style: {
                    height: (this.currentStatus === "on" ? d : this.originalHeight) + "px"
                },
                duration: 0.3
            })
        }.bind(this))
    },
    clickOnMainContainerEvent: function (c) {
        var b = c.element();
        if (!b.hasClassName("page_nav_link")) {
            return true
        }
        c.stop();
        var a = b.tagName == "IMG" ? b.up().href : b.href;
        this.container.startWaiting(this.waitingClass);
        new Ajax.Request(a, {
            onComplete: function (e) {
                var d = Application.ajaxResponseProcess(e);
                if (!d || d.error === true) {
                    return
                }
                this.dummyContainer.update(d.html);
                this.containerOnAllImageLoaded(this.dummyContainer, this.updateGalleryFromDummy.bind(this))
            }.bind(this)
        })
    },
    updateGalleryFromDummy: function () {
        this.dummyContainer.descendants().invoke("stopObserving");
        this.container.stopWaiting();
        var a = this.dummyContainer.getHeight();
        this.container.update(this.dummyContainer.innerHTML);
        this.dummyContainer.update();
        new Effect.Morph(this.container, {
            style: {
                height: a + "px"
            },
            duration: 0.3
        })
    }
});
Element.addMethods({
    hoverIntent: function (g, j, l, n) {
        var e = Object.extend({
            sensitivity: 7,
            interval: 250,
            timeout: 100
        }, n);
        e.onMouseOver = j || Prototype.emptyFunction;
        e.onMouseOut = l || Prototype.emptyFunction;
        var d, c, i, f;

        function b(o) {
            d = o.pageX;
            c = o.pageY
        }
        function a(o) {
            g.hoverTimer = clearTimeout(g.hoverTimer);
            if ((Math.abs(i - d) + Math.abs(f - c)) < e.sensitivity) {
                g.stopObserving("mousemove");
                g.isHovering = true;
                return e.onMouseOver.apply(g, [o])
            } else {
                i = d;
                f = c;
                g.hoverTimer = arguments.callee.delay(e.interval / 1000, o)
            }
        }
        function k(o) {
            g.isHovering = false;
            g.hoverTimer = clearTimeout(g.hoverTimer);
            return e.onMouseOut.apply(g, [o])
        }
        function m(o) {
            var r = o.fromElement || o.relatedTarget;
            while (r && r != g) {
                try {
                    r = r.parentNode
                } catch (q) {
                    r = g
                }
            }
            if (r == g) {
                return false
            }
            i = o.pageX;
            f = o.pageY;
            if (g.hoverTimer) {
                g.hoverTimer = clearTimeout(g.hoverTimer)
            }
            g.observe("mousemove", b);
            if (!g.isHovering) {
                g.hoverTimer = a.delay(e.interval / 1000, Object.extend({}, o))
            }
        }
        function h(o) {
            var r = o.toElement || o.relatedTarget;
            while (r && r != g) {
                try {
                    r = r.parentNode
                } catch (q) {
                    r = g
                }
            }
            if (r == g) {
                return false
            }
            if (g.hoverTimer) {
                g.hoverTimer = clearTimeout(g.hoverTimer)
            }
            g.stopObserving("mousemove");
            if (g.isHovering) {
                g.hoverTimer = k.delay(e.timeout / 1000, Object.extend({}, o))
            }
        }
        return g.observe("mouseover", m).observe("mouseout", h)
    }
});
mainBoxTabs = Class.create();
Object.extend(mainBoxTabs, {
    timeouts: $H([]),
    registerTimeout: function (a, b, c) {
        this.timeouts.set(a, setTimeout(b, c))
    },
    unregisterTimeout: function (a) {
        clearTimeout(this.timeouts.unset(a))
    }
});
Object.extend(mainBoxTabs.prototype, {
    initialize: function (a, b, c, d) {
        this.container = $(a);
        this.containerId = this.container.id;
        this.prefix = a;
        this.currentItem = 0;
        this.items = $A([]);
        this.startPlaying = b;
        this.timeout = d;
        this.stopNavClickEvent = c || false;
        this.initElements()
    },
    initElements: function () {
        mainBoxTabs.unregisterTimeout(this.containerId);
        var a = this;
        this.container.select("ul.ul-nav li").each(function (b) {
            var c = parseInt(b.id.replace(a.prefix + "_nav_link_", ""));
            a.items.push(c);
            b.hoverIntent(function () {
                mainBoxTabs.unregisterTimeout(this.containerId);
                this.activateTab(c)
            }.bind(a), Prototype.emptyFunction, {
                interval: 100
            });
            b.observe("click", function (d) {
                if (this.stopNavClickEvent) {
                    d.stop()
                }
                mainBoxTabs.unregisterTimeout(this.containerId);
                this.activateTab(c)
            }.bind(a))
        });
        this.container.select(".prev").first().observe("click", a.showPrevious.bindAsEventListener(a));
        this.container.select(".next").first().observe("click", a.showNext.bindAsEventListener(a));
        if (this.startPlaying) {
            this.play()
        } else {
            this.showNext()
        }
    },
    play: function () {
        mainBoxTabs.unregisterTimeout(this.containerId);
        var a = this.items.indexOf(this.currentItem);
        a++;
        if (this.items[a] == undefined) {
            a = 0
        }
        var b = this.items[a];
        this.activateTab(b);
        mainBoxTabs.registerTimeout(this.containerId, arguments.callee.bind(this), this.timeout)
    },
    showNext: function () {
        mainBoxTabs.unregisterTimeout(this.containerId);
        var a = this.items.indexOf(this.currentItem);
        a++;
        if (this.items[a] == undefined) {
            a = 0
        }
        this.activateTab(this.items[a])
    },
    showPrevious: function () {
        mainBoxTabs.unregisterTimeout(this.containerId);
        var a = this.items.indexOf(this.currentItem);
        a--;
        if (this.items[a] == undefined) {
            a = this.items.length - 1
        }
        this.activateTab(this.items[a])
    },
    activateTab: function (b) {
        if (this.currentItem == b) {
            return
        }
        this.currentItem = b;
        this.container.select(".item").invoke("hide");
        var a = this.prefix + "_container_" + b;
        $(a).show();
        $(a).select("img").first().hide().appear({
            duration: 0.2
        });
        this.container.select("ul.ul-nav li").invoke("removeClassName", "on");
        $(this.prefix + "_nav_link_" + b).addClassName("on")
    }
});
zoomImage = Class.create({
    initialize: function (e, c, d) {
        var a = $(e);
        var f = $(c);
        var b = $(d);
        var g = false;
        var h = null;
        f.observe("mouseover", function (m) {
            clearTimeout(h);
            if (!f.complete) {
                return
            }
            if (!g) {
                g = true;
                var l = f.getDimensions();
                var j = a.getDimensions();
                var k = ((j.width - l.width) / 2) + 10;
                var i = ((j.height - l.height) / 2) + 10;
                b.setStyle({
                    position: "absolute",
                    right: k + "px",
                    bottom: i + "px"
                })
            }
            b.show()
        });
        f.observe("mouseout", function () {
            h = Element.hide.delay(0.2, b)
        });
        b.observe("mouseover", function (i) {
            clearTimeout(h);
            return
        })
    }
});
MyAccordion = new Class.create({
    initialize: function (a) {
        this.container = $(a);
        this.allTrigs = this.container.select(".trig");
        this.allTargs = this.container.select(".targ");
        this.container.observe("click", this.containerClickEvent.bindAsEventListener(this))
    },
    containerClickEvent: function (b) {
        var a = b.element();
        if (a.hasClassName("trig")) {
            if (a.hasClassName("open")) {
                this.hideAllTarg()
            } else {
                this.hideAllTarg();
                a.addClassName("open");
                a.next().show()
            }
            return true
        }
    },
    hideAllTarg: function () {
        this.allTargs.invoke("hide");
        this.allTrigs.invoke("removeClassName", "open")
    }
});
var MultipleMessage = Class.create({
    initialize: function (a) {
        this.baseName = a.baseName;
        this.containerRegExp = new RegExp("^" + this.baseName + "\\[(.+?)\\]$");
        this.containers = new Hash();
        this.scrollIntoView = false;
        if (a.buildMessageItemContainer) {
            this.buildMessageItemContainer = a.buildMessageItemContainer
        }
        if (a.buildMessageTypeContainer) {
            this.buildMessageTypeContainer = a.buildMessageTypeContainer
        }
        $$("div[rel^=" + this.baseName + "]").each(this.addContainer.bind(this))
    },
    addContainer: function (a) {
        var b = this.containerRegExp.exec(a.readAttribute("rel"));
        if (b[1] == undefined) {
            return false
        }
        this.containers.set(b[1], a);
        a.addClassName("multiple-message-group");
        a.observe("click", function (d) {
            var c = d.element();
            if (c.hasClassName("multiple-message-close-item")) {
                d.stop();
                try {
                    c.up(".multiple-message-item").remove()
                } catch (f) {}
                return true
            }
            if (c.hasClassName("multiple-message-close-type")) {
                d.stop();
                try {
                    c.up(".multiple-message-type-container").remove()
                } catch (f) {}
                return true
            }
            if (c.hasClassName("multiple-message-close-group")) {
                d.stop();
                try {
                    elementle.up(".multiple-message-group").update().hide()
                } catch (f) {}
                return true
            }
        });
        return true
    },
    clean: function (b) {
        if (b) {
            try {
                this.containers.get(b).update()
            } catch (a) {}
        } else {
            this.containers.values().invoke("update")
        }
    },
    hide: function (b) {
        if (b) {
            try {
                this.containers.get(b).hide()
            } catch (a) {}
        } else {
            this.containers.values().invoke("hide")
        }
    },
    show: function (b) {
        if (b) {
            try {
                this.containers.get(b).show()
            } catch (a) {}
        } else {
            this.containers.values().show("hide")
        }
    },
    add: function (d, a, b) {
        var c = this.messageContainer(a, b);
        c.insert(d);
        if (this.scrollIntoView === false) {
            c.scrollIntoView(true);
            this.scrollIntoView = true;
            window.scrollBy(0, -(document.viewport.getHeight() / 2))
        }
        return true
    },
    set: function (c, a, b) {
        this.clean(a);
        this.add(c, a, b)
    },
    messageContainer: function (a, b) {
        var d = this.containers.get(a);
        var e = d.down(".multiple-message-type-container-" + a + "-" + b);
        if (e == undefined) {
            e = this.buildMessageTypeContainer(a, b);
            e.addClassName("multiple-message-type-container");
            e.addClassName("multiple-message-type-container-" + a + "-" + b);
            e.writeAttribute("rel", this.baseName + "[" + a + "][" + b + "]");
            d.insert(e)
        }
        var c = this.buildMessageItemContainer(e, a, b);
        c.addClassName("multiple-message-item");
        return c
    },
    buildMessageTypeContainer: function (a, b) {
        var c = new Element("div");
        c.addClassName("multiple-message-type-container");
        return c
    },
    buildMessageItemContainer: function (d, a, c) {
        var b = new Element("div");
        b.addClassName("multiple-message-item");
        d.insert(b);
        return b
    },
    handleMessageSet: function (a) {
        this.scrollIntoView = false;
        var c = this;
        c.clean();
        c.hide();
        try {
            $H(a).each(function (d) {
                $H(d.value).each(function (e) {
                    $A(e.value).each(function (f) {
                        c.add(f, d.key, e.key);
                        c.show(d.key)
                    })
                })
            })
        } catch (b) {}
        return
    }
});

function openLinkInDialog(c, b, d) {
    if (!c) {
        c = window.event;
        Event.extend(c)
    }
    var a = c.element();
    if (a.tagName != "A") {
        a = a.up("a");
        if (!a) {
            return
        }
    }
    if (typeof(b) == "undefined") {
        b = true
    }
    if (typeof(d) == "undefined") {
        d = true
    }
    c.stop();
    new Ajax.Request(a.href, {
        onComplete: function (f) {
            var e = Application.ajaxResponseProcess(f);
            if (!e || !e.html) {
                return
            }(new DefaultDialog({
                innerScroll: true,
                padding: 0,
                margin: 0,
                content: e.html,
                close: {
                    link: false,
                    overlay: b,
                    esc: d
                }
            })).open()
        }
    });
    return
}
function str_pad(c, g, f, d) {
    var e = "",
        a;
    var b = function (k, h) {
        var l = "",
            j;
        while (l.length < h) {
            l += k
        }
        l = l.substr(0, h);
        return l
    };
    c += "";
    f = f !== undefined ? f : " ";
    if (d != "STR_PAD_LEFT" && d != "STR_PAD_RIGHT" && d != "STR_PAD_BOTH") {
        d = "STR_PAD_RIGHT"
    }
    if ((a = g - c.length) > 0) {
        if (d == "STR_PAD_LEFT") {
            c = b(f, a) + c
        } else {
            if (d == "STR_PAD_RIGHT") {
                c = c + b(f, a)
            } else {
                if (d == "STR_PAD_BOTH") {
                    e = b(f, Math.ceil(a / 2));
                    c = e + c + e;
                    c = c.substr(0, g)
                }
            }
        }
    }
    return c
}
if (!window.console) {
    window.console = {
        debug: function () {
            alert(arguments[0])
        },
        dir: function () {
            alert(arguments[0])
        }
    }
}
function loadBranding(a) {
    if (typeof(Application.pageBranding) != "undefined") {
        return true
    }
    Application.pageBranding = a;
    var b = CFG.jsBaseURL + "/assets/branding/" + encodeURIComponent(a) + "/script.js";
    new ScriptInclude(b, function () {
        initBranding()
    }.bind(window))
}(function () {
    function a(d) {
        var b;
        if (d.wheelDelta) {
            b = d.wheelDelta / 120
        } else {
            if (d.detail) {
                b = -d.detail / 3
            }
        }
        if (!b) {
            return
        }
        var c = d.element().fire("mouse:wheel", {
            delta: b
        });
        if (c.stopped) {
            d.stop()
        }
    }
    document.observe("mousewheel", a);
    document.observe("DOMMouseScroll", a)
})();
Autocompleter.Ajax = Class.create(Autocompleter.Base, {
    initialize: function (c, d, b, a) {
        this.baseInitialize(c, d, a);
        this.options.asynchronous = true;
        this.options.onComplete = this.onComplete.bind(this);
        this.options.defaultParams = this.options.parameters || null;
        this.options.buildList = this.options.buildList ? this.options.buildList.bind(this) : this.buildList.bind(this);
        this.url = b
    },
    getUpdatedChoices: function () {
        this.startIndicator();
        var a = encodeURIComponent(this.options.paramName) + "=" + encodeURIComponent(this.getToken());
        this.options.parameters = this.options.callback ? this.options.callback(this.element, a) : a;
        if (this.options.defaultParams) {
            this.options.parameters += "&" + this.options.defaultParams
        }
        new Ajax.Request(this.url, this.options)
    },
    onComplete: function (c) {
        try {
            var a = c.responseText.evalJSON();
            this.results = $A(a.result)
        } catch (b) {
            this.results = $A([])
        }
        this.options.buildList()
    },
    markPrevious: function () {
        if (this.index > 0) {
            this.index--
        } else {
            this.index = this.entryCount - 1
        }
        this.getEntry(this.index).scrollIntoView(false)
    },
    buildList: function () {
        var a = [];
        this.results.each(function (b) {
            a.push('<li id="autocomplete_' + b.parent_type + "_" + b.parent_id + '"><strong>' + b.text + "</li>")
        });
        this.updateChoices("<ul>" + a.join("") + "</ul>")
    },
    onKeyPress: function (a) {
        if (this.active) {
            switch (a.keyCode) {
            case Event.KEY_TAB:
            case Event.KEY_RETURN:
                if (this.index < 0) {
                    this.hide();
                    this.active = false;
                    return
                }
                a.stop();
                this.selectEntry();
            case Event.KEY_ESC:
                this.hide();
                this.active = false;
                Event.stop(a);
                return;
            case Event.KEY_LEFT:
            case Event.KEY_RIGHT:
                return;
            case Event.KEY_UP:
                this.markPrevious();
                this.render();
                Event.stop(a);
                return;
            case Event.KEY_DOWN:
                this.markNext();
                this.render();
                Event.stop(a);
                return
            }
        } else {
            if (a.keyCode == Event.KEY_TAB || a.keyCode == Event.KEY_RETURN || (Prototype.Browser.WebKit > 0 && a.keyCode == 0)) {
                return
            }
        }
        this.changed = true;
        this.hasFocus = true;
        if (this.observer) {
            clearTimeout(this.observer)
        }
        this.observer = setTimeout(this.onObserverEvent.bind(this), this.options.frequency * 1000)
    },
    markPrevious: function () {
        if (this.index > 0) {
            this.index--
        } else {
            this.index = this.entryCount - 1
        }
        this.getEntry(this.index).scrollIntoView(false)
    },
    markNext: function () {
        if (this.index < 0) {
            this.index = 0
        } else {
            if (this.index < this.entryCount - 1) {
                this.index++
            } else {
                this.index = 0
            }
        }
        this.getEntry(this.index).scrollIntoView(false)
    },
    selectEntry: function () {
        this.active = false;
        this.updateElement(this.getCurrentEntry())
    },
    onBlur: function (a) {
        if (this.observer) {
            clearTimeout(this.observer)
        }
        this.observer = null;
        setTimeout(this.hide.bind(this), 250);
        this.hasFocus = false;
        this.active = false
    },
    updateChoices: function (c) {
        if (!this.changed && this.hasFocus) {
            this.update.innerHTML = c;
            Element.cleanWhitespace(this.update);
            Element.cleanWhitespace(this.update.down());
            if (this.update.firstChild && this.update.down().childNodes) {
                this.entryCount = this.update.down().childNodes.length;
                for (var a = 0; a < this.entryCount; a++) {
                    var b = this.getEntry(a);
                    b.autocompleteIndex = a;
                    this.addObservers(b)
                }
            } else {
                this.entryCount = 0
            }
            this.stopIndicator();
            this.index = -1;
            if (this.entryCount == 1 && this.options.autoSelect) {
                this.selectEntry();
                this.hide()
            } else {
                this.render()
            }
        }
    }
});
