﻿    //exemplo de uso do noLetters: onKeyDown="return noLetters(event);"
    function noLetters(e)
    {
        var tecla;
        if(!e)
	        e = window.event;
		
        // verificação cross-browser
        if(e.which)
	        tecla = e.which;
        else if(e.keyCode)
	        tecla = e.keyCode;

        if( (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) || tecla == 8 || tecla == 37 || tecla == 39 || tecla == 46 || tecla == 9 )
        {
	        /*9: tab; 8 = backspace; 37 = seta pra esquerda; 39 = seta pra direita; 46 = delete*/
	        return true;
        }
        else
        {
	        return false;
        }
    }
	
    //formata uma data corretamente
    function formataData( obj )
    {
        if( parseInt(obj.value.length) == 2 )
	        obj.value += "/";
        if( parseInt(obj.value.length) == 5 )
	        obj.value += "/";
    }
	
    //formata uma CPF corretamente
    function formataCPF( obj )
    {
        if( parseInt(obj.value.length) == 3 )
	        obj.value += ".";
        if( parseInt(obj.value.length) == 7 )
	        obj.value += ".";
        if( parseInt(obj.value.length) == 11 )
	        obj.value += "-";			
    }
	
    //formata uma telefone corretamente
    function formataTelefone( obj )
    {
        if (parseInt(obj.value.length) == 2 || parseInt(obj.value.length) == 7)
	        obj.value += "-";			
    }
	
    //formata uma CEP corretamente
    function formataCEP( obj )
    {
        if( parseInt(obj.value.length) == 5 )
	        obj.value += "-";
	}


	function EnviaExibicao(idLogo, idControle) {
	    
	    var StringData = "idLogo=" + idLogo;

	    $.post("AdicionaExibicao.aspx", StringData, function(data) {
	        document.getElementById(idControle).innerHTML = data;

	    });
	
	
	}
	
	function ContaCaracteres(contador, obj, e)
    {
        if((450 - obj.value.length) == -1)
        {
            obj.value = obj.value.substr(0,450);
        }
        else
        {
            if(window.event) // IE
            {                    
                if(e.keyCode == 8 || e.keyCode == 36)
                {
                    if(obj.value.length != -1)
                        document.getElementById(contador).value = 450 - (obj.value.length);
                }
                else
                {
                    document.getElementById(contador).value = 450 - (obj.value.length);
                }
            }
            else
            {
                if(e.which == 8 || e.which == 36)
                {
                    if(obj.value.length != -1)
                        document.getElementById(contador).value = 450 - (obj.value.length);
                }
                else
                {
                    document.getElementById(contador).value = 450 - (obj.value.length);
                }
            }
        }
    }