Number.formatFunctions={count:0};Number.prototype.NaN="NaN";Number.prototype.posInfinity="Infinity";Number.prototype.negInfinity="-Infinity";Number.prototype.numberFormat=function(B,A){if(isNaN(this)){return Number.prototype.NaNstring}else{if(this==+Infinity){return Number.prototype.posInfinity}else{if(this==-Infinity){return Number.prototype.negInfinity}else{if(Number.formatFunctions[B]==null){Number.createNewFormat(B)}}}}return this[Number.formatFunctions[B]](A)};Number.createNewFormat=function(format){var funcName="format"+Number.formatFunctions.count++;Number.formatFunctions[format]=funcName;var code="Number.prototype."+funcName+" = function(context){\n";var formats=format.split(";");switch(formats.length){case 1:code+=Number.createTerminalFormat(format);break;case 2:code+='return (this < 0) ? this.numberFormat("'+String.escape(formats[1])+'", 1) : this.numberFormat("'+String.escape(formats[0])+'", 2);';break;case 3:code+='return (this < 0) ? this.numberFormat("'+String.escape(formats[1])+'", 1) : ((this == 0) ? this.numberFormat("'+String.escape(formats[2])+'", 2) : this.numberFormat("'+String.escape(formats[0])+'", 3));';break;default:code+="throw 'Too many semicolons in format string';";break}eval(code+"}")};Number.createTerminalFormat=function(I){if(I.length>0&&I.search(/[0#?]/)==-1){return"return '"+String.escape(I)+"';\n"}var A="var val = (context == null) ? new Number(this) : Math.abs(this);\n";var F=false;var E=I;var G="";var J=0;var K=0;var B=0;var H=false;var C="";D=I.match(/\..*(e)([+-]?)(0+)/i);if(D){C=D[1];H=(D[2]=="+");B=D[3].length;I=I.replace(/(e)([+-]?)(0+)/i,"")}var D=I.match(/^([^.]*)\.(.*)$/);if(D){E=D[1].replace(/\./g,"");G=D[2].replace(/\./g,"")}if(I.indexOf("%")>=0){A+="val *= 100;\n"}D=E.match(/(,+)(?:$|[^0#?,])/);if(D){A+="val /= "+Math.pow(1000,D[1].length)+"\n;"}if(E.search(/[0#?],[0#?]/)>=0){F=true}if((D)||F){E=E.replace(/,/g,"")}D=E.match(/0[0#?]*/);if(D){J=D[0].length}D=G.match(/[0#?]*/);if(D){K=D[0].length}if(B>0){A+="var sci = Number.toScientific(val,"+J+", "+K+", "+B+", "+H+");\nvar arr = [sci.l, sci.r];\n"}else{if(I.indexOf(".")<0){A+="val = (val > 0) ? Math.ceil(val) : Math.floor(val);\n"}A+="var arr = val.round("+K+").toFixed("+K+").split('.');\n";A+="arr[0] = (val < 0 ? '-' : '') + String.leftPad((val < 0 ? arr[0].substring(1) : arr[0]), "+J+", '0');\n"}if(F){A+="arr[0] = Number.addSeparators(arr[0]);\n"}A+="arr[0] = Number.injectIntoFormat(arr[0].reverse(), '"+String.escape(E.reverse())+"', true).reverse();\n";if(K>0){A+="arr[1] = Number.injectIntoFormat(arr[1], '"+String.escape(G)+"', false);\n"}if(B>0){A+="arr[1] = arr[1].replace(/(\\d{"+K+"})/, '$1"+C+"' + sci.s);\n"}return A+"return arr.join('.');\n"};Number.toScientific=function(C,G,H,B,D){var I={l:"",r:"",s:""};var E="";var F=Math.abs(C).toFixed(G+H+1).trim("0");var A=Math.round(new Number(F.replace(".","").replace(new RegExp("(\\d{"+(G+H)+"})(.*)"),"$1.$2"))).toFixed(0);if(A.length>=G){A=A.substring(0,G)+"."+A.substring(G)}else{A+="."}I.s=(F.indexOf(".")-F.search(/[1-9]/))-A.indexOf(".");if(I.s<0){I.s++}I.l=(C<0?"-":"")+String.leftPad(A.substring(0,A.indexOf(".")),G,"0");I.r=A.substring(A.indexOf(".")+1);if(I.s<0){E="-"}else{if(D){E="+"}}I.s=E+String.leftPad(Math.abs(I.s).toFixed(0),B,"0");return I};Number.prototype.round=function(B){if(B>0){var A=this.toFixed(B+1).match(new RegExp("(-?\\d*).(\\d{"+B+"})(\\d)\\d*$"));if(A&&A.length){return new Number(A[1]+"."+String.leftPad(Math.round(A[2]+"."+A[3]),B,"0"))}}return this};Number.injectIntoFormat=function(G,F,B){var D=0;var C=0;var A="";var E=G.charAt(G.length-1)=="-";if(E){G=G.substring(0,G.length-1)}while(D<F.length&&C<G.length&&F.substring(D).search(/[0#?]/)>=0){if(F.charAt(D).match(/[0#?]/)){if(G.charAt(C)!="-"){A+=G.charAt(C)}else{A+="0"}C++}else{A+=F.charAt(D)}++D}if(E&&C==G.length){A+="-"}if(C<G.length){if(B){A+=G.substring(C)}if(E){A+="-"}}if(D<F.length){A+=F.substring(D)}return A.replace(/#/g,"").replace(/\?/g," ")};Number.addSeparators=function(A){return A.reverse().replace(/(\d{3})/g,"$1,").reverse().replace(/^(-)?,/,"$1")};String.prototype.reverse=function(){var B="";for(var A=this.length;A>0;--A){B+=this.charAt(A-1)}return B};String.prototype.trim=function(A){if(!A){A=" "}return this.replace(new RegExp("^"+A+"+|"+A+"+$","g"),"")};String.leftPad=function(D,B,C){var A=new String(D);if(C==null){C=" "}while(A.length<B){A=C+A}return A};String.escape=function(A){return A.replace(/('|\\)/g,"\\$1")};