window.PA_Money = {
format: function (s, n, isFixed) {
isFixed = isFixed || false;
typeof n != 'undefined' && (n = "" + n || 2);
n = n >= 0 && n <= 20 ? +n : 2;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).fixed(n, isFixed) + "";
return !isNaN(s) ? (function () {
var l = s.split(".")[0].split("").reverse(),
r = s.split(".")[1];
var d = "";
for (var j = 0; j < n; j++) {
d += "0";
}
r = r || d;
r.length == 1 && (r += "0");
var t = "";
for (var i = 0; i < l.length; i++) {
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
}
var m = t.split("").reverse().join("");
return n != '0' ? m + "." + r : m;
})() : '';
},
parse: function (s, hd) {
hd = hd || false;
if (hd) {
var st = s.indexOf(".");
s = st != -1 ? s.substring(0, st) : s;
}
return s.replace(/[^\d\.-]/g, "");
},
toUpper: function (n) {
var fraction = ['\u89d2', '\u5206'];
var digit = ['\u96f6', '\u58f9', '\u8d30', '\u53c1', '\u8086', '\u4f0d', '\u9646', '\u67d2', '\u634c', '\u7396'];
var unit = [
['\u5143', '\u4e07', '\u4ebf'],
['', '\u62fe', '\u4f70', '\u4edf']
];
var head = n < 0 ? '\u6b20' : '';
(n != '' && n != null) && (n = Math.abs(n)) || (n = parseFloat(n));
return !isNaN(n) ? (function () {
var s = '';
for (var i = 0; i < fraction.length; i++) {
s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/\u96f6./, '');
}
s = s || '\u6574';
n = Math.floor(n);
for (var i = 0; i < unit[0].length && n > 0; i++) {
var p = '';
for (var j = 0; j < unit[1].length && n > 0; j++) {
p = digit[n % 10] + unit[1][j] + p;
n = Math.floor(n / 10);
}
s = p.replace(/(\u96f6.)*\u96f6$/, '').replace(/^$/, '\u96f6') + unit[0][i] + s;
}
return head + s.replace(/(\u96f6.)*\u96f6\u5143/, '\u5143').replace(/(\u96f6.)+/g, '\u96f6').replace(/^\u6574$/, '\u96f6\u5143\u6574');
})() : '';
}
};
window.PA_Money.format('300')