﻿/*********************************/
function GetTecla()
/*********************************/
{
	var tecla;
	
	if(navigator.appName.indexOf("Netscape")!= -1)
	{
		tecla = event.which;
	}
	else 
	{
		tecla = event.keyCode; 
	}
	
	return tecla;
}

/**********************************/
function GetCaracterAcentuado()
/**********************************/
{
    var tecla = GetTecla();
   
    return ((tecla >= 192) && (tecla <= 259))
}

function isNum( caractere ) 
{ 
    var strValidos = "0123456789";
    if (strValidos.indexOf( caractere ) == -1)
    {
        return false; 
    }
    else
    {
        return true;
    }
} 

function validaTecla(campo, event) 
{ 
    var BACKSPACE = 8;
    var tecla = GetTecla();
    var key = String.fromCharCode(tecla);
    
    //alert( 'key: ' + tecla + ' -> campo: ' + campo.value); 
    if (tecla == 13)
    {
        return false;
    }
    
    if (tecla == BACKSPACE)
    {
        return true;
    }
    
    if ((tecla == 44) || (tecla == 46))
    {
        return false;
    }
 
    return isNum(key);
}

function SomenteLetrasEPonto(src, event)
{
    var tecla = GetTecla();
    
    //  Ponto           letras  maiúsculas             letras minúsculas              backspace           tab                  home/end             cedilha           espaço
    if((tecla == 46) || (tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123) || (tecla == 8) || (tecla == 9) || (tecla > 2  && tecla < 4) || (tecla == 231) || (tecla == 32) || (GetCaracterAcentuado()))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function SomenteNumerosETraco(src, event)
{
    var tecla = GetTecla();
    
    //  Números e Traço
    if((tecla > 47 && tecla < 58) || (tecla == 45))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function EmailKeyPress(email)
{
    var tecla = GetTecla();

    //   Números                          @               letras maiúsculas             letras minúsculas           Ponto e traço                 backspace        tab            underline         home/end                                                                              
    if((tecla > 47 && tecla < 58) || (tecla == 64) || (tecla > 64 && tecla < 91) || (tecla > 96 && tecla < 123) || (tecla > 44 && tecla < 47) || (tecla == 8) || (tecla == 9) || (tecla == 95) || (tecla > 2  && tecla < 4))
    {
        return true;
    }
    else
    {
        return false;
    }
}


