function NumberFormat(A,B){this.VERSION="Number Format v1.5.4";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.truncate;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;this.addSeparators=addSeparatorsNF;if(B==null){this.setNumber(A,this.PERIOD);}else{this.setNumber(A,B);}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(A,B){if(B!=null){this.setInputDecimal(B);}this.numOriginal=A;this.num=this.justNumber(A);}function toUnformattedNF(){return(this.num);}function getOriginalNF(){return(this.numOriginal);}function setNegativeFormatNF(A){this.negativeFormat=A;}function setNegativeRedNF(A){this.negativeRed=A;}function setSeparatorsNF(B,C,A){this.hasSeparators=B;if(C==null){C=this.COMMA;}if(A==null){A=this.PERIOD;}if(C==A){this.decimalValue=(A==this.PERIOD)?this.COMMA:this.PERIOD;}else{this.decimalValue=A;}this.separatorValue=C;}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(B,A){this.roundToPlaces=!(B==this.NO_ROUNDING);this.truncate=(A!=null&&A);this.places=(B<0)?0:B;}function addSeparatorsNF(D,E,A,C){D+="";var F=D.indexOf(E);var G="";if(F!=-1){G=A+D.substring(F+1,D.length);D=D.substring(0,F);}var B=/(\d+)(\d{3})/;while(B.test(D)){D=D.replace(B,"$1"+C+"$2");}return D+G;}function toFormattedNF(){var L;var M=this.num;var A;var B=new Array(2);if(this.roundToPlaces){M=this.getRounded(M);A=this.preserveZeros(Math.abs(M));}else{A=this.expandExponential(Math.abs(M));}if(this.hasSeparators){A=this.addSeparators(A,this.PERIOD,this.decimalValue,this.separatorValue);}else{A=A.replace(new RegExp("\\"+this.PERIOD),this.decimalValue);}var F="";var K="";var E="";var J="";var H="";var D="";var G="";var C="";var N=(this.negativeFormat==this.PARENTHESIS)?this.LEFT_PAREN:this.DASH;var I=(this.negativeFormat==this.PARENTHESIS)?this.RIGHT_PAREN:this.DASH;if(this.currencyPosition==this.LEFT_OUTSIDE){if(M<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){J=N;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){H=I;}}if(this.hasCurrency){F=this.currencyValue;}}else{if(this.currencyPosition==this.LEFT_INSIDE){if(M<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){K=N;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){G=I;}}if(this.hasCurrency){E=this.currencyValue;}}else{if(this.currencyPosition==this.RIGHT_INSIDE){if(M<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){K=N;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){G=I;}}if(this.hasCurrency){D=this.currencyValue;}}else{if(this.currencyPosition==this.RIGHT_OUTSIDE){if(M<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){J=N;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){H=I;}}if(this.hasCurrency){C=this.currencyValue;}}}}}A=F+K+E+J+A+H+D+G+C;if(this.negativeRed&&M<0){A='<font color="red">'+A+"</font>";}return(A);}function toPercentageNF(){nNum=this.num*100;nNum=this.getRounded(nNum);return nNum+"%";}function getZerosNF(A){var C="";var B;for(B=0;B<A;B++){C+="0";}return C;}function expandExponentialNF(B){if(isNaN(B)){return B;}var D=parseFloat(B)+"";var G=D.toLowerCase().indexOf("e");if(G!=-1){var A=D.toLowerCase().indexOf("+");var E=D.toLowerCase().indexOf("-",G);var F=D.substring(0,G);if(E!=-1){var C=D.substring(E+1,D.length);F=this.moveDecimalAsString(F,true,parseInt(C));}else{if(A==-1){A=G;}var C=D.substring(A+1,D.length);F=this.moveDecimalAsString(F,false,parseInt(C));}D=F;}return D;}function moveDecimalRightNF(C,B){var A="";if(B==null){A=this.moveDecimal(C,false);}else{A=this.moveDecimal(C,false,B);}return A;}function moveDecimalLeftNF(C,B){var A="";if(B==null){A=this.moveDecimal(C,true);}else{A=this.moveDecimal(C,true,B);}return A;}function moveDecimalAsStringNF(D,E,A){var I=(arguments.length<3)?this.places:A;if(I<=0){return D;}var B=D+"";var F=this.getZeros(I);var H=new RegExp("([0-9.]+)");if(E){B=B.replace(H,F+"$1");var G=new RegExp("(-?)([0-9]*)([0-9]{"+I+"})(\\.?)");B=B.replace(G,"$1$2.$3");}else{var C=H.exec(B);if(C!=null){B=B.substring(0,C.index)+C[1]+F+B.substring(C.index+C[0].length);}var G=new RegExp("(-?)([0-9]*)(\\.?)([0-9]{"+I+"})");B=B.replace(G,"$1$2$4.");}B=B.replace(/\.$/,"");return B;}function moveDecimalNF(D,C,B){var A="";if(B==null){A=this.moveDecimalAsString(D,C);}else{A=this.moveDecimalAsString(D,C,B);}return parseFloat(A);}function getRoundedNF(A){A=this.moveDecimalRight(A);if(this.truncate){A=A>=0?Math.floor(A):Math.ceil(A);}else{A=Math.round(A);}A=this.moveDecimalLeft(A);return A;}function preserveZerosNF(C){var B;C=this.expandExponential(C);if(this.places<=0){return C;}var A=C.indexOf(".");if(A==-1){C+=".";for(B=0;B<this.places;B++){C+="0";}}else{var E=(C.length-1)-A;var D=this.places-E;for(B=0;B<D;B++){C+="0";}}return C;}function justNumberNF(E){newVal=E+"";var D=false;if(newVal.indexOf("%")!=-1){newVal=newVal.replace(/\%/g,"");D=true;}var B=new RegExp("[^\\"+this.inputDecimalValue+"\\d\\-\\+\\(\\)eE]","g");newVal=newVal.replace(B,"");var F=new RegExp("["+this.inputDecimalValue+"]","g");var C=F.exec(newVal);if(C!=null){var A=newVal.substring(C.index+C[0].length);newVal=newVal.substring(0,C.index)+this.PERIOD+A.replace(F,"");}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(D){newVal=this.moveDecimalLeft(newVal,2);}return newVal;}