Incorporo un pequeño añadido para mostar la separacion de los millares.
Código:
function Decimales(Numero, Decimales) {
pot = Math.pow(10,Decimales);
num = parseInt(Numero * pot) / pot;
nume = num.toString().split('.');
entero = nume[0];
decima = nume[1];
if (decima != undefined) {
fin = Decimales-decima.length; }
else {
decima = '';
fin = Decimales; }
for(i=0;i<fin;i++)
decima+=String.fromCharCode(48);
buffer="";
marca=entero.length-1;
chars=1;
while(marca>=0){
if((chars%4)==0){
buffer="."+buffer;
}
buffer=entero.charAt(marca)+buffer;
marca--;
chars++;
}
num=buffer+','+decima;
return num;
}