// JaSCL - JAvaScript Common Library
// Copyright (C) 2006 IP Labs GmbH <http://www.iplabs.de/>
// $Id: Formatter.js 84386 2009-10-01 11:47:48Z k.reimer $
function Formatter(){}Formatter.currencyFractionDigits=2;Formatter.groupingSize=3;Formatter.decimalSeparator=".";Formatter.groupingSeparator=",";Formatter.msgSeconds="seconds";Formatter.msgMinutes="minutes";Formatter.msgBytes="B";Formatter.msgKBytes="KB";Formatter.msgMBytes="MB";Formatter.msgCurrency="{0} €";Formatter.taxRate=19.00;Formatter.TO_TARE="tare";Formatter.TO_GROSS="gross";Formatter.TO_NET="net";Formatter.formatNumber=function(g,h){var _;var a;var b;var c;var d;var e;d=Formatter.decimalSeparator;e=Formatter.groupingSeparator;a=Math.round(g*Math.pow(10,h));a=a.toString();for(b=h,c=a.length;b>c;b--){a="0"+a;}_="";for(b=0,c=a.length;b<c;b++){if((a.charAt(c-b-1)!="-")&&((b-h)>0)&&(((b-h)%Formatter.groupingSize)===0)){_=e+_;}_=a.charAt(c-b-1)+_;if(b==h-1){_=d+_;}}if(_.charAt(0)==d){_="0"+_;}return _;};Formatter.formatSeconds=function(i){if(i<120){return Math.round(i)+" "+Formatter.msgSeconds;}else{return String(Math.round(i/60))+" "+Formatter.msgMinutes;}};Formatter.formatBytes=function(j){if(j<1000){return Formatter.formatNumber(j,0)+" "+Formatter.msgBytes;}if(j<1000*1000){return Formatter.formatNumber(j/1024,1)+" "+Formatter.msgKBytes;}return Formatter.formatNumber(j/1024/1024,1)+" "+Formatter.msgMBytes;};Formatter.formatCurrency=function(k,l,m){var f;if(l!==undefined){f=(m!==undefined)?m:Formatter.taxRate;if(l==Formatter.TO_TARE){k=(k*f)/(100+f);}else if(l==Formatter.TO_NET){k=(k/(f+100))*100;}else if(l==Formatter.TO_GROSS){k=(k*(f+100))/100;}}return Formatter.msgCurrency.replace("{0}",Formatter.formatNumber(k,Formatter.currencyFractionDigits));};