// JavaScript Document
Number.prototype.format = function() {

	var nbDecimales = 2, carPoint = '.', carSepMilliers = ',';

	var nbArgs = arguments.length;



	if (isNaN(this) || !(new RegExp('0|1|3', 'g').test(nbArgs))) return false;



	switch (nbArgs) {

		case 3: carPoint = arguments[1]; carSepMilliers = arguments[2];

		case 1: nbDecimales = parseInt(arguments[0]);

	}

	var intNb = parseInt(this), str = intNb.toString(), n = str.length;

	var puiss = Math.pow(10, nbDecimales);



	return ((n % 3) ? str.substr(0, n % 3) + carSepMilliers : '')

	+ str.substr(n % 3).match(new RegExp('[0-9]{3}', 'g')).join(carSepMilliers)

	+ ((intNb != this) ? carPoint + parseInt(puiss * this.toFixed(nbDecimales) - puiss * intNb) : '');

}

Number.prototype.toFormatFrancais = function() {

	return this.format(arguments[0] ? arguments[0] : 0, ',', ' ');

}