/*
* jQuery UI Button 1.8.12
*
* Copyright 2011, 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/Button
*
* Depends:
*	jquery.ui.core.js
*	jquery.ui.widget.js
*/
(function(a) {
    var g, i = function(b) { a(":ui-button", b.target.form).each(function() { var c = a(this).data("button"); setTimeout(function() { c.refresh() }, 1) }) }, h = function(b) { var c = b.name, d = b.form, f = a([]); if (c) f = d ? a(d).find("[name='" + c + "']") : a("[name='" + c + "']", b.ownerDocument).filter(function() { return !this.form }); return f }; a.widget("ui.button", { options: { disabled: null, text: true, label: null, icons: { primary: null, secondary: null} }, _create: function() {
        this.element.closest("form").unbind("reset.button").bind("reset.button",
i); if (typeof this.options.disabled !== "boolean") this.options.disabled = this.element.attr("disabled"); this._determineButtonType(); this.hasTitle = !!this.buttonElement.attr("title"); var b = this, c = this.options, d = this.type === "checkbox" || this.type === "radio", f = "ui-state-hover" + (!d ? " ui-state-active" : ""); if (c.label === null) c.label = this.buttonElement.html(); if (this.element.is(":disabled")) c.disabled = true; this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role", "button").bind("mouseenter.button",
function() { if (!c.disabled) { a(this).addClass("ui-state-hover"); this === g && a(this).addClass("ui-state-active") } }).bind("mouseleave.button", function() { c.disabled || a(this).removeClass(f) }).bind("focus.button", function() { a(this).addClass("ui-state-focus") }).bind("blur.button", function() { a(this).removeClass("ui-state-focus") }); d && this.element.bind("change.button", function() { b.refresh() }); if (this.type === "checkbox") this.buttonElement.bind("click.button", function() {
    if (c.disabled) return false; a(this).toggleClass("ui-state-active");
    b.buttonElement.attr("aria-pressed", b.element[0].checked)
}); else if (this.type === "radio") this.buttonElement.bind("click.button", function() { if (c.disabled) return false; a(this).addClass("ui-state-active"); b.buttonElement.attr("aria-pressed", true); var e = b.element[0]; h(e).not(e).map(function() { return a(this).button("widget")[0] }).removeClass("ui-state-active").attr("aria-pressed", false) }); else {
            this.buttonElement.bind("mousedown.button", function() {
                if (c.disabled) return false; a(this).addClass("ui-state-active");
                g = this; a(document).one("mouseup", function() { g = null })
            }).bind("mouseup.button", function() { if (c.disabled) return false; a(this).removeClass("ui-state-active") }).bind("keydown.button", function(e) { if (c.disabled) return false; if (e.keyCode == a.ui.keyCode.SPACE || e.keyCode == a.ui.keyCode.ENTER) a(this).addClass("ui-state-active") }).bind("keyup.button", function() { a(this).removeClass("ui-state-active") }); this.buttonElement.is("a") && this.buttonElement.keyup(function(e) { e.keyCode === a.ui.keyCode.SPACE && a(this).click() })
        } this._setOption("disabled",
c.disabled)
    }, _determineButtonType: function() {
        this.type = this.element.is(":checkbox") ? "checkbox" : this.element.is(":radio") ? "radio" : this.element.is("input") ? "input" : "button"; if (this.type === "checkbox" || this.type === "radio") {
            var b = this.element.parents().filter(":last"), c = "label[for=" + this.element.attr("id") + "]"; this.buttonElement = b.find(c); if (!this.buttonElement.length) { b = b.length ? b.siblings() : this.element.siblings(); this.buttonElement = b.filter(c); if (!this.buttonElement.length) this.buttonElement = b.find(c) } this.element.addClass("ui-helper-hidden-accessible");
            (b = this.element.is(":checked")) && this.buttonElement.addClass("ui-state-active"); this.buttonElement.attr("aria-pressed", b)
        } else this.buttonElement = this.element
    }, widget: function() { return this.buttonElement }, destroy: function() {
        this.element.removeClass("ui-helper-hidden-accessible"); this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active  ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());
        this.hasTitle || this.buttonElement.removeAttr("title"); a.Widget.prototype.destroy.call(this)
    }, _setOption: function(b, c) { a.Widget.prototype._setOption.apply(this, arguments); if (b === "disabled") c ? this.element.attr("disabled", true) : this.element.removeAttr("disabled"); this._resetButton() }, refresh: function() {
        var b = this.element.is(":disabled"); b !== this.options.disabled && this._setOption("disabled", b); if (this.type === "radio") h(this.element[0]).each(function() {
            a(this).is(":checked") ? a(this).button("widget").addClass("ui-state-active").attr("aria-pressed",
true) : a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed", false)
        }); else if (this.type === "checkbox") this.element.is(":checked") ? this.buttonElement.addClass("ui-state-active").attr("aria-pressed", true) : this.buttonElement.removeClass("ui-state-active").attr("aria-pressed", false)
    }, _resetButton: function() {
        if (this.type === "input") this.options.label && this.element.val(this.options.label); else {
            var b = this.buttonElement.removeClass("ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only"),
c = a("<span></span>").addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(), d = this.options.icons, f = d.primary && d.secondary, e = []; if (d.primary || d.secondary) {
                if (this.options.text) e.push("ui-button-text-icon" + (f ? "s" : d.primary ? "-primary" : "-secondary")); d.primary && b.prepend("<span class='ui-button-icon-primary ui-icon " + d.primary + "'></span>"); d.secondary && b.append("<span class='ui-button-icon-secondary ui-icon " + d.secondary + "'></span>"); if (!this.options.text) {
                    e.push(f ? "ui-button-icons-only" :
"ui-button-icon-only"); this.hasTitle || b.attr("title", c)
                } 
            } else e.push("ui-button-text-only"); b.addClass(e.join(" "))
        } 
    } 
    }); a.widget("ui.buttonset", { options: { items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" }, _create: function() { this.element.addClass("ui-buttonset") }, _init: function() { this.refresh() }, _setOption: function(b, c) { b === "disabled" && this.buttons.button("option", b, c); a.Widget.prototype._setOption.apply(this, arguments) }, refresh: function() { this.buttons = this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function() { return a(this).button("widget")[0] }).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass("ui-corner-left").end().filter(":last").addClass("ui-corner-right").end().end() },
        destroy: function() { this.element.removeClass("ui-buttonset"); this.buttons.map(function() { return a(this).button("widget")[0] }).removeClass("ui-corner-left ui-corner-right").end().button("destroy"); a.Widget.prototype.destroy.call(this) } 
    })
})(jQuery);

