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