Format Currency - Euro in Javascript

How to Format euro money with javascript.

123456789.123456789

return

123.456.789,12

javascript code:

Javascript Format Currency - Euro

function (number)
{
var numberStr = parseFloat(number).toFixed(2).toString();
var numFormatDec = numberStr.slice(-2); /*decimal 00*/
numberStr = numberStr.substring(0, numberStr.length-3); /*cut last 3 strings*/
var numFormat = new Array;
while (numberStr.length > 3) {
numFormat.unshift(numberStr.slice(-3));
numberStr = numberStr.substring(0, numberStr.length-3);
}
numFormat.unshift(numberStr);
return numFormat.join('.')+','+numFormatDec; /*format 000.000.000,00 */
}