
function testaNumero(inputBox, texto) {
  str = inputBox.value;
  for (i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        if ((ch < "0" || ch > "9")) {
			alert ("O "+texto+" não é válido!");
			inputBox.focus();
			return false;
		}
  }
  return true;
}

function digitaNumero()
{
	var Tecla = window.event.keyCode;
	event.cancelBubble = true;
//	alert(Tecla);
	if((Tecla > 47 && Tecla < 58) || Tecla == 13)
		event.returnValue = true;
	else
		event.returnValue = false;
}

function digitaFone() {
	var Tecla = window.event.keyCode;
	event.cancelBubble = true;
//	alert(Tecla);
	if((Tecla > 47 && Tecla < 58) || Tecla == 40 || Tecla == 41 || Tecla == 43 || Tecla == 13)
		event.returnValue = true;
	else
		event.returnValue = false;
}

function testaMinimo(inputBox, minimo, texto){
  str = inputBox.value;
  if (str.length<minimo) {
	alert(texto + " deve possuir no mínimo " + minimo +" caracteres.");
	inputBox.focus();
	return false;
  }
  return true;
}

function testaMaximo(inputBox, maximo, texto){
  str = inputBox.value;
  if (str.length>maximo) {
//	alert(texto + " deve possuir no máximo " + maximo +" caracteres.");
	inputBox.length = inputBox.length-1;	
	inputBox.focus();
//	return false;
  }
  return true;
}

function digitaMoeda()
{
	var Tecla = window.event.keyCode;
	event.cancelBubble = true;
	if(Tecla==46 || Tecla==44){
        var texto = window.event.srcElement.value
        if(texto.indexOf(",")>-1){
            event.returnValue = false;
        }else{
            window.event.keyCode=44;
            event.returnValue = true;        
        }
    }else{
        if((Tecla > 47 && Tecla < 58))
		    event.returnValue = true;
    	else
		    event.returnValue = false;
   }
}

function telefone(valor, minimo, maximo, campo) {
alert(valor + "\n" + minimo + "\n" + maximo + "\n" + campo.name);
/*
  if (campo.length<minimo) {
	alert("O campo telefone deve possuir no mínimo " + minimo +" caracteres.");
	campo.focus();
	return false;
  }
  if (campo.length>maximo) {
	alert("O campo telefone deve possuir no máximo " + maximo +" caracteres.");
	campo.focus();
	return false;
  }
  return true;
*/
}
