﻿// JScript File
var service;

var dayarray=new Array("Domingo","Segunda-Feira","Terça-Feira","Quarta-Feira","Quinta-Feira","Sexta-Feira","Sábado");
var montharray=new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");
var texto = document.createTextNode('Relógio');

// evento Enter - chamada: onKeyDown="KeyDownHandler('ctl00_ContentPlaceHolder1_Search')"
function KeyDownHandler(btn) {
    if (event.keyCode == 13) {
        event.returnValue=false;
        event.cancel = true;
        document.getElementById(btn).click();
    }
}

// evento Tab - chamada: onKeyPress="KeyTabHandler('ctl00_ContentPlaceHolder1_Search')"
function KeyTabHandler(obj) {
    if (event.keyCode == 9) {
        event.cancel = true;
        document.getElementById(obj).click();
    }
}

// Page initialization code, called from Body onLoad event handler
function InitializePage() {		
	service = document.getElementById("service");	

	// Create an instance of the web service and call it WebService
	service.useService("../services/WebService.asmx?WSDL","WebService");		
}

// Page initialization code, called from Body onLoad event handler
function InitializePage1() {		
	service = document.getElementById("service");	

	// Create an instance of the web service and call it WebService
	service.useService("services/WebService.asmx?WSDL","WebService");		
}

function showHide(elementid)
{
    if (document.getElementById(elementid).style.display == 'none')
        document.getElementById(elementid).style.display = '';
    else 
        document.getElementById(elementid).style.display = 'none';
} 

function getBloqueador(){    
    var janela = window.open("#","janelaBloq", "width=5, height=5, top=0, left=0, scrollbars=no, status=no, resizable=no, directories=no, location=no, menubar=no, titlebar=no, toolbar=no");
    if (janela == null){
        alert("IMPORTANTE: Bloqueador de popup ativado! Desabilite para continuar.");
        return false;
    } 
    else {
        janela.close();
        return true;
    }
}    

function AbrirTelaSimples(pCaption, pUrl, pWidth, pHeight)
{
    if (pWidth == 1)
    {
       LeftPosition = 1;
       TopPosition = 1;
       pWidth = window.screen.availWidth;
       pHeight = window.screen.availHeight;
    }
    else
    {
        LeftPosition = (screen.width) ? (screen.width-pWidth)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-pHeight)/2 : 0;
    }

    aWindow = window.open(pUrl, pCaption, 'status=no,scrollbars=yes, menubar=no,status=no,toolbar=no,resizable=yes,width=' + pWidth + ',height=' + pHeight + ',titlebar=yes, alwaysRaised=yes ; top=' + TopPosition + ', left=' + LeftPosition );
    aWindow.focus();
    aWindow.resizeTo(pWidth, pHeight);
}

function AbrirTelaSimplesX(pCaption, pUrl, pWidth, pHeight)
{
    LeftPosition = (screen.width) ? (screen.width-pWidth)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-pHeight)/2 : 0;
        
    aWindow = window.open(pUrl, pCaption, 'status=no,scrollbars=yes, menubar=no,status=no,toolbar=yes,resizable=no,width=' + pWidth + ',height=' + pHeight + ',titlebar=yes, alwaysRaised=yes ; top=' + TopPosition + ', left=' + LeftPosition );
    aWindow.focus();
}


function AbrirTela(pCaption, pUrl, pWidth, pHeight)
{
    LeftPosition = (screen.width) ? (screen.width-pWidth)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-pHeight)/2 : 0;
    
    aWindow = window.open(pUrl, pCaption, 'status=no,scrollbars=yes,menubar=yes,status=no,toolbar=no,resizable=yes,width=' + pWidth + ',height=' + pHeight + ',titlebar=no, alwaysRaised=yes ; top=' + TopPosition + ', left=' + LeftPosition );
    aWindow.focus();
}

function GetCidade(estado)
{
    AbrirTelaSimples('','Gr_PesquisaCidade.aspx?estado=' + estado, 800, 500);
	return;
}

function GetCnpj(cnpj) 
{		
    cnpj=cnpj.replace(/\D/g,"");
	if (cnpj == '')
	{
	    var tomadorfora = '';
	    if (document.getElementById('ctl00$ContentPlaceHolder1$Tomador').checked == false)
	        tomadorfora = 'S';

        //cmbtipopessoa
        var tipopessoa='J';
        if (document.getElementById('ctl00$ContentPlaceHolder1$CmbTomador').value==0)
            tipopessoa='F';
	    
        AbrirTelaSimples('','Gr_PesquisaEmpresa.aspx?tomadorfora=' + tomadorfora + '&tipopessoa=' + tipopessoa, 800, 500);
		return;
    }

    var fl_fora = document.getElementById('ctl00_ContentPlaceHolder1_RbtMunicipio').checked;

    if (fl_fora==true)
        fl_fora='N';
    else
        fl_fora='S';
    
	var iCallID = service.WebService.callService(onGetEmpresaResult, 'GetEmpresa', cnpj, fl_fora);
}

function onGetEmpresaResult(result) 
{
	if (!result.error) 
	{
	    if(result.value == '')
	    {
            document.getElementById('ctl00$ContentPlaceHolder1$txtrazaosocial').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtestado').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtid_empresa').value = '';


	        var tomadorfora = '';
	        if (document.getElementById('ctl00$ContentPlaceHolder1$Tomador').checked == false)
	            tomadorfora = 'S';

            var tipopessoa='J';
            //cmbtipopessoa
            if (document.getElementById('ctl00$ContentPlaceHolder1$CmbTomador').value==0)
                tipopessoa='F';

            AbrirTelaSimples('','Gr_PesquisaEmpresa.aspx?tipopessoa=' + tipopessoa + '&tomadorfora=' + tomadorfora + '&cnpj=' + document.getElementById('ctl00$ContentPlaceHolder1$txtdocumento_tomador').value, 800, 500);
            return;
        }
        var text = result.value.split('|'); 

        document.getElementById('ctl00$ContentPlaceHolder1$txtrazaosocial').value = text[0];
        document.getElementById('ctl00$ContentPlaceHolder1$txtestado').value = text[1];
        document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').value = text[2];
        document.getElementById('ctl00$ContentPlaceHolder1$txtid_empresa').value = text[3];
	}
	else 
		alert("Erro - " + result.errorDetail.code + " " + result.errorDetail.string);		

}

function GetCnpjPrest(cnpj) 
{		
    document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtendereco').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtnumero').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtbairro').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtcep').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$cmbestado').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').disabled=false;
    if (document.getElementById('ctl00$ContentPlaceHolder1$chkEmail').value ==0)
        document.getElementById('ctl00$ContentPlaceHolder1$txtemail').disabled=false;

    cnpj=cnpj.replace(/\D/g,"");
	if (cnpj == '')
	{
	    alert('Informe o CNPJ/CPF.');
		return;
    }
    var tipopessoa='J';
    if (document.getElementById('ctl00$ContentPlaceHolder1$cmbtipopessoa').value==0)
        tipopessoa='F';
    
	var iCallID = service.WebService.callService(onGetPrestResult, 'GetCnpjPrest', tipopessoa, cnpj);
}

function GetCnpjOrgao(cnpj) 
{		
    cnpj=cnpj.replace(/\D/g,"");
	if (cnpj == '')
	{
	    alert('Informe o CNPJ.');
		return;
    }
	var iCallID = service.WebService.callService(onGetPrestResult, 'GetCnpjPrest', 'J', cnpj);
}

function onGetPrestResult(result) 
{
	if (!result.error) 
	{
	    if(result.value == '')
	    {
            document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtendereco').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtnumero').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtbairro').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtcep').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$cmbestado').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').value = '';
            if (document.getElementById('ctl00$ContentPlaceHolder1$chkEmail').value ==0)
                document.getElementById('ctl00$ContentPlaceHolder1$txtemail').value = '';

            return;
        }

        var text = result.value.split('|'); 

        document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$txtendereco').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$txtnumero').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$txtbairro').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$txtcep').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$cmbestado').disabled=true;
        document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').disabled=true;
        if (document.getElementById('ctl00$ContentPlaceHolder1$chkEmail').value ==0)
        {
            if (text[7]!='')
                document.getElementById('ctl00$ContentPlaceHolder1$txtemail').disabled=true;
        }
        
        document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').value = text[0];
        document.getElementById('ctl00$ContentPlaceHolder1$txtendereco').value = text[1];
        document.getElementById('ctl00$ContentPlaceHolder1$txtnumero').value = text[2];
        document.getElementById('ctl00$ContentPlaceHolder1$txtbairro').value = text[3];
        document.getElementById('ctl00$ContentPlaceHolder1$txtcep').value = text[4];
        document.getElementById('ctl00$ContentPlaceHolder1$cmbestado').value = text[5];
        document.getElementById('ctl00$ContentPlaceHolder1$txtcidade').value = text[6];        
        if (document.getElementById('ctl00$ContentPlaceHolder1$chkEmail').value ==0)
            document.getElementById('ctl00$ContentPlaceHolder1$txtemail').value = text[7];
        
        if (text[8]!='')
            document.getElementById('ctl00$ContentPlaceHolder1$cmbtipopessoa').value = text[8];
	}
	else 
		alert("Erro - " + result.errorDetail.code + " " + result.errorDetail.string);		

}

function GetCnpjCont(cnpj) 
{		
    document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtnomecontador').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtcrc').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtcpfcontador').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtrgcontador').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtlogincontador').disabled=false;
    document.getElementById('ctl00$ContentPlaceHolder1$txtemail').disabled=false;

    cnpj=cnpj.replace(/\D/g,"");
	if (cnpj == '')
	{
	    alert('Informe o CNPJ.');
		return;
    }
	var iCallID = service.WebService.callService(onGetCnpjContResult, 'GetCnpjCont', cnpj);
}

function onGetCnpjContResult(result) 
{
	if (!result.error) 
	{
	    if(result.value == '')
	    {
            document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtnomecontador').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtcrc').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtcpfcontador').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtrgcontador').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtlogincontador').value = '';
            document.getElementById('ctl00$ContentPlaceHolder1$txtemail').value = '';
            return;
        }

        var text = result.value.split('|'); 
        
        if (text[0]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').disabled=true;
        if (text[1]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtnomecontador').disabled=true;
        if (text[2]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtcrc').disabled=true;
        if (text[3]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtcpfcontador').disabled=true;
        if (text[4]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtrgcontador').disabled=true;
        if (text[5]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtlogincontador').disabled=true;
        if (text[6]!="")
            document.getElementById('ctl00$ContentPlaceHolder1$txtemail').disabled=true;

        document.getElementById('ctl00$ContentPlaceHolder1$txtrazao').value = text[0];
        document.getElementById('ctl00$ContentPlaceHolder1$txtnomecontador').value = text[1];
        document.getElementById('ctl00$ContentPlaceHolder1$txtcrc').value = text[2];
        document.getElementById('ctl00$ContentPlaceHolder1$txtcpfcontador').value = text[3];
        document.getElementById('ctl00$ContentPlaceHolder1$txtrgcontador').value = text[4];
        document.getElementById('ctl00$ContentPlaceHolder1$txtlogincontador').value = text[5];
        document.getElementById('ctl00$ContentPlaceHolder1$txtemail').value = text[6];
	}
	else 
		alert("Erro - " + result.errorDetail.code + " " + result.errorDetail.string);		
}

// esta funcao deve ser descontinuada, por isto alertar o usuario
function GetRegime() {
    alert('Função descontinuada! Informe a Prefeitura');
    //var id_emp = document.getElementById('ctl00$ContentPlaceHolder1$txtid_empresa').value;
    //var cd_mes = document.getElementById('ctl00$ContentPlaceHolder1$txtdt_prestacao').value.substring(3,5);
    //var cd_ano = document.getElementById('ctl00$ContentPlaceHolder1$txtdt_prestacao').value.substring(6,10);

    //if (id_emp!='' && cd_mes !='' && cd_ano !='')
    //	var iCallID = service.WebService.callService(onGetRegimeResult, 'GetRegime', id_emp, cd_mes, cd_ano);    	
}

//function onGetRegimeResult(result) 
//{
//	if (!result.error) 
//	{
//        document.getElementById('ctl00_ContentPlaceHolder1_lblregime').value = ' - '+ result.value;
//        if (result.value=='Regime: SIMPLES NACIONAL' || result.value=='Regime: SIMPLES NACIONAL - CONTADOR')
//            document.getElementById('ctl00_ContentPlaceHolder1_pnlsimples').style.visibility='visible';  
//        else
//            document.getElementById('ctl00_ContentPlaceHolder1_pnlsimples').style.visibility='hidden';          
//    }
//}

function MM_swapImgRestore() 
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ConfirmaExclusao()
{
    return confirm('Deseja realmente excluir este registro?');
}

function ConfirmaExclusaoMessagem(Mensagem) 
{
    return confirm(Mensagem);
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}
 
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    //v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function foneddd(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}
 
function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}
 
function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

function cnpjcpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    if(v.length==11)
    {
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
        v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
        v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    }
    else if(v.length>11)
    {
        v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
        v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
        v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
        v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    }
    return v
}

function getthedate(){
    var container = document.getElementById("clock");
    var mydate=new Date();
    var day=mydate.getDay();
    var month=mydate.getMonth();
    var daym=mydate.getDate();
    if (daym<10)
    daym="0"+daym;
    var hours=mydate.getHours();
    var minutes=mydate.getMinutes();
    var seconds=mydate.getSeconds();
    if (minutes<=9)
    minutes="0"+minutes;
    if (seconds<=9)
    seconds="0"+seconds;
    var cdate=dayarray[day]+", "+daym+" de "+montharray[month]+" de "+ mydate.getFullYear() +" - "+hours+":"+minutes+":"+seconds;

    for(x=0;x<container.childNodes.length;x++){
        if((container.childNodes[x].nodeType==3)&&(container.childNodes[x].length>5)){
            container.childNodes[x].nodeValue = cdate;
        }

    container.appendChild(texto);
   }
}

function goforit(){
    setInterval("getthedate()",1000);
}


function formatar_moeda(campo, separador_milhar, separador_decimal, tecla) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? tecla.which : tecla.keyCode;

	if (whichCode == 13) return true; // Tecla Enter
	if (whichCode == 8) return true; // Tecla Delete
	key = String.fromCharCode(whichCode); // Pegando o valor digitado
	if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
	len = campo.value.length;
	for(i = 0; i < len; i++)
	if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_decimal)) break;
	aux = '';
	for(; i < len; i++)
	if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) campo.value = '';
	if (len == 1) campo.value = '0'+ separador_decimal + '0' + aux;
	if (len == 2) campo.value = '0'+ separador_decimal + aux;

	if (len > 2) {
		aux2 = '';

		for (j = 0, i = len - 3; i >= 0; i--) {
			if (j == 3) {
				aux2 += separador_milhar;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}

		campo.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
		campo.value += aux2.charAt(i);
		campo.value += separador_decimal + aux.substr(len - 2, len);
	}

	return false;
}
/************************************************************************************************************************************************************
** Para chamá-la, tem-se que passar 3 parâmetros: campo, máscara, evento
** Os parâmetros têm que ser passados através do evento onkeypress.
** 
** ex: input type="text" name="cep" id="cep" onkeypress="return fnMascara(this, '???.???.???-??', Event)"> // fnMascara o campo para cep
** 
** O caracter '?' define que só será permitido números
** O caracter '!' define que é permitido qualquer caracter
** 
** obs: com essa função, É necessário colocar a propriedade 'maxlength' no campo.
*************************************************************************************************************************************************************/
function fnMascara(campo, mask, evt) {

    if (document.all) { // Internet Explorer
        key = evt.keyCode;
    }
    else { // Nestcape
        key = evt.which;
    }

    if (key == 8) {
        return true;
    }

    string = campo.value;
    i = string.length;

    if (i < mask.length) {
        if (mask.charAt(i) == '?') {
            return (key > 47 && key < 58);
        } else {
            if (mask.charAt(i) == '!') { return true; }
            for (c = i; c < mask.length; c++) {
                if (mask.charAt(c) != '?' && mask.charAt(c) != '!')
                    campo.value = campo.value + mask.charAt(c);
                else if (mask.charAt(c) == '!') {
                    return true;
                } else {
                    return (key > 47 && key < 58);
                }
            }
        }
    } else return false;
}

