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
};
