(function ($) {

    $.fn.adjustSize = function (width, height) {
        var rate = parseFloat(width) / parseFloat(height);
        //$(this).load(function () {
        $(this).width('auto');
        $(this).height('auto');

        var oriWidth = $(this).width();
        var oriHeight = $(this).height();
        if ((oriWidth / oriHeight) >= rate)
            $(this).width(oriWidth > width ? width : oriWidth);
        else
            $(this).height(oriHeight > height ? height : oriHeight);
        //});
    };

    //块タ絋计
    $.fn.numericOnly = function (integerOnly) {
        this.filter(":text,:password")
        .each(function () {
            if (!$(this).attr("class")) {
                if (integerOnly)
                    $(this).addClass("integer");
                else
                    $(this).addClass("numeric");
            }
            $(this).keypress(function (event) {
                if (event.which < 48 || event.which > 57) { //计 0°9
                    if (!integerOnly)
                        return (event.which == 46); //计翴
                    else //す砛俱计
                        return false;
                }
            }).change(function () {
                var enter = $(this).val();
                if (isNaN(parseInt(enter)) || isNaN(parseFloat(enter))) {
                    alert("叫块タ絋计");
                    $(this).val("0");
                }
            });
        }).end();
    };

})(jQuery);
