function NumberFormat(B,A){this.COMMA=",";this.PERIOD=".";this.DASH="-";this.LEFT_PAREN="(";this.RIGHT_PAREN=")";this.LEFT_OUTSIDE=0;this.LEFT_INSIDE=1;this.RIGHT_INSIDE=2;this.RIGHT_OUTSIDE=3;this.LEFT_DASH=0;this.RIGHT_DASH=1;this.PARENTHESIS=2;this.NO_ROUNDING=-1;this.num;this.numOriginal;this.hasSeparators=false;this.separatorValue;this.inputDecimalValue;this.decimalValue;this.negativeFormat;this.negativeRed;this.hasCurrency;this.currencyPosition;this.currencyValue;this.places;this.roundToPlaces;this.setNumber=setNumberNF;this.toUnformatted=toUnformattedNF;this.setInputDecimal=setInputDecimalNF;this.setSeparators=setSeparatorsNF;this.setCommas=setCommasNF;this.setNegativeFormat=setNegativeFormatNF;this.setNegativeRed=setNegativeRedNF;this.setCurrency=setCurrencyNF;this.setCurrencyPrefix=setCurrencyPrefixNF;this.setCurrencyValue=setCurrencyValueNF;this.setCurrencyPosition=setCurrencyPositionNF;this.setPlaces=setPlacesNF;this.toFormatted=toFormattedNF;this.toPercentage=toPercentageNF;this.getOriginal=getOriginalNF;this.moveDecimalRight=moveDecimalRightNF;this.moveDecimalLeft=moveDecimalLeftNF;this.getRounded=getRoundedNF;this.preserveZeros=preserveZerosNF;this.justNumber=justNumberNF;this.expandExponential=expandExponentialNF;this.getZeros=getZerosNF;this.moveDecimalAsString=moveDecimalAsStringNF;this.moveDecimal=moveDecimalNF;if(A==null){this.setNumber(B,this.PERIOD)}else{this.setNumber(B,A)}this.setCommas(true);this.setNegativeFormat(this.LEFT_DASH);this.setNegativeRed(false);this.setCurrency(false);this.setCurrencyPrefix("$");this.setPlaces(2)}function setInputDecimalNF(A){this.inputDecimalValue=A}function setNumberNF(B,A){if(A!=null){this.setInputDecimal(A)}this.numOriginal=B;this.num=this.justNumber(B)}function toUnformattedNF(){return(this.num)}function getOriginalNF(){return(this.numOriginal)}function setNegativeFormatNF(A){this.negativeFormat=A}function setNegativeRedNF(A){this.negativeRed=A}function setSeparatorsNF(A,B,C){this.hasSeparators=A;if(B==null){B=this.COMMA}if(C==null){C=this.PERIOD}if(B==C){this.decimalValue=(C==this.PERIOD)?this.COMMA:this.PERIOD}else{this.decimalValue=C}this.separatorValue=B}function setCommasNF(A){this.setSeparators(A,this.COMMA,this.PERIOD)}function setCurrencyNF(A){this.hasCurrency=A}function setCurrencyValueNF(A){this.currencyValue=A}function setCurrencyPrefixNF(A){this.setCurrencyValue(A);this.setCurrencyPosition(this.LEFT_OUTSIDE)}function setCurrencyPositionNF(A){this.currencyPosition=A}function setPlacesNF(A){this.roundToPlaces=!(A==this.NO_ROUNDING);this.places=(A<0)?0:A}function toFormattedNF(){var F;var G=this.num;var I;var J=new Array(2);if(this.roundToPlaces){G=this.getRounded(G);I=this.preserveZeros(Math.abs(G))}else{I=this.expandExponential(Math.abs(G))}if(I.indexOf(this.PERIOD)==-1){J[0]=I;J[1]=""}else{J=I.split(this.PERIOD,2)}if(this.hasSeparators){F=J[0].length;while(F>0){F-=3;if(F<=0){break}J[0]=J[0].substring(0,F)+this.separatorValue+J[0].substring(F,J[0].length)}}if(J[1].length>0){I=J[0]+this.decimalValue+J[1]}else{I=J[0]}var N="";var E="";var M="";var D="";var B="";var L="";var A="";var K="";var H=(this.negativeFormat==this.PARENTHESIS)?this.LEFT_PAREN:this.DASH;var C=(this.negativeFormat==this.PARENTHESIS)?this.RIGHT_PAREN:this.DASH;if(this.currencyPosition==this.LEFT_OUTSIDE){if(G<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){D=H}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){B=C}}if(this.hasCurrency){N=this.currencyValue}}else{if(this.currencyPosition==this.LEFT_INSIDE){if(G<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){E=H}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){A=C}}if(this.hasCurrency){M=this.currencyValue}}else{if(this.currencyPosition==this.RIGHT_INSIDE){if(G<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){E=H}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){A=C}}if(this.hasCurrency){L=this.currencyValue}}else{if(this.currencyPosition==this.RIGHT_OUTSIDE){if(G<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){D=H}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){B=C}}if(this.hasCurrency){K=this.currencyValue}}}}}I=N+E+M+D+I+B+L+A+K;if(this.negativeRed&&G<0){I='<font color="red">'+I+"</font>"}return(I)}function toPercentageNF(){nNum=this.num*100;nNum=this.getRounded(nNum);return nNum+"%"}function getZerosNF(C){var B="";var A;for(A=0;A<C;A++){B+="0"}return B}function expandExponentialNF(F){if(isNaN(F)){return F}var A=parseFloat(F)+"";var D=A.toLowerCase().indexOf("e");if(D!=-1){var E=A.toLowerCase().indexOf("+");var B=A.toLowerCase().indexOf("-",D);var C=A.substring(0,D);if(B!=-1){var G=A.substring(B+1,A.length);C=this.moveDecimalAsString(C,true,parseInt(G))}else{if(E==-1){E=D}var G=A.substring(E+1,A.length);C=this.moveDecimalAsString(C,false,parseInt(G))}A=C}return A}function moveDecimalRightNF(B,A){var C="";if(A==null){C=this.moveDecimal(B,false)}else{C=this.moveDecimal(B,false,A)}return C}function moveDecimalLeftNF(B,A){var C="";if(A==null){C=this.moveDecimal(B,true)}else{C=this.moveDecimal(B,true,A)}return C}function moveDecimalAsStringNF(C,B,G){var D=(arguments.length<3)?this.places:G;if(D<=0){return C}var F=C+"";var A=this.getZeros(D);var H=new RegExp("([0-9.]+)");if(B){F=F.replace(H,A+"$1");var E=new RegExp("(-?)([0-9]*)([0-9]{"+D+"})(\\.?)");F=F.replace(E,"$1$2.$3")}else{if(H.test(F)){F=RegExp.leftContext+RegExp.$1+A+RegExp.rightContext}var E=new RegExp("(-?)([0-9]*)(\\.?)([0-9]{"+D+"})");F=F.replace(E,"$1$2$4.")}F=F.replace(/\.$/,"");return F}function moveDecimalNF(C,B,A){var D="";if(A==null){D=this.moveDecimalAsString(C,B)}else{D=this.moveDecimalAsString(C,B,A)}return parseFloat(D)}function getRoundedNF(A){A=this.moveDecimalRight(A);A=Math.round(A);A=this.moveDecimalLeft(A);return A}function preserveZerosNF(B){var A;B=this.expandExponential(B);if(this.places<=0){return B}var E=B.indexOf(".");if(E==-1){B+=".";for(A=0;A<this.places;A++){B+="0"}}else{var D=(B.length-1)-E;var C=this.places-D;for(A=0;A<C;A++){B+="0"}}return B}function justNumberNF(B){newVal=B+"";var A=false;if(newVal.indexOf("%")!=-1){newVal=newVal.replace(/\%/g,"");A=true}var D=new RegExp("[^\\"+this.inputDecimalValue+"\\d\\-\\+\\(\\)e]","g");newVal=newVal.replace(D,"");var C=new RegExp("["+this.inputDecimalValue+"]","g");if(C.test(newVal)){newVal=RegExp.leftContext+this.PERIOD+RegExp.rightContext.replace(C,"")}if(newVal.charAt(newVal.length-1)==this.DASH){newVal=newVal.substring(0,newVal.length-1);newVal="-"+newVal}else{if(newVal.charAt(0)==this.LEFT_PAREN&&newVal.charAt(newVal.length-1)==this.RIGHT_PAREN){newVal=newVal.substring(1,newVal.length-1);newVal="-"+newVal}}newVal=parseFloat(newVal);if(!isFinite(newVal)){newVal=0}if(A){newVal=this.moveDecimalLeft(newVal,2)}return newVal}