


function confereCampoVazio(campo)
{
	if( campo.value == "" ) 
	{
		alert("Please, type on the field '" + campo.id + "'.");
		campo.focus();
		return false;		
	}
	return true;
	
}

function Tecla(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
	if (tecla > 47 && tecla < 58) // numeros de 0 a 9
		return true;
	else
		{
			if (tecla != 8) // backspace
				event.keyCode = 0;
				//return false;
			else
				return true;
		}
}

function validaInt(campo)
{
	valor = campo.value;
	
	if( (valor < -2147483648) || (valor > 2147483647))
	{
		alert("Valor fora do intervalo numérico permitido.");
		campo.value = "";
		campo.focus();
	}
	
}

function validaSmallInt(campo)
{
	valor = campo.value;
	
	if( (valor < -32768 ) || (valor > 32767))
	{
		alert("Valor fora do intervalo numérico permitido.");
		campo.value = "";
		campo.focus();
	}
	
}

function validaTinyInt(campo)
{
	valor = campo.value;
	
	if( (valor < 0 ) || (valor > 255))
	{
		alert("Valor fora do intervalo numérico permitido.");
		campo.value = "";
		campo.focus();
	}	
}

function validaString(campo,num)
{
	str = campo.value;
	//alert (str);
	//alert (str.lenght + "  " + num);
	
	if( str.length  > (num-1) )
	{
		str = str.substring(0,num-1);
		campo.value = str;
	}	
}


function confereNumChar(num, campo)
{
	//alert (campo.value);
	 if (campo.value.length > num) 
	 {
		alert("O tamanho máximo permitido para o campo é " + num + ".");
		campo.value = campo.value.substr(0,num-1);
		campo.focus();
		return false ;
  	}
	return true;	
}