n)?n:k;var j=this.round(k,this.digits);this.trigger(j);var m=this.focused?this.formatEdit(j):this.format(j);i.removeClass("t-state-error").val(m)},formatEdit:function(i){var h=this.separator;if(i&&h!="."){i=i.toString().replace(".",h)}return i},format:function(h){return g.textbox.formatNumber(h,this.numFormat,this.digits,this.separator,this.groupSeparator,this.groupSize,this.positive,this.negative,this.symbol,true)},trigger:function(h){if(this.val!=h){if(g.trigger(this.element,"change",{oldValue:this.val,newValue:h})){return}d(".t-input:last",this.element).val(this.formatEdit(h));this.val=h}},parseTrigger:function(h){this.trigger(this.round(this.parse(h,this.separator),this.digits))},inRange:function(j,h,i){return j===null||((h!==null?j>=h:true)&&(i!==null?j<=i:true))},parse:function(h,j){var i=null;if(h||h=="0"){if(typeof h==typeof 1){return h}h=h.replace(this.replaceRegExp,"");if(j&&j!="."){h=h.replace(j,".")}var l=d.fn.tTextBox.patterns[this.type].negative[this.negative].replace(/(\(|\))/g,"\\$1").replace("*","").replace("n","([\\d|\\.]*)"),k=new RegExp(l);if(k.test(h)){i=-parseFloat(k.exec(h)[1])}else{i=parseFloat(h)}}return isNaN(i)?null:i},round:function(i,h){if(i||i==0){return parseFloat(i.toFixed(h||2))}return null}};d.fn.tTextBox=function(j){var i=j.type,h=d.fn.tTextBox.defaults[i];h.digits=g.cultureInfo[i+"decimaldigits"];h.separator=g.cultureInfo[i+"decimalseparator"];h.groupSeparator=g.cultureInfo[i+"groupseparator"];h.groupSize=g.cultureInfo[i+"groupsize"];h.positive=g.cultureInfo[i+"positive"];h.negative=g.cultureInfo[i+"negative"];h.symbol=g.cultureInfo[i+"symbol"];j=d.extend({},h,j);return this.each(function(){var k=d(this);j=d.meta?d.extend({},j,k.data()):j;if(!k.data("tTextBox")){k.data("tTextBox",new g.textbox(this,j));g.trigger(this,"load")}})};var f={val:null,text:"",step:1,inputAttributes:""};d.fn.tTextBox.defaults={numeric:d.extend(f,{minValue:-100,maxValue:100}),currency:d.extend(f,{minValue:0,maxValue:1000}),percent:d.extend(f,{minValue:0,maxValue:100})};d.fn.tTextBox.patterns={numeric:{negative:["(n)","-n","- n","n-","n -"]},currency:{positive:["*n","n*","* n","n *"],negative:["(*n)","-*n","*-n","*n-","(n*)","-n*","n-*","n*-","-n *","-* n","n *-","* n-","* -n","n- *","(* n)","(n *)"]},percent:{positive:["n *","n*","*n"],negative:["-n *","-n*","-*n"]}};if(!g.cultureInfo.numericnegative){d.extend(g.cultureInfo,{currencydecimaldigits:2,currencydecimalseparator:".",currencygroupseparator:",",currencygroupsize:3,currencynegative:0,currencypositive:0,currencysymbol:"$",numericdecimaldigits:2,numericdecimalseparator:".",numericgroupseparator:",",numericgroupsize:3,numericnegative:1,percentdecimaldigits:2,percentdecimalseparator:".",percentgroupseparator:",",percentgroupsize:3,percentnegative:0,percentpositive:0,percentsymbol:"%"})}var c=/[0#?]/;function b(h){return h.split("").reverse().join("")}function e(n,h,q){var k=0,l=0,p=h.length,r=n.length,u=new g.stringBuilder();while(k=0){if(h.charAt(k).match(c)){u.cat(n.charAt(l++))}else{u.cat(h.charAt(k))}k++}u.catIf(n.substring(l),l-1){s=t.indexOf("0")}if(s>-1){var m=t.slice(0,s),o=t.slice(s,t.length);t=m.replace(/#/g,"")+o.replace(/#/g,"0")}else{t=t.replace(/#/g,"")}if(t.indexOf(",")==0){t=t.replace(/,/g,"")}return q?t:b(t)}g.textbox.formatNumber=function(K,n,s,u,i,Q,o,q,M,F){if(!n){return K}var P,G,L,m,J=K<0;n=n.split(":");n=n.length>1?n[1].replace("}",""):n[0];var l=n.search(c)!=-1;if(l){n=n.split(";");G=n[0];L=n[1];m=n[2];n=(J&&L?L:G).indexOf("%")!=-1?"p":"n"}switch(n.toLowerCase()){case"d":return Math.round(K).toString();case"c":P="currency";break;case"n":P="numeric";break;case"p":P="percent";if(!F){K=Math.abs(K)*100}break;default:return K.toString()}var z=function(T,R,S){for(var U=T.length;U1?C[1]:"";var h=g.lastIndexOf(A,"0");var x=g.lastIndexOf(A,"#");var s=(x>h?x:h)+1}var B=Math.pow(10,s);var N=(Math.round(K*B)/B);K=isFinite(N)?N:K;var v=K.toString().split(/e/i);y=v.length>1?parseInt(v[1]):0;v=v[0].split(".");j=v[0];j=J?j.replace("-",""):j;r=v.length>1?v[1]:"";if(y){if(!J){r=z(r,y,false);j+=r.slice(0,y);r=r.substr(y)}else{j=z(j,y+1,true);r=j.slice(y,j.length)+r;j=j.slice(0,y)}}var O=r.length;if(s<1||(l&&h==-1&&O===0)){r=""}else{r=O>s?r.slice(0,s):z(r,s,false)}var k;if(l){if(j==0){j=""}j=e(b(j),b(w),true);j=w.indexOf(",")!=-1?I(j,i,Q):j;r=r&&A?e(r,A):"";k=K===0&&m?m:(J&&!L?"-":"")+j+(r.length>0?u+r:"")}else{j=I(j,i,Q);H=H[P];var t=J?H.negative[q]:M?H.positive[o]:null;var p=j+(r.length>0?u+r:"");k=t?t.replace("n",p).replace("*",M):p}return k};d.extend(g.formatters,{number:g.textbox.formatNumber})})(jQuery);