(function($) {
    /**
     * Shows/hides element(s) and enables/disables form elements.
     * @param visible True to show, false to hide
     * @param slow True to animate, false to execute immediately (optional, default: true)
     */
    $.fn.showHide = function(visible, slow) {
        if(slow === undefined) slow = true;

        if(visible) {
            this.find(":input").removeAttr("disabled");
            if(slow == true) this.show("slow");
            else this.show();
        } else {
            this.find(":input").attr("disabled", true);
            if(slow == true) this.hide("slow");
            else this.hide();
        }
    }

    /**
     * Limits the maximum length of an input element.
     * @param max Maximum length
     */
    $.fn.maxLength = function(max) {
        this.keyup(function() {
            this.value = this.value.substr(0, max);
        });
    };
})(jQuery);

