function teclas(campo){
    if(((event.keyCode < 96) || (event.keyCode > 105)) &&
       ((event.keyCode < 48) || (event.keyCode > 57)) ){
           campo.value = campo.value.replace(String.fromCharCode(event.keyCode).toLowerCase(),"");
    }
}
function numMoeda(campo){
       // para evitar caracteres alfas.
       teclas(campo);
       str = campo.value;

       while(str.search(",") != -1)
           str = str.replace(",","");
       i = 0;

       while(i< str.length){
           if(str.substr(i,1) == ".")
              str = str.replace(".","");
              i++;
       }

       part1 = str.substr(0,str.length - 2);
       while(part1.search(" ") != -1)
           part1 = part1.replace(" ","");

           part2 = str.substr(str.length - 2,2);
           res = "";
           i = part1.length;
           sob = i % 3;
           if((sob != 0) && (i > 2))
              res = part1.substr(0,sob) + ".";
           else
              res = part1.substr(0,sob);
           j = 1;
           part1 = part1.substr(sob);
           i = 0;
           while(i < part1.length){
              if(j == 3){
                 if(i + 1 == part1.length)
                    res = res + part1.substr(i-2,3);
                 else res = res + part1.substr(i-2,3) + ".";
              }
              i++;
              j = j<3?j+1:1;
           }
           campo.value = res + "," + part2;
}