function LocalMoney() { this.currencyCode = "$localeInfo.getDefaultCurrencyCode()"; this.amount = ""; } LocalMoney.prototype.parse = function(moneyField,allowEmpty) { // Determine if there is a currency code prepended to the amount if (moneyField.length == 0) { if (allowEmpty) { this.amount = ""; } else { this.amount = "0.0"; } } else if (this.isDigit(moneyField.charAt(0)) || (moneyField.indexOf("-") == 0)) { this.amount = moneyField; } else if (moneyField.indexOf("_") == 0) { this.amount = moneyField.substring(1); } else { this.currencyCode = moneyField.substring(0, 3).toUpperCase(); this.amount = moneyField.substring(4); } if (this.amount.length == 0) { if (allowEmpty) { this.amount = ""; } else { this.amount = "0.0"; } } } LocalMoney.prototype.getCurrencyCode = function() { return this.currencyCode; } LocalMoney.prototype.getAmount = function() { return this.amount; } LocalMoney.prototype.isDigit = function(c) { return ((c >= "0") && (c <= "9")); }