(function(C) {
    C.ui = {
        plugin: {
            add: function(E, F, H) {
                var G = C.ui[E].prototype;
                for (var D in H) {
                    G.plugins[D] = G.plugins[D] || [];
                    G.plugins[D].push([F, H[D]])
                }
            },
            call: function(D, F, E) {
                var H = D.plugins[F];
                if (!H) {
                    return
                }
                for (var G = 0; G < H.length; G++) {
                    if (D.options[H[G][0]]) {
                        H[G][1].apply(D.element, E)
                    }
                }
            }
        },
        cssCache: {},
        css: function(D) {
            if (C.ui.cssCache[D]) {
                return C.ui.cssCache[D]
            }
            var E = C('<div class="ui-gen">').addClass(D).css({
                position: "absolute",
                top: "-5000px",
                left: "-5000px",
                display: "block"
            }).appendTo("body");
            C.ui.cssCache[D] = !!((!(/auto|default/).test(E.css("cursor")) || (/^[1-9]/).test(E.css("height")) || (/^[1-9]/).test(E.css("width")) || !(/none/).test(E.css("backgroundImage")) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(E.css("backgroundColor"))));
            try {
                C("body").get(0).removeChild(E.get(0))
            } catch(F) {}
            return C.ui.cssCache[D];
        },
        disableSelection: function(D) {
            C(D).attr("unselectable", "on").css("MozUserSelect", "none")
        },
        enableSelection: function(D) {
            C(D).attr("unselectable", "off").css("MozUserSelect", "")
        },
        hasScroll: function(G, E) {
            var D = /top/.test(E || "top") ? "scrollTop": "scrollLeft",
            F = false;
            if (G[D] > 0) {
                return true
            }
            G[D] = 1;
            F = G[D] > 0 ? true: false;
            G[D] = 0;
            return F;
        }
    };
    var B = C.fn.remove;
    C.fn.remove = function() {
        C("*", this).add(this).triggerHandler("remove");
        return B.apply(this, arguments);
    };
    function A(E, F, G) {
        var D = C[E][F].getter || [];
        D = (typeof D == "string" ? D.split(/,?\s+/) : D);
        return (C.inArray(G, D) != -1)
    }
    C.widget = function(E, D) {
        var F = E.split(".")[0];
        E = E.split(".")[1];
        C.fn[E] = function(J) {
            var H = (typeof J == "string"),
            I = Array.prototype.slice.call(arguments, 1);
            if (H && A(F, E, J)) {
                var G = C.data(this[0], E);
                return (G ? G[J].apply(G, I) : undefined)
            }
            return this.each(function() {
                var K = C.data(this, E);
                if (H && K && C.isFunction(K[J])) {
                    K[J].apply(K, I)
                } else {
                    if (!H) {
                        C.data(this, E, new C[F][E](this, J))
                    }
                }
            })
        };
        C[F][E] = function(I, H) {
            var G = this;
            this.widgetName = E;
            this.widgetBaseClass = F + "-" + E;
            this.options = C.extend({},
            C.widget.defaults, C[F][E].defaults, H);
            this.element = C(I).bind("setData." + E,
            function(L, J, K) {
                return G.setData(J, K);
            }).bind("getData." + E,
            function(K, J) {
                return G.getData(J);
            }).bind("remove",
            function() {
                return G.destroy();
            });
            this.init()
        };
        C[F][E].prototype = C.extend({},
        C.widget.prototype, D)
    };
    C.widget.prototype = {
        init: function() {},
        destroy: function() {
            this.element.removeData(this.widgetName)
        },
        getData: function(D) {
            return this.options[D];
        },
        setData: function(D, E) {
            this.options[D] = E;
            if (D == "disabled") {
                this.element[E ? "addClass": "removeClass"](this.widgetBaseClass + "-disabled")
            }
        },
        enable: function() {
            this.setData("disabled", false)
        },
        disable: function() {
            this.setData("disabled", true)
        }
    };
    C.widget.defaults = {
        disabled: false
    };
    C.ui.mouse = {
        mouseInit: function() {
            var D = this;
            this.element.bind("mousedown." + this.widgetName,
            function(E) {
                return D.mouseDown(E);
            });
            if (C.browser.msie) {
                this._mouseUnselectable = this.element.attr("unselectable");
                this.element.attr("unselectable", "on")
            }
            this.started = false;
        },
        mouseDestroy: function() {
            this.element.unbind("." + this.widgetName);
            (C.browser.msie && this.element.attr("unselectable", this._mouseUnselectable))
        },
        mouseDown: function(F) { (this._mouseStarted && this.mouseUp(F));
            this._mouseDownEvent = F;
            var E = this,
            G = (F.which == 1),
            D = (typeof this.options.cancel == "string" ? C(F.target).parents().add(F.target).filter(this.options.cancel).length: false);
            if (!G || D || !this.mouseCapture(F)) {
                return true
            }
            this._mouseDelayMet = !this.options.delay;
            if (!this._mouseDelayMet) {
                this._mouseDelayTimer = setTimeout(function() {
                    E._mouseDelayMet = true;
                },
                this.options.delay)
            }
            if (this.mouseDistanceMet(F) && this.mouseDelayMet(F)) {
                this._mouseStarted = (this.mouseStart(F) !== false);
                if (!this._mouseStarted) {
                    F.preventDefault();
                    return true;
                }
            }
            this._mouseMoveDelegate = function(H) {
                return E.mouseMove(H);
            };
            this._mouseUpDelegate = function(H) {
                return E.mouseUp(H);
            };
            C(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate);
            return false;
        },
        mouseMove: function(D) {
            if (C.browser.msie && !D.button) {
                return this.mouseUp(D)
            }
            if (this._mouseStarted) {
                this.mouseDrag(D);
                return false
            }
            if (this.mouseDistanceMet(D) && this.mouseDelayMet(D)) {
                this._mouseStarted = (this.mouseStart(this._mouseDownEvent, D) !== false);
                (this._mouseStarted ? this.mouseDrag(D) : this.mouseUp(D))
            }
            return ! this._mouseStarted;
        },
        mouseUp: function(D) {
            C(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
            if (this._mouseStarted) {
                this._mouseStarted = false;
                this.mouseStop(D)
            }
            return false;
        },
        mouseDistanceMet: function(D) {
            return (Math.max(Math.abs(this._mouseDownEvent.pageX - D.pageX), Math.abs(this._mouseDownEvent.pageY - D.pageY)) >= this.options.distance);
        },
        mouseDelayMet: function(D) {
            return this._mouseDelayMet;
        },
        mouseStart: function(D) {},
        mouseDrag: function(D) {},
        mouseStop: function(D) {},
        mouseCapture: function(D) {
            return true;
        }
    };
    C.ui.mouse.defaults = {
        cancel: null,
        distance: 1,
        delay: 0
    }
})(jQuery);
(function(E) {
    E.widget("ui.accordion", {
        init: function() {
            var G = this.options;
            if (G.navigation) {
                var J = this.element.find("a").filter(G.navigationFilter);
                if (J.length) {
                    if (J.filter(G.header).length) {
                        G.active = J
                    } else {
                        G.active = J.parent().parent().prev();
                        J.addClass("current")
                    }
                }
            }
            G.headers = this.element.find(G.header);
            G.active = C(G.headers, G.active);
            if (E.browser.msie) {
                this.element.find("a").css("zoom", "1")
            }
            if (!this.element.hasClass("ui-accordion")) {
                this.element.addClass("ui-accordion");
                E("<span class='ui-accordion-left'/>").insertBefore(G.headers);
                E("<span class='ui-accordion-right'/>").appendTo(G.headers);
                G.headers.addClass("ui-accordion-header").attr("tabindex", "0")
            }
            var I;
            if (G.fillSpace) {
                I = this.element.parent().height();
                G.headers.each(function() {
                    I -= E(this).outerHeight()
                });
                var H = 0;
                G.headers.next().each(function() {
                    H = Math.max(H, E(this).innerHeight() - E(this).height());
                }).height(I - H)
            } else {
                if (G.autoHeight) {
                    I = 0;
                    G.headers.next().each(function() {
                        I = Math.max(I, E(this).outerHeight());
                    }).height(I)
                }
            }
            G.headers.not(G.active || "").next().hide();
            G.active.parent().andSelf().addClass(G.selectedClass);
            if (G.event) {
                this.element.bind((G.event) + ".accordion", F)
            }
        },
        activate: function(G) {
            F.call(this.element[0], {
                target: C(this.options.headers, G)[0]
            })
        },
        destroy: function() {
            this.options.headers.next().css("display", "");
            if (this.options.fillSpace || this.options.autoHeight) {
                this.options.headers.next().css("height", "")
            }
            E.removeData(this.element[0], "accordion");
            this.element.removeClass("ui-accordion").unbind(".accordion")
        }
    });
    function B(H, G) {
        return function() {
            return H.apply(G, arguments);
        }
    }
    function D(I) {
        if (!E.data(this, "accordion")) {
            return
        }
        var G = E.data(this, "accordion");
        var H = G.options;
        H.running = I ? 0 : --H.running;
        if (H.running) {
            return
        }
        if (H.clearStyle) {
            H.toShow.add(H.toHide).css({
                height: "",
                overflow: ""
            })
        }
        E(this).triggerHandler("accordionchange", [E.event.fix({
            type: "accordionchange",
            target: G.element[0]
        }), H.data], H.change)
    }
    function A(G, K, L, J, M) {
        var I = E.data(this, "accordion").options;
        I.toShow = G;
        I.toHide = K;
        I.data = L;
        var H = B(D, this);
        I.running = K.size() === 0 ? G.size() : K.size();
        if (I.animated) {
            if (!I.alwaysOpen && J) {
                E.ui.accordion.animations[I.animated]({
                    toShow: jQuery([]),
                    toHide: K,
                    complete: H,
                    down: M,
                    autoHeight: I.autoHeight
                })
            } else {
                E.ui.accordion.animations[I.animated]({
                    toShow: G,
                    toHide: K,
                    complete: H,
                    down: M,
                    autoHeight: I.autoHeight
                })
            }
        } else {
            if (!I.alwaysOpen && J) {
                G.toggle()
            } else {
                K.hide();
                G.show()
            }
            H(true)
        }
    }
    function F(L) {
        var J = E.data(this, "accordion").options;
        if (J.disabled) {
            return false
        }
        if (!L.target && !J.alwaysOpen) {
            J.active.parent().andSelf().toggleClass(J.selectedClass);
            var I = J.active.next(),
            M = {
                options: J,
                newHeader: jQuery([]),
                oldHeader: J.active,
                newContent: jQuery([]),
                oldContent: I
            },
            G = (J.active = E([]));
            A.call(this, G, I, M);
            return false
        }
        var K = E(L.target);
        K = E(K.parents(J.header)[0] || K);
        var H = K[0] == J.active[0];
        if (J.running || (J.alwaysOpen && H)) {
            return false
        }
        if (!K.is(J.header)) {
            return
        }
        J.active.parent().andSelf().toggleClass(J.selectedClass);
        if (!H) {
            K.parent().andSelf().addClass(J.selectedClass)
        }
        var G = K.next(),
        I = J.active.next(),
        M = {
            options: J,
            newHeader: K,
            oldHeader: J.active,
            newContent: G,
            oldContent: I
        },
        N = J.headers.index(J.active[0]) > J.headers.index(K[0]);
        J.active = H ? E([]) : K;
        A.call(this, G, I, M, H, N);
        return false
    }
    function C(H, G) {
        return G != undefined ? typeof G == "number" ? H.filter(":eq(" + G + ")") : H.not(H.not(G)) : G === false ? E([]) : H.filter(":eq(0)")
    }
    E.extend(E.ui.accordion, {
        defaults: {
            selectedClass: "selected",
            alwaysOpen: true,
            animated: "slide",
            event: "click",
            header: "a",
            autoHeight: true,
            running: 0,
            navigationFilter: function() {
                return this.href.toLowerCase() == location.href.toLowerCase();
            }
        },
        animations: {
            slide: function(G, I) {
                G = E.extend({
                    easing: "swing",
                    duration: 300
                },
                G, I);
                if (!G.toHide.size()) {
                    G.toShow.animate({
                        height: "show"
                    },
                    G);
                    return
                }
                var H = G.toHide.height(),
                J = G.toShow.height(),
                K = J / H;
                G.toShow.css({
                    height: 0,
                    overflow: "hidden"
                }).show();
                G.toHide.filter(":hidden").each(G.complete).end().filter(":visible").animate({
                    height: "hide"
                },
                {
                    step: function(L) {
                        var M = (H - L) * K;
                        if (E.browser.msie || E.browser.opera) {
                            M = Math.ceil(M)
                        }
                        G.toShow.height(M);
                    },
                    duration: G.duration,
                    easing: G.easing,
                    complete: function() {
                        if (!G.autoHeight) {
                            G.toShow.css("height", "auto")
                        }
                        G.complete()
                    }
                })
            },
            bounceslide: function(G) {
                this.slide(G, {
                    easing: G.down ? "bounceout": "swing",
                    duration: G.down ? 1000 : 200
                })
            },
            easeslide: function(G) {
                this.slide(G, {
                    easing: "easeinout",
                    duration: 700
                })
            }
        }
    });
    E.fn.activate = function(G) {
        return this.accordion("activate", G);
    }
})(jQuery);