(function(n){function l(a){var c=n('<input type="hidden">').insertAfter(a);var b=n(a).attr("name");if(b){c.attr("name",b);n(a).removeAttr("name").attr("numberboxName",b)}return c}function o(b){var c=n.data(b,"numberbox").options;var a=c.onChange;c.onChange=function(){};i(b,c.parser.call(b,c.value));c.onChange=a}function j(a){return n.data(a,"numberbox").field.val()}function i(a,b){var c=n.data(a,"numberbox");var d=c.options;var e=j(a);b=d.parser.call(a,b);d.value=b;c.field.val(b);n(a).val(d.formatter.call(a,b));if(e!=b){d.onChange.call(a,b,e)}}function k(a){var b=n.data(a,"numberbox").options;n(a).unbind(".numberbox").bind("keypress.numberbox",function(c){if(c.which==45){return true}if(c.which==46){return true}else{if((c.which>=48&&c.which<=57&&c.ctrlKey==false&&c.shiftKey==false)||c.which==0||c.which==8){return true}else{if(c.ctrlKey==true&&(c.which==99||c.which==118)){return true}else{return false}}}}).bind("paste.numberbox",function(){if(window.clipboardData){var c=clipboardData.getData("text");if(!/\D/.test(c)){return true}else{return false}}else{return false}}).bind("dragenter.numberbox",function(){return false}).bind("blur.numberbox",function(){i(a,n(this).val());n(this).val(b.formatter.call(a,j(a)))}).bind("focus.numberbox",function(){var c=j(a);if(n(this).val()!=c){n(this).val(c)}})}function m(a){if(n.fn.validatebox){var b=n.data(a,"numberbox").options;n(a).validatebox(b)}}function p(a,b){var c=n.data(a,"numberbox").options;if(b){c.disabled=true;n(a).attr("disabled",true)}else{c.disabled=false;n(a).removeAttr("disabled")}}n.fn.numberbox=function(c,a){if(typeof c=="string"){var b=n.fn.numberbox.methods[c];if(b){return b(this,a)}else{return this.validatebox(c,a)}}c=c||{};return this.each(function(){var d=n.data(this,"numberbox");if(d){n.extend(d.options,c)}else{d=n.data(this,"numberbox",{options:n.extend({},n.fn.numberbox.defaults,n.fn.numberbox.parseOptions(this),c),field:l(this)});n(this).removeAttr("disabled");n(this).css({imeMode:"disabled"})}p(this,d.options.disabled);k(this);m(this);o(this)})};n.fn.numberbox.methods={options:function(a){return n.data(a[0],"numberbox").options},destroy:function(a){return a.each(function(){n.data(this,"numberbox").field.remove();n(this).validatebox("destroy");n(this).remove()})},disable:function(a){return a.each(function(){p(this,true)})},enable:function(a){return a.each(function(){p(this,false)})},fix:function(a){return a.each(function(){i(this,n(this).val())})},setValue:function(a,b){return a.each(function(){i(this,b)})},getValue:function(a){return j(a[0])},clear:function(a){return a.each(function(){var b=n.data(this,"numberbox");b.field.val("");n(this).val("")})}};n.fn.numberbox.parseOptions=function(b){var a=n(b);return n.extend({},n.fn.validatebox.parseOptions(b),{disabled:(a.attr("disabled")?true:undefined),value:(a.val()||undefined),min:(a.attr("min")=="0"?0:parseFloat(a.attr("min"))||undefined),max:(a.attr("max")=="0"?0:parseFloat(a.attr("max"))||undefined),precision:(parseInt(a.attr("precision"))||undefined),decimalSeparator:(a.attr("decimalSeparator")?a.attr("decimalSeparator"):undefined),groupSeparator:(a.attr("groupSeparator")?a.attr("groupSeparator"):undefined),prefix:(a.attr("prefix")?a.attr("prefix"):undefined),suffix:(a.attr("suffix")?a.attr("suffix"):undefined)})};n.fn.numberbox.defaults=n.extend({},n.fn.validatebox.defaults,{disabled:false,value:"",min:null,max:null,precision:0,decimalSeparator:".",groupSeparator:"",prefix:"",suffix:"",formatter:function(d){if(!d){return d}d=d+"";var e=n(this).numberbox("options");var b=d,c="";var f=d.indexOf(".");if(f>=0){b=d.substring(0,f);c=d.substring(f+1,d.length)}if(e.groupSeparator){var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1"+e.groupSeparator+"$2")}}if(c){return e.prefix+b+e.decimalSeparator+c+e.suffix}else{return e.prefix+b+e.suffix}},parser:function(c){c=c+"";var a=n(this).numberbox("options");if(a.groupSeparator){c=c.replace(new RegExp("\\"+a.groupSeparator,"g"),"")}if(a.decimalSeparator){c=c.replace(new RegExp("\\"+a.decimalSeparator,"g"),".")}if(a.prefix){c=c.replace(new RegExp("\\"+n.trim(a.prefix),"g"),"")}if(a.suffix){c=c.replace(new RegExp("\\"+n.trim(a.suffix),"g"),"")}c=c.replace(/\s/g,"");var b=parseFloat(c).toFixed(a.precision);if(isNaN(b)){b=""}else{if(typeof(a.min)=="number"&&b<a.min){b=a.min.toFixed(a.precision)}else{if(typeof(a.max)=="number"&&b>a.max){b=a.max.toFixed(a.precision)}}}return b},onChange:function(a,b){}})})(jQuery);