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;this.addSeparators=addSeparatorsNF;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(0)}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(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(a){this.roundToPlaces=!(a==this.NO_ROUNDING);this.places=(a<0)?0:a}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)}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(b){var c="";var a;for(a=0;a<b;a++){c+="0"}return c}function expandExponentialNF(e){if(isNaN(e)){return e}var c=parseFloat(e)+"";var g=c.toLowerCase().indexOf("e");if(g!=-1){var d=c.toLowerCase().indexOf("+");var a=c.toLowerCase().indexOf("-",g);var f=c.substring(0,g);if(a!=-1){var b=c.substring(a+1,c.length);f=this.moveDecimalAsString(f,true,parseInt(b))}else{if(d==-1){d=g}var b=c.substring(d+1,c.length);f=this.moveDecimalAsString(f,false,parseInt(b))}c=f}return c}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(c,d,i){var a=(arguments.length<3)?this.places:i;if(a<=0){return c}var h=c+"";var e=this.getZeros(a);var g=new RegExp("([0-9.]+)");if(d){h=h.replace(g,e+"$1");var f=new RegExp("(-?)([0-9]*)([0-9]{"+a+"})(\\.?)");h=h.replace(f,"$1$2.$3")}else{var b=g.exec(h);if(b!=null){h=h.substring(0,b.index)+b[1]+e+h.substring(b.index+b[0].length)}var f=new RegExp("(-?)([0-9]*)(\\.?)([0-9]{"+a+"})");h=h.replace(f,"$1$2$4.")}h=h.replace(/\.$/,"");return h}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);a=Math.round(a);a=this.moveDecimalLeft(a);return a}function preserveZerosNF(d){var a;d=this.expandExponential(d);if(this.places<=0){return d}var b=d.indexOf(".");if(b==-1){d+=".";for(a=0;a<this.places;a++){d+="0"}}else{var c=(d.length-1)-b;var e=this.places-c;for(a=0;a<e;a++){d+="0"}}return d}function justNumberNF(f){newVal=f+"";var e=false;if(newVal.indexOf("%")!=-1){newVal=newVal.replace(/\%/g,"");e=true}var b=new RegExp("[^\\"+this.inputDecimalValue+"\\d\\-\\+\\(\\)eE]","g");newVal=newVal.replace(b,"");var d=new RegExp("["+this.inputDecimalValue+"]","g");var c=d.exec(newVal);if(c!=null){var a=newVal.substring(c.index+c[0].length);newVal=newVal.substring(0,c.index)+this.PERIOD+a.replace(d,"")}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};