String.prototype.repeat=function(a){return Array(a+1).join(this)};RegExp.escape=function(a){arguments.callee.escapeExpression||(arguments.callee.escapeExpression=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\)","g"));return a.replace(arguments.callee.escapeExpression,"\\$1")};
Number.parseFloat=function(a,b,c,d){if(!a)return 0;Log(b);a=a.toString();a=a.match("^\\s*(-?(?:\\d+|\\d{1,"+d+"}(?:"+c+"\\d{"+d+"})+))(?:"+b+"(\\d+))?\\s*$");if(!a||void 0==a[1])return Number.NaN;a[1]=a[1].replace(RegExp(c,"g"),"");return parseFloat(void 0==a[2]?a[1]:a[1]+"."+a[2])};Number.parseFloatWithFormat=function(a,b){switch(b){default:case FloatFormats.Currency:return Number.parseCurrency(a);case FloatFormats.Percentage:return Number.parsePercentage(a)}};
Number.parseCurrency=function(a){var b=Culture.currentCulture(),c=RegExp.escape(b.currencyDecimalSeparator),d=RegExp.escape(b.currencyGroupSeparator);return Number.parseFloat(a,c,d,b.currencyGroupSize)};Number.parsePercentage=function(a){var b=Culture.currentCulture(),c=RegExp.escape(b.numberDecimalSeparator),d=RegExp.escape(b.numberGroupSeparator);return Number.parseFloat(a,c,d,b.numberGroupSize)};
Number.prototype.formatCurrency=function(){return String.format("{0:#,0."+"0".repeat(Culture.currentCulture().currencyDecimalDigits)+"}",this)};Number.prototype.formatPercentage=function(){return String.format("{0:#,0."+"0".repeat(Culture.currentCulture().numberDecimalDigits)+"}",this)};Number.prototype.formatNumber=function(){return String.format("{0:#,0}",this)};
Number.prototype.format=function(a){switch(a){default:case FloatFormats.Currency:return this.formatCurrency();case FloatFormats.Percentage:return this.formatPercentage();case FloatFormats.Number:return this.formatNumber()}};document.getScreenDensity=function(){return 0.75>=window.devicePixelRatio?"ldpi":1>=window.devicePixelRatio?"mdpi":1.5>=window.devicePixelRatio?"hdpi":2>=window.devicePixelRatio?"xhdpi":"mdpi"};
document.addStyle=function(a){var b=document.getElementsByTagName("head")[0],c=document.createElement("link");c.type="text/css";c.rel="stylesheet";c.href=a;b.appendChild(c)};Math.roundTo=function(a,b){var c=Math.pow(10,b+1),a=Math.round(Math.round(a*c)/10);return a/(c/10)};
