/* Copyright © 2008 Deep Web Technologies, Inc.  All rights reserved. */

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 K=this.num;var A;if(this.roundToPlaces){K=this.getRounded(K);A=this.preserveZeros(Math.abs(K));}else{A=this.expandExponential(Math.abs(K));}if(this.hasSeparators){A=this.addSeparators(A,this.PERIOD,this.decimalValue,this.separatorValue);}else{A=A.replace(new RegExp("\\"+this.PERIOD),this.decimalValue);}var E="";var J="";var D="";var I="";var G="";var C="";var F="";var B="";var L=(this.negativeFormat==this.PARENTHESIS)?this.LEFT_PAREN:this.DASH;var H=(this.negativeFormat==this.PARENTHESIS)?this.RIGHT_PAREN:this.DASH;if(this.currencyPosition==this.LEFT_OUTSIDE){if(K<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){I=L;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){G=H;}}if(this.hasCurrency){E=this.currencyValue;}}else{if(this.currencyPosition==this.LEFT_INSIDE){if(K<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){J=L;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){F=H;}}if(this.hasCurrency){D=this.currencyValue;}}else{if(this.currencyPosition==this.RIGHT_INSIDE){if(K<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){J=L;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){F=H;}}if(this.hasCurrency){C=this.currencyValue;}}else{if(this.currencyPosition==this.RIGHT_OUTSIDE){if(K<0){if(this.negativeFormat==this.LEFT_DASH||this.negativeFormat==this.PARENTHESIS){I=L;}if(this.negativeFormat==this.RIGHT_DASH||this.negativeFormat==this.PARENTHESIS){G=H;}}if(this.hasCurrency){B=this.currencyValue;}}}}}A=E+J+D+I+A+G+C+F+B;if(this.negativeRed&&K<0){A='<font color="red">'+A+"</font>";}return(A);}function toPercentageNF(){var A=this.num*100;A=this.getRounded(A);return A+"%";}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");var C;if(G!=-1){var A=D.toLowerCase().indexOf("+");var E=D.toLowerCase().indexOf("-",G);var F=D.substring(0,G);if(E!=-1){C=D.substring(E+1,D.length);F=this.moveDecimalAsString(F,true,parseInt(C,10));}else{if(A==-1){A=G;}C=D.substring(A+1,D.length);F=this.moveDecimalAsString(F,false,parseInt(C,10));}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.]+)");var G;if(E){B=B.replace(H,F+"$1");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);}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;}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=0;this.numOriginal=0;this.hasSeparators=false;this.separatorValue=0;this.inputDecimalValue=0;this.decimalValue=0;this.negativeFormat="";this.negativeRed="";this.hasCurrency=false;this.currencyPosition=0;this.currencyValue=0;this.places=0;this.roundToPlaces=0;this.truncate=0;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);}