/*
 * jQuery UI Tabs 1.8.4
 *
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 */
(function (d, p) {
    function u() {
        return ++v
    }
    function w() {
        return ++x
    }
    var v = 0,
        x = 0;
    d.widget("ui.tabs", {
        options: {
            add: null,
            ajaxOptions: null,
            cache: false,
            cookie: null,
            collapsible: false,
            disable: null,
            disabled: [],
            enable: null,
            event: "click",
            fx: null,
            idPrefix: "ui-tabs-",
            load: null,
            panelTemplate: "<div></div>",
            remove: null,
            select: null,
            show: null,
            spinner: "<em>Loading&#8230;</em>",
            tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
        },
        _create: function () {
            this._tabify(true)
        },
        _setOption: function (a, e) {
            if (a == "selected") this.options.collapsible && e == this.options.selected || this.select(e);
            else {
                this.options[a] = e;
                this._tabify()
            }
        },
        _tabId: function (a) {
            return a.title && a.title.replace(/\s/g, "_").replace(/[^A-Za-z0-9\-_:\.]/g, "") || this.options.idPrefix + u()
        },
        _sanitizeSelector: function (a) {
            return a.replace(/:/g, "\\:")
        },
        _cookie: function () {
//            var a = this.cookie || (this.cookie = this.options.cookie.name || "ui-tabs-" + w());
//            return d.cookie.apply(null, [a].concat(d.makeArray(arguments)))
        },
        _ui: function (a, e) {
            return {
                tab: a,
                panel: e,
                index: this.anchors.index(a)
            }
        },
        _cleanup: function () {
            this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function () {
                var a =
                d(this);
                a.html(a.data("label.tabs")).removeData("label.tabs")
            })
        },
        _tabify: function (a) {
            function e(g, f) {
                g.css("display", "");
                !d.support.opacity && f.opacity && g[0].style.removeAttribute("filter")
            }
            var b = this,
                c = this.options,
                h = /^#.+/;
            this.list = this.element.find("ol,ul").eq(0);
            this.lis = d("li:has(a[href])", this.list);
            this.anchors = this.lis.map(function () {
                return d("a", this)[0]
            });
            this.panels = d([]);
            this.anchors.each(function (g, f) {
                var j = d(f).attr("href"),
                    l = j.split("#")[0],
                    q;
                if (l && (l === location.toString().split("#")[0] || (q = d("base")[0]) && l === q.href)) {
                    j = f.hash;
                    f.href = j
                }
                if (h.test(j)) b.panels = b.panels.add(b._sanitizeSelector(j));
                else if (j !== "#") {
                    d.data(f, "href.tabs", j);
                    d.data(f, "load.tabs", j.replace(/#.*$/, ""));
                    j = b._tabId(f);
                    f.href = "#" + j;
                    f = d("#" + j);
                    if (!f.length) {
                        f = d(c.panelTemplate).attr("id", j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(b.panels[g - 1] || b.list);
                        f.data("destroy.tabs", true)
                    }
                    b.panels = b.panels.add(f)
                } else c.disabled.push(g)
            });
            if (a) {
                this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
                this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");
                this.lis.addClass("ui-state-default ui-corner-top");
                this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");
                if (c.selected === p) {
                    location.hash && this.anchors.each(function (g, f) {
                        if (f.hash == location.hash) {
                            c.selected = g;
                            return false
                        }
                    });
                    if (typeof c.selected !== "number" && c.cookie) c.selected = parseInt(b._cookie(), 10);
                    if (typeof c.selected !== "number" && this.lis.filter(".ui-tabs-selected").length) c.selected =
                    this.lis.index(this.lis.filter(".ui-tabs-selected"));
                    c.selected = c.selected || (this.lis.length ? 0 : -1)
                } else if (c.selected === null) c.selected = -1;
                c.selected = c.selected >= 0 && this.anchors[c.selected] || c.selected < 0 ? c.selected : 0;
                c.disabled = d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"), function (g) {
                    return b.lis.index(g)
                }))).sort();
                d.inArray(c.selected, c.disabled) != -1 && c.disabled.splice(d.inArray(c.selected, c.disabled), 1);
                this.panels.addClass("ui-tabs-hide");
                this.lis.removeClass("ui-tabs-selected ui-state-active");
                if (c.selected >= 0 && this.anchors.length) {
                    this.panels.eq(c.selected).removeClass("ui-tabs-hide");
                    this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");
                    b.element.queue("tabs", function () {
                        b._trigger("show", null, b._ui(b.anchors[c.selected], b.panels[c.selected]))
                    });
                    this.load(c.selected)
                }
                d(window).bind("unload", function () {
                    b.lis.add(b.anchors).unbind(".tabs");
                    b.lis = b.anchors = b.panels = null
                })
            } else c.selected = this.lis.index(this.lis.filter(".ui-tabs-selected"));
            this.element[c.collapsible ? "addClass" : "removeClass"]("ui-tabs-collapsible");
            c.cookie && this._cookie(c.selected, c.cookie);
            a = 0;
            for (var i; i = this.lis[a]; a++) d(i)[d.inArray(a, c.disabled) != -1 && !d(i).hasClass("ui-tabs-selected") ? "addClass" : "removeClass"]("ui-state-disabled");
            c.cache === false && this.anchors.removeData("cache.tabs");
            this.lis.add(this.anchors).unbind(".tabs");
            if (c.event !== "mouseover") {
                var k = function (g, f) {
                    f.is(":not(.ui-state-disabled)") && f.addClass("ui-state-" + g)
                },
                    n = function (g, f) {
                        f.removeClass("ui-state-" + g)
                    };
                this.lis.bind("mouseover.tabs", function () {
                    k("hover", d(this))
                });
                this.lis.bind("mouseout.tabs", function () {
                    n("hover", d(this))
                });
                this.anchors.bind("focus.tabs", function () {
                    k("focus", d(this).closest("li"))
                });
                this.anchors.bind("blur.tabs", function () {
                    n("focus", d(this).closest("li"))
                })
            }
            var m, o;
            if (c.fx) if (d.isArray(c.fx)) {
                m = c.fx[0];
                o = c.fx[1]
            } else m = o = c.fx;
            var r = o ?
            function (g, f) {
                d(g).closest("li").addClass("ui-tabs-selected ui-state-active");
                f.hide().removeClass("ui-tabs-hide").animate(o, o.duration || "normal", function () {
                    e(f, o);
                    b._trigger("show", null, b._ui(g, f[0]))
                })
            } : function (g, f) {
                d(g).closest("li").addClass("ui-tabs-selected ui-state-active");
                f.removeClass("ui-tabs-hide");
                b._trigger("show", null, b._ui(g, f[0]))
            },
                s = m ?
                function (g, f) {
                    f.animate(m, m.duration || "normal", function () {
                        b.lis.removeClass("ui-tabs-selected ui-state-active");
                        f.addClass("ui-tabs-hide");
                        e(f, m);
                        b.element.dequeue("tabs")
                    })
                } : function (g, f) {
                    b.lis.removeClass("ui-tabs-selected ui-state-active");
                    f.addClass("ui-tabs-hide");
                    b.element.dequeue("tabs")
                };
            this.anchors.bind(c.event + ".tabs", function () {
                var g = this,
                    f = d(g).closest("li"),
                    j = b.panels.filter(":not(.ui-tabs-hide)"),
                    l = d(b._sanitizeSelector(g.hash));
                if (f.hasClass("ui-tabs-selected") && !c.collapsible || f.hasClass("ui-state-disabled") || f.hasClass("ui-state-processing") || b._trigger("select", null, b._ui(this, l[0])) === false) {
                    this.blur();
                    return false
                }
                c.selected = b.anchors.index(this);
                b.abort();
                if (c.collapsible) if (f.hasClass("ui-tabs-selected")) {
                    c.selected = -1;
                    c.cookie && b._cookie(c.selected, c.cookie);
                    b.element.queue("tabs", function () {
                        s(g, j)
                    }).dequeue("tabs");
                    this.blur();
                    return false
                } else if (!j.length) {
                    c.cookie && b._cookie(c.selected, c.cookie);
                    b.element.queue("tabs", function () {
                        r(g, l)
                    });
                    b.load(b.anchors.index(this));
                    this.blur();
                    return false
                }
                c.cookie && b._cookie(c.selected, c.cookie);
                if (l.length) {
                    j.length && b.element.queue("tabs", function () {
                        s(g, j)
                    });
                    b.element.queue("tabs", function () {
                        r(g, l)
                    });
                    b.load(b.anchors.index(this))
                } else
                throw "jQuery UI Tabs: Mismatching fragment identifier.";
                d.browser.msie && this.blur()
            });
            this.anchors.bind("click.tabs", function () {
                return false
            })
        },
        _getIndex: function (a) {
            if (typeof a == "string") a = this.anchors.index(this.anchors.filter("[href$=" + a + "]"));
            return a
        },
        destroy: function () {
            var a = this.options;
            this.abort();
            this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");
            this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");
            this.anchors.each(function () {
                var e = d.data(this, "href.tabs");
                if (e) this.href =
                e;
                var b = d(this).unbind(".tabs");
                d.each(["href", "load", "cache"], function (c, h) {
                    b.removeData(h + ".tabs")
                })
            });
            this.lis.unbind(".tabs").add(this.panels).each(function () {
                d.data(this, "destroy.tabs") ? d(this).remove() : d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")
            });
            a.cookie && this._cookie(null, a.cookie);
            return this
        },
        add: function (a, e, b) {
            if (b === p) b = this.anchors.length;
            var c = this,
                h = this.options;
            e = d(h.tabTemplate.replace(/#\{href\}/g, a).replace(/#\{label\}/g, e));
            a = !a.indexOf("#") ? a.replace("#", "") : this._tabId(d("a", e)[0]);
            e.addClass("ui-state-default ui-corner-top").data("destroy.tabs", true);
            var i = d("#" + a);
            i.length || (i = d(h.panelTemplate).attr("id", a).data("destroy.tabs", true));
            i.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");
            if (b >= this.lis.length) {
                e.appendTo(this.list);
                i.appendTo(this.list[0].parentNode)
            } else {
                e.insertBefore(this.lis[b]);
                i.insertBefore(this.panels[b])
            }
            h.disabled = d.map(h.disabled, function (k) {
                return k >= b ? ++k : k
            });
            this._tabify();
            if (this.anchors.length == 1) {
                h.selected = 0;
                e.addClass("ui-tabs-selected ui-state-active");
                i.removeClass("ui-tabs-hide");
                this.element.queue("tabs", function () {
                    c._trigger("show", null, c._ui(c.anchors[0], c.panels[0]))
                });
                this.load(0)
            }
            this._trigger("add", null, this._ui(this.anchors[b], this.panels[b]));
            return this
        },
        remove: function (a) {
            a = this._getIndex(a);
            var e = this.options,
                b = this.lis.eq(a).remove(),
                c = this.panels.eq(a).remove();
            if (b.hasClass("ui-tabs-selected") && this.anchors.length > 1) this.select(a + (a + 1 < this.anchors.length ? 1 : -1));
            e.disabled = d.map(d.grep(e.disabled, function (h) {
                return h != a
            }), function (h) {
                return h >= a ? --h : h
            });
            this._tabify();
            this._trigger("remove", null, this._ui(b.find("a")[0], c[0]));
            return this
        },
        enable: function (a) {
            a = this._getIndex(a);
            var e = this.options;
            if (d.inArray(a, e.disabled) != -1) {
                this.lis.eq(a).removeClass("ui-state-disabled");
                e.disabled = d.grep(e.disabled, function (b) {
                    return b != a
                });
                this._trigger("enable", null, this._ui(this.anchors[a], this.panels[a]));
                return this
            }
        },
        disable: function (a) {
            a = this._getIndex(a);
            var e = this.options;
            if (a != e.selected) {
                this.lis.eq(a).addClass("ui-state-disabled");
                e.disabled.push(a);
                e.disabled.sort();
                this._trigger("disable", null, this._ui(this.anchors[a], this.panels[a]))
            }
            return this
        },
        select: function (a) {
            a = this._getIndex(a);
            if (a == -1) if (this.options.collapsible && this.options.selected != -1) a = this.options.selected;
            else
            return this;
            this.anchors.eq(a).trigger(this.options.event + ".tabs");
            return this
        },
        load: function (a) {
            a = this._getIndex(a);
            var e = this,
                b = this.options,
                c = this.anchors.eq(a)[0],
                h = d.data(c, "load.tabs");
            this.abort();
            if (!h || this.element.queue("tabs").length !== 0 && d.data(c, "cache.tabs")) this.element.dequeue("tabs");
            else {
                this.lis.eq(a).addClass("ui-state-processing");
                if (b.spinner) {
                    var i = d("span", c);
                    i.data("label.tabs", i.html()).html(b.spinner)
                }
                this.xhr = d.ajax(d.extend({}, b.ajaxOptions, {
                    url: h,
                    success: function (k, n) {
                        d(e._sanitizeSelector(c.hash)).html(k);
                        e._cleanup();
                        b.cache && d.data(c, "cache.tabs", true);
                        e._trigger("load", null, e._ui(e.anchors[a], e.panels[a]));
                        try {
                            b.ajaxOptions.success(k, n)
                        } catch (m) {}
                    },
                    error: function (k, n) {
                        e._cleanup();
                        e._trigger("load", null, e._ui(e.anchors[a], e.panels[a]));
                        try {
                            b.ajaxOptions.error(k, n, a, c)
                        } catch (m) {}
                    }
                }));
                e.element.dequeue("tabs");
                return this
            }
        },
        abort: function () {
            this.element.queue([]);
            this.panels.stop(false, true);
            this.element.queue("tabs", this.element.queue("tabs").splice(-2, 2));
            if (this.xhr) {
                this.xhr.abort();
                delete this.xhr
            }
            this._cleanup();
            return this
        },
        url: function (a, e) {
            this.anchors.eq(a).removeData("cache.tabs").data("load.tabs", e);
            return this
        },
        length: function () {
            return this.anchors.length
        }
    });
    d.extend(d.ui.tabs, {
        version: "1.8.4"
    });
    d.extend(d.ui.tabs.prototype, {
        rotation: null,
        rotate: function (a, e) {
            var b = this,
                c = this.options,
                h = b._rotate || (b._rotate = function (i) {
                    clearTimeout(b.rotation);
                    b.rotation = setTimeout(function () {
                        var k = c.selected;
                        b.select(++k < b.anchors.length ? k : 0)
                    }, a);
                    i && i.stopPropagation()
                });
            e = b._unrotate || (b._unrotate = !e ?
            function (i) {
                i.clientX && b.rotate(null)
            } : function () {
                t = c.selected;
                h()
            });
            if (a) {
                this.element.bind("tabsshow", h);
                this.anchors.bind(c.event + ".tabs", e);
                h()
            } else {
                clearTimeout(b.rotation);
                this.element.unbind("tabsshow", h);
                this.anchors.unbind(c.event + ".tabs", e);
                delete this._rotate;
                delete this._unrotate
            }
            return this
        }
    })
})(jQuery);

