Javascript version of php number_format function