var ccount={'Unicef':{c:9893,u:6166},'':{}}; function ccount_display(id) { document.write(ccount[id]['c'].formatThousands('US')); } function ccount_unique(id) { document.write(ccount[id]['u'].formatThousands('US')); } Number.prototype.formatThousands = function(notation) { var n = this, separator = ""; switch (notation) { case "US": separator = ","; break; case "UK": separator = "."; break; case "FR": separator = " "; break; default: return n; } n = parseInt(n) + ""; j = (j = n.length) > 3 ? j % 3 : 0; return (j ? n.substr(0, j) + separator : "") + n.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + separator); }