function ValidaPreco (valor)
{
	var tam, virgula;

	virgula = 0;
	tam = valor.length;

	for(i=0; i<tam; i++)
		if(valor.charAt(i) == "," && i > 0 && i != (tam-1))
			virgula++;
		else
			if(valor.charAt(i) < '0' || valor.charAt(i) > '9')
				return false;
	if(virgula > 1)
		return false;
	else
		return true;
}

function FormataPreco(campo, teclaPres, precisao)
{
	var tecla = navigator.appName == 'Microsoft Internet Explorer' ? teclaPres.keyCode : teclaPres.which;

	if(tecla == 46)
		if(navigator.appName == 'Microsoft Internet Explorer')
			tecla = teclaPres.keyCode = 44;
		else
			tecla = teclaPres.which = 44;

	if((tecla > 47 && tecla < 58) || tecla == 44)
	{
		var vr = new String(campo.value);
		var tam = vr.length;

		if(tecla == 44)
		{
			if(tam == 0 || precisao == 0)
				return false;
			if(vr.indexOf(',') != -1)
				return false;
		}
		else
		{
			if(precisao < 1)
				precisao = 100;
			if(tam >= precisao && vr.indexOf(',') == -1)
				campo.value = vr.substr(0,precisao) + ',' + vr.substr(precisao,tam-precisao);
		}
		return true;
	}
	return false;
}

function ValidaDigito (valor)
{
	for(i=0; i<valor.length; i++)
		if(valor.charAt(i) < '0' || valor.charAt(i) > '9')
			return false;
	return true;
}
