function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+'.'+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '' +  num + ',' + cents);
}

function verTecla() {
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;

}

 function checkValor(form) 
{
var subdescricao1 = 0; 
var subdescricao2 = 0;
var subdescricao3 = 0;
var subdescricao4 = 0;
var subdescricao5 = 0;
var subdescricao6 = 0;
var subdescricao7 = 0;
var subdescricao8 = 0;
var teste = 0;
if (document.calculo.bc.value > 0)
	subdescricao1 = eval(document.calculo.bc.value);
if (document.calculo.refis.value > 0)
	subdescricao3 = ( eval(document.calculo.refis.value)/100);
if (document.calculo.venda.value > 0)
	subdescricao6 = ( eval(document.calculo.venda.value));
if (document.calculo.serv.value > 0)
	subdescricao7 = ( eval(document.calculo.serv.value));
if (document.calculo.servprof.value > 0)
	subdescricao8 = ( eval(document.calculo.servprof.value));
if ((subdescricao1 == 0) && (subdescricao2 == 0) && (subdescricao3 == 0) && (subdescricao4 == 0) && (subdescricao5 == 0) && (subdescricao6 == 0) && (subdescricao7 == 0) && (subdescricao8 == 0))
	total = 0;
else {
total2 = ((subdescricao6 + subdescricao7 + subdescricao8) * subdescricao3);
totalbc = (subdescricao6 + subdescricao7 + subdescricao8);
}
 document.calculo.valrefis.value =formatCurrency(total2);
 document.calculo.bc.value =formatCurrency(totalbc);
}
