Ext.namespace('CW.util');
CW.util.Format = function() {
    return {
        nlMoney : function(v,noEsign) {
            v = (Math.round((v-0)*100))/100;
            v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
            v = String(v);
            var ps = v.split('.');
            var whole = ps[0];
            var sub = ps[1] ? ','+ ps[1] : ',00';
            var r = /(\d+)(\d{3})/;
            while (r.test(whole)) {
                whole = whole.replace(r, '$1' + '.' + '$2');
            }
            v = whole + sub;
            if(v.charAt(0) == '-'){
                return '-€' + v.substr(1);
            }
            if(noEsign == 1) {
            	return v;
            } else {
            
            	return '€ '+v;
            
            }
            
        }
    }
}();

CW.util.Btw = function() {
    return {
        excl : function(v, btw) {
            btw = parseFloat(btw) || 19;
            v = parseFloat(v) || 0;
            
            return ( Math.round( (v / (1 + btw / 100)) * 1000 )) / 1000;
        },
        incl : function(v, btw) {
            btw = parseFloat(btw) || 19;
            v = parseFloat(v) || 0;

            return Math.round( (v * (1 + btw / 100) ) * 1000 ) / 1000;
        },
        btw : function(v, btw) {
            btw = parseFloat(btw) || 19;
            v = parseFloat(v) || 0;
            
            return Math.round( (v * (btw / 100) ) * 1000 ) / 1000;
        }
    }
}();



