/*! http://www.teamdf.com/web/jquery-number-format-redux/196/ jQuery number 2.1.0 (c) github.com/teamdf/jquery-number | opensource.teamdf.com/license */ (function(d){function e(h,g){if(this.createTextRange){var i=this.createTextRange(); i.collapse(true); i.moveStart("character",h); i.moveEnd("character",g-h); i.select(); }else{if(this.setSelectionRange){this.focus(); this.setSelectionRange(h,g); }}}function c(h){var g=this.value.length; h=h.toLowerCase()=="start"?"Start":"End"; if(document.selection){g=document.selection.createRange(); var i; i=g.duplicate(); i.expand("textedit"); i.setEndPoint("EndToEnd",g); i=i.text.length-g.text.length; g=i+g.text.length; return h=="Start"?i:g; }else{if(typeof this["selection"+h]!="undefined"){g=this["selection"+h]; }}return g; }var f={codes:{188:44,109:45,190:46,191:47,192:96,220:92,222:39,221:93,219:91,173:45,187:61,186:59,189:45,110:46},shifts:{96:"~",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",48:")",45:"_",61:"+",91:"{",93:"}",92:"|",59:":",39:'"',44:"<",46:">",47:"?"}}; d.fn.number=function(m,h,q,g){g=typeof g==="undefined"?",":g; q=typeof q==="undefined"?".":q; h=typeof h==="undefined"?0:h; var j="\\u"+("0000"+q.charCodeAt(0).toString(16)).slice(-4),p=RegExp("[^"+j+"0-9]","g"),k=RegExp(j,"g"); if(m===true){return this.is("input:text")?this.on({"keydown.format":function(l){var s=d(this),u=s.data("numFormat"),r=l.keyCode?l.keyCode:l.which,i="",o=c.apply(this,["start"]),t=c.apply(this,["end"]),n=""; n=false; if(f.codes.hasOwnProperty(r)){r=f.codes[r]; }if(!l.shiftKey&&r>=65&&r<=90){r+=32; }else{if(!l.shiftKey&&r>=69&&r<=105){r-=48; }else{if(l.shiftKey&&f.shifts.hasOwnProperty(r)){i=f.shifts[r]; }}}if(i==""){i=String.fromCharCode(r); }if(r!==8&&i!=q&&!i.match(/[0-9]/)){s=l.keyCode?l.keyCode:l.which; if(s==46||s==8||s==9||s==27||s==13||(s==65||s==82)&&(l.ctrlKey||l.metaKey)===true||s>=35&&s<=39){return; }l.preventDefault(); return false; }if((o==0&&t==this.value.length||s.val()==0)&&!l.metaKey&&!l.ctrlKey&&!l.altKey&&i.length===1&&i!=0){o=t=1; this.value=""; u.init=h>0?-1:0; u.c=h>0?-(h+1):0; e.apply(this,[0,0]); }else{u.c=t-this.value.length; }if(h>0&&i==q&&o==this.value.length-h-1){u.c++; u.init=Math.max(0,u.init); l.preventDefault(); n=this.value.length+u.c; }else{if(i==q){u.init=Math.max(0,u.init); l.preventDefault(); }else{if(h>0&&r==8&&o==this.value.length-h){l.preventDefault(); u.c--; n=this.value.length+u.c; }else{if(h>0&&r==8&&o>this.value.length-h){if(this.value===""){return; }if(this.value.slice(o-1,o)!="0"){n=this.value.slice(0,o-1)+"0"+this.value.slice(o); s.val(n.replace(p,"").replace(k,q)); }l.preventDefault(); u.c--; n=this.value.length+u.c; }else{if(r==8&&this.value.slice(o-1,o)==g){l.preventDefault(); u.c--; n=this.value.length+u.c; }else{if(h>0&&o==t&&this.value.length>h+1&&o>this.value.length-h-1&&isFinite(+i)&&!l.metaKey&&!l.ctrlKey&&!l.altKey&&i.length===1){this.value=n=t===this.value.length?this.value.slice(0,o-1):this.value.slice(0,o)+this.value.slice(o+1); n=o; }}}}}}n!==false&&e.apply(this,[n,n]); s.data("numFormat",u); },"keyup.format":function(i){var n=d(this),o=n.data("numFormat"); i=i.keyCode?i.keyCode:i.which; var l=c.apply(this,["start"]); if(!(this.value===""||(i<48||i>57)&&(i<96||i>105)&&i!==8)){n.val(n.val()); if(h>0){if(o.init<1){l=this.value.length-h-(o.init<0?1:0); o.c=l-this.value.length; o.init=1; n.data("numFormat",o); }else{if(l>this.value.length-h&&i!=8){o.c++; n.data("numFormat",o); }}}n=this.value.length+o.c; e.apply(this,[n,n]); }},"paste.format":function(i){var n=d(this),o=i.originalEvent,l=null; if(window.clipboardData&&window.clipboardData.getData){l=window.clipboardData.getData("Text"); }else{if(o.clipboardData&&o.clipboardData.getData){l=o.clipboardData.getData("text/plain"); }}n.val(l); i.preventDefault(); return false; }}).each(function(){var i=d(this).data("numFormat",{c:-(h+1),decimals:h,thousands_sep:g,dec_point:q,regex_dec_num:p,regex_dec:k,init:false}); this.value!==""&&i.val(i.val()); }):this.each(function(){var i=d(this),l=+i.text().replace(p,"").replace(k,"."); i.number(!isFinite(l)?0:+l,h,q,g); }); }return this.text(d.number.apply(window,arguments)); }; var b=null,a=null; if(d.valHooks.text){b=d.valHooks.text.get; a=d.valHooks.text.set; }else{d.valHooks.text={}; }d.valHooks.text.get=function(h){var g=d(h).data("numFormat"); if(g){if(h.value===""){return""; }h=+h.value.replace(g.regex_dec_num,"").replace(g.regex_dec,"."); return""+(isFinite(h)?h:0); }else{if(d.isFunction(b)){return b(h); }}}; d.valHooks.text.set=function(h,g){var i=d(h).data("numFormat"); if(i){return h.value=d.number(g,i.decimals,i.dec_point,i.thousands_sep); }else{if(d.isFunction(a)){return a(h,g); }}}; d.number=function(k,h,m,g){g=typeof g==="undefined"?",":g; m=typeof m==="undefined"?".":m; h=!isFinite(+h)?0:Math.abs(h); var j="\\u"+("0000"+m.charCodeAt(0).toString(16)).slice(-4); k=(k+"").replace(RegExp(j,"g"),".").replace(RegExp("[^0-9+-Ee.]","g"),""); k=!isFinite(+k)?0:+k; j=""; j=function(p,l){var i=Math.pow(10,l); return""+Math.round(p*i)/i; }; j=(h?j(k,h):""+Math.round(k)).split("."); if(j[0].length>3){j[0]=j[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,g); }if((j[1]||"").length