PageSourceSearch

https://www.ipatinga.mg.gov.br/scripts/int_cad.js

js ipatinga.mg.gov.br collected 2026-10-02 04:30:48 UTC 93,627 bytes, 2,119 lines download raw bytes

1/* ===========================================================================
2CÓDIGO JAVASCRIPT DO MÓDULO DE INTERNAUTA
3PROGRAMADOR: Ricielly Ortolani
4DATA: 18/07/2012
5ULTIMA REVISAO: 14/11/2012 17:19 VINICIUS M CÂNDIDO DUTRA
6============================================================================ */
7if (!String.prototype.trim) {
8    String.prototype.trim = function () {
9        return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
10    };
11}
12
13//logica específica de int_cad
14var INT_CAD = (function (window, document, undefined) {
15    var enumDmTipo = {
16        "dmperson_f": 1,
17        "dmperson_j": 2,
18        "dmperson_1": "f",
19        "dmperson_2": "j"
20    },
21        idListPF = "#ul_documento_pf",
22        idListPJ = "#ul_documento_pj",
23        classItensPF = ".exclusivoPF",
24        classItensPJ = ".exclusivoPJ",
25        mainContext = "#conteudo",
26        whitespace = "[\\x20\\t\\r\\n\\f]",
27        core_trim = "".trim,
28        rtrim = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g"),
29        trim;
30
31
32    trim = core_trim && !core_trim.call("\uFEFF\xA0") ?
33        function (text) {
34            return text == null ?
35                "" :
36                core_trim.call(text);
37        } :
38        // Otherwise use our own trimming functionality
39        function (text) {
40            return text == null ?
41                "" :
42                (text + "").replace(rtrim, "");
43        };
44
45    function ConfirmAction(fConfirm, fCancel, msg) {
46        var action = new MessageAction(); action.Ok = function () { Message.Hide(); };
47
48        action.Ok = (function (f) {
49            return function () {
50                var temp = f ? f() : null;
51                Message.Hide();
52            };
53        })(fConfirm);
54
55        action.Cancel = (function (f) {
56            return function () {
57                var temp = f ? f() : null;
58                Message.Hide();
59            };
60        })(fCancel);
61
62        Message.Show(MessageIcon.Warning, MessageButtons.OkCancel, msg, action);
63    }
64
65    function toggleBtnAddDocs(manual, status) {
66        var
67            btn = document.getElementById("bt_add_documento"),
68            _dmPerson = dmPerson(),
69            list = get(_dmPerson === "dmperson_1" ? idListPF : idListPJ)[0],
70            exist = list.getElementsByTagName("li").length,
71            limit = list.getElementsByTagName("li")[0].getElementsByTagName("select")[0].options.length,
72            changeStatus;
73
74        changeStatus = (function () {
75
76            return function (show) {
77                btn.style.opacity = show ? 1 : 0.5;
78                btn.style.filter = show ? "alpha(opacity=100)" : "alpha(opacity=50)";
79            }
80        }());
81
82
83        if (manual) {
84            if (status === true) {
85                changeStatus(true);
86            } else if (status === false) {
87                changeStatus(false);
88            }
89        } else {
90            if (exist >= limit) {
91                changeStatus(false);
92            } else {
93                changeStatus(true);
94            }
95        }
96
97        btn = list = null;
98    }
99
100
101    function dmPerson() {
102        return "dmperson_" + (document.getElementById("rdb_pf").checked ? 1 : 2);
103    }
104
105    function bind(elem, eventName, eventHandler) {
106        if (elem && elem.addEventListener) {
107            elem.addEventListener(eventName, eventHandler, false);
108        }
109        else if (elem && elem.attachEvent) {
110            elem.attachEvent("on" + eventName, (function (e, h) {
111                return function () {
112                    h.apply(e, arguments);
113                }
114            }(elem, eventHandler)));
115        } else if (elem && elem.nodeType) {
116            elem['on' + event] = eventHandler;
117        }
118        return elem;
119    }
120
121    //usar somente para os tipos array verdadeiros
122    function each(colecao, callback, oncomplete) {
123        for (var i = 0, length = colecao.length; i < length; i++) {
124            if (callback.call(colecao[i], i, colecao[i]) === true) {
125                break;
126            };
127        }
128        if ((typeof oncomplete).toLowerCase() === "function") {
129            oncomplete();
130        }
131    }
132
133    function alternateDocumentType(type) {
134        var
135            dmTipo = +enumDmTipo[("dmperson_" + type.toLowerCase())],
136            classItensToShow = dmTipo === 1 ? classItensPF : classItensPJ,
137            classItensToHide = dmTipo === 1 ? classItensPJ : classItensPF;
138
139        //oculta itens do tipo atual
140        each(get(classItensToHide, mainContext), function () {
141            this.style.display = "none";
142        });
143
144        //mostra itens do tipo escolhido
145        each(get(classItensToShow, mainContext), function () {
146            this.style.display = "";
147        });
148
149        toggleBtnAddDocs();
150    }
151
152    /*
153    * Centraliza através de um identificador todos os tipos ja utilizados,
154    * afim de infomar a aplicacao ja foi usado ou esta disponivel, alem eh claro, de 
155    * configurar valor de uso (true=ja usado, false=disponivel)
156    */
157    function usageDoc(cd, vlue) {
158
159        var
160            store = get("#bt_add_documento")[0],
161            type = dmPerson(),
162            cd = +cd || -1,
163            retr = null;
164
165        //se o 'vlue' nao for passado, retornar o status para o dado código
166        //se o 'cd' for menor ou igual a 0, retornar false, ou seja, tipo nao usado
167        retr = (vlue === undefined || cd <= 0) ? (store[type][("dmtipo_" + cd)] || false) : store[type][("dmtipo_" + cd)] = vlue;
168        store = null; //avoid memory leak
169        return retr;
170    }
171
172    function changeIdElemDocuments(li, cont) {
173        each(li.getElementsByTagName("label"), function () {
174            var id = this.htmlFor;
175            this.htmlFor = id.replace(id.substring(id.lastIndexOf("_") + 1), cont);
176        });
177        each(li.getElementsByTagName("select"), function () {
178            var id = this.id;
179            this.id = id.replace(id.substring(id.lastIndexOf("_") + 1), cont);
180        });
181        each(li.getElementsByTagName("input"), function () {
182            var id = this.id;
183            this.id = id.replace(id.substring(id.lastIndexOf("_") + 1), cont);
184        });
185    }
186
187    /*
188    * use com cuidado o método get, dependendo da forma de uso pode ser doloroso para o browser
189    * Dicas:
190    *   - use o contexto somente através de ID
191    *   - quando usar ID, nao use o contexto
192    *   - não use isso: get(".classe", ".contextoPorClasse"), pode ser um processamento árduo
193    *   - o uso do parâmetro "tag", só terá validade quando usado em browsers que não suportam o método nativo
194    *   - quando usar classe, será retornado um array dos intens que c
194asarem com a classe
195    *   - contexto pode ser uma string "#meu_contexto" ou um elemento
196    *   - lembre-se que mesemo sendo usado id para identificador, será retornado um array, portando se quiser trabalhar com o elemento
197    *     diretamente, faça: get("#meu_id")[0]
198    */
199    function get(identificador, contexto, tagType) {
200        var
201            contexto = contexto ? (contexto.nodeType ? contexto : get(contexto)[0]) : null,
202            tagType = tagType || null,
203            ret = null;
204
205        ret = identificador.nodeType ? identificador : /#.*/ig.test(identificador) ?
206            document.getElementById(identificador.slice(1)) :
207            document.getElementsByClassName ? (contexto || document).getElementsByClassName(identificador.slice(1)) : getElementsByClassName(identificador.slice(1), tagType, contexto);
208
209        return !ret || ret.nodeType ? [ret] : ret;
210    }
211
212
213    //incializa propriedades em um objeto
214    function initProp(source, props) {
215        if (source) {
216            for (var prop in props) {
217                if (props.hasOwnProperty(prop)) {
218                    source[prop] = {};
219                }
220            }
221        }
222    }
223
224
225
226    /*
227    * Métodos publicos ao módulo INT_CAD
228    */
229    return {
230        init: function () {
231            var
232                btnAddDocs = document.getElementById("bt_add_documento"),
233                a = initProp(btnAddDocs, enumDmTipo),
234                stTel = hdf_stTelefones.value;
235            var sicCorrespondencia = sessionStorage.getItem("SicCorresp");
236
237            if (btnAddDocs) {
238
239                //evento do botão adicionar documento
240                btnAddDocs.onclick = function () {
241                    var
242                        _dmPerson = dmPerson(),
243                        list = get(_dmPerson === "dmperson_1" ? idListPF : idListPJ)[0],
244                        newLi = list.getElementsByTagName("li")[0].cloneNode(true),
245                        limit = list.getElementsByTagName("li")[0].getElementsByTagName("option").length,
246                        exist = list.getElementsByTagName("li").length,
247                        selectType = get(".cddocumentotipo", newLi)[0],
248                        btnAdd = this;
249
250                    //init prev property                      
251                    selectType.prev = { v: selectType.value, i: selectType.selectedIndex };
252
253                    //limita a quantidade de documentos que podem ser adicionados, pelos tipos disponíveis
254                    if (limit - 1 === exist) {
255                        toggleBtnAddDocs(true, false);
256                    } else if (exist >= limit) {
257                        list = btnAdd = newLi = null;
258                        return;
259                    } else {
260                        toggleBtnAddDocs(true, true);
261                    }
262
263                    /*
264                    * Logica responsável por gerenciar o uso dos tipo de documentos,
265                    * afim de que o usuario possa ter selecionado no dropdown de tipos
266                    * de documentos um tipo por vez, e além disso, preeencher o valor
267                    * do item selecionado, caso exista. tendo os seguintes comportamentos:
268                    * - quando um tipo escolhido já estiver selecionado, volte ao estado de
269                    * seleção anterior
270                    * - quando o item estiver disponível, permita-o ser usado além de setar
271                    * o valor presente no atributo "data-nudocumento" no input vinculado.
272                    * - a prop 'prev' do select é inicializada para os itens pré existentes e além dos clones
273                    * - se o input text vinculado já estiver definido, ele não ocorrerá modificação
274                    */
275                    bind(selectType, "change", function (e) {
276                        var
277                            isUsed = usageDoc(this.value),
278                            that = this,
279                            _index = this.selectedIndex,
280                            _value = this.value,
281                            prev = this.prev,
282                            item = this.options.item(isUsed ? prev.i : _index),
283                            nuDocumento = item.getAttribute("data-nudocumento"),
284                            txt_nudocumento = get(".txt_documento", newLi)[0],
285                            stCurriculo = +this.options.item(prev.i).getAttribute("data-stcurriculo"),
286                            isOrigDestValid = prev.v >= 0,
287                            confirmChange, rollbackChange;
288
289                        confirmChange = (function () {
290                            return function () {
291                                //define os itens que foram usado/liberado
292                                usageDoc(that.value, true);
293                                usageDoc(prev.v, false);
294
295                                that.prev = { v: +(_value), i: +(_index) };
296                                txt_nudocumento.value = nuDocumento;
297                            }
298                        }());
299
300                        rollbackChange = (function () {
301                            return function () {
302                                that.value = prev.v;
303                            }
304                        }())
305
306
307                        if (isUsed) {
308                            rollbackChange();
309                        }
310                        else {
311                            //caso esteja sendo usado pelo curriculo, exigir confirmação
312                            if (stCurriculo === 1 && isOrigDestValid) {
313                                ConfirmAction(confirmChange, rollbackChange, "Este documento é utilizado em seu currículo, tem certeza de que deseja apagar este documento?")
314                            } else {
315                                confirmChange();
316                            }
317                        }
318                    });
319                    //=========================================================
320
321
322                    newLi.style.display = "";
323
324                    //adiciona evento ao botão excluir
325                    bind(newLi.getElementsByTagName("button")[0], 'click', function () {
326                        var
327                            that = this
328                            , list = that.parentNode.parentNode.parentNode.parentNode
329                            , item = get(".cddocumentotipo", this.parentNode.parentNode.parentNode)[0]
330                            , txt_nudocumento = get(".txt_documento", this.parentNode.parentNode.parentNode)[0]
331                            , prev = item.prev
332                            , _index = item.selectedIndex
333                            , _value = item.value
334                            , stCurriculo = +item.options.item(_index).getAttribute("data-stcurriculo")
335                            , isValidDefinition = _value >= 0 && trim(txt_nudocumento.value).length > 0
336                            , confirmChange;
337
338                        confirmChange = (function () {
339                            return function () {
340                                //permitindo o uso do tipo que esta sendo removido
341                                usageDoc(_value, false);
342                                list.removeChild(that.parentNode.parentNode.parentNode);
343
344                                var arr_li = list.getElementsByTagName("li");
345                                for (var i = 1; i < arr_li.length; i++) {
346                                    changeIdElemDocuments(arr_li[i], i);
347                                }
348
349                                //o método abaixo faz a query dos elementos a cada chamada, deve-se remover o item primeiro para o metodo comportar-se como esperado
350                                toggleBtnAddDocs();
351                            }
352                        }());
353
354                        if (stCurriculo === 1) {
355                            ConfirmAction(confirmChange, null, "Este documento é utilizado em seu currículo, tem certeza de que deseja apagar este documento?");
356                        } else if (isValidDefinition) {
357                            ConfirmAction(confirmChange, null, "Tem certeza de que deseja apagar este documento?");
358                        } else {
359                            confirmChange();
360                        }
361
362                    });
363
364                    changeIdElemDocuments(newLi, exist);
365
366                    list.appendChild(newLi);
367                }
368            }
369
370            if (sicCorrespondencia == "true" && hdf_stEndereco.value == "True" && hdf_redir.value == "sic_cad.aspx") {
371                div_cep.setAttribute("class", "form-group required");
372                div_bairro.setAttribute("class", "form-group required");
373                div_tipo_log.setAttribute("class", "form-group required");
374                div_logradouro.setAttribute("class", "form-group required");
375                div_numero.setAttribute("class", "form-group required");
376            } else {
377                if (hdf_stEndereco.value == "True" && (hdf_redir.value == "sic_cad.aspx" || hdf_redir.value == "sic_pag.aspx" || hdf_redir.value == "sic_lis.aspx") && hdf_stTornaCamposInternautaOpcionaisSic.value == "True") {
378                    if ($("#div_dtNascimento").val() != undefined) div_dtNascimento.setAttribute("class", "form-group");
379                    if ($("#div_nacionalidade").val() != undefined) div_nacionalidade.setAttribute("class", "form-group");
380                    if ($("#div_naturalidade").val() != undefined) div_naturalidade.setAttribute("class", "form-group");
381                    if ($("#div_sexo").val() != undefined) div_sexo.setAttribute("class", "form-group");
382                    if ($("#div_pais").val() != undefined) div_pais.setAttribute("class", "form-group");
383                    if ($("#div_estado1").val() != undefined) div_estado1.setAttribute("class", "form-group");
384                    if ($("#div_estado2").val() != undefined) div_estado2.setAttribute("class", "form-group");
385                    if ($("#div_municipio").val() != undefined) div_municipio.setAttribute("class", "form-group");
386                    if ($("#div_municipio2").val() != undefined) div_municipio2.setAttribute("class", "form-group");
387                }
388            }
389
390            if (hdf_cdinternauta.value != -1) {
391                var licitacao = int_cad.moduloLicitacaoAtivo();
392                if (hdf_stEndereco.value == "False" || hdf_stDadosPessoais.value == "False" || hdf_stDocPessoais.value == "False" || hdf_stDadosCNH.value == "False")
393                    document.getElementById("div_completar_cadastro").style.display = "block";
394                else if (hdf_stDadosLicitacao.value == "False" && licitacao.value)
395                    document.getElementById("div_completar_cadastro").style.display = "block";
396                else
397                    document.getElementById("div_completar_cadastro").style.display = "none";
398            }
399
400        },
401        dmPerson: dmPerson,
402        alternateDocumentType: alternateDocumentType,
403        get: get,
404        idListPF: idListPF,
405        idListPJ: idListPJ,
406        usageDoc: usageDoc,
407        toggleBtnAddDocs: toggleBtnAddDocs,
408        each: each,
409        trim: trim
410    };
411}(window, window.document));
412
413INT_CAD.init();
414
415//Estrutura que controla os Documentos
416
417(function () {
418
419    var un = ["undefined", null, "null"];
420
421    this.PortalFacil = {};
422
423    this.PortalFacil.classe = int_cad.AjaxGetClass();
424
425    this.PortalFacil.AjaxSave = function () {
426        var txt_captcha_cad = document.getElementById("txt_captcha_cad"),
427            isEnabledCaptcha = txt_captcha_cad && txt_captcha_cad.Captcha ? true : false,
428            docs = (function () {
429                var docs = [],
430                    dmTipo = INT_CAD.dmPerson(),
431                    idListPF = INT_CAD.idListPF.replace(/(\.|#)/g, ""),
432                    idListPJ = INT_CAD.idListPJ.replace(/(\.|#)/g, ""),
433                    contexto = document.getElementById(dmTipo === "dmperson_1" ? idListPF : idListPJ),
434                    length = contexto.getElementsByTagName("li").length,
435                    cddocumentotipo = INT_CAD.get(".cddocumentotipo", contexto, "select"),
436                    nudocumento = INT_CAD.get(".nudocumento", contexto, "input"),
437                    txt_documento = document.getElementById("txt_nuDocumento"),
438                    num_cnh = document.getElementById("num_cnh"),
439                    isPreenchido;
440
441
442                //começando em 1 por causa do item modelo, usado para clonar. os documentos são definidos a partir do segundo item da lista
443                for (var i = 1; i < length; i++) {
444
445                    isPreenchido = (INT_CAD.trim(nudocumento[i].value).length > 0) && (cddocumentotipo[i].value > 0);
446
447                    if (isPreenchido) {
448                        docs.push({
449                            CDDOCUMENTOTIPO: cddocumentotipo[i].value
450                            , NUDOCUMENTO: nudocumento[i].value
451                            , CDINTERNAUTA_DOCUMENTOTIPO: (cddocumentotipo[i].options.item(cddocumentotipo[i].selectedIndex).getAttribute("data-cddocumentotipo") || -1)
452                        });
453                    }
454                }
455
456                //Pessoa juírida não possue CNH
457                if (dmTipo === "dmperson_1") {
458                    if (num_cnh && num_cnh.value != "") {
459                        var cdcategoriacnh = document.getElementsByName("cdcategoriacnh", "input"),
460                            asCategorias = [];
461
462                        for (var z = 0; z < cdcategoriacnh.length; z++) {
463                            if (cdcategoriacnh[z].checked)
464                                asCategorias.push(cdcategoriacnh[z].value)
465                        }
466
467                        docs.push({
468                            CDDOCUMENTOTIPO: document.getElementById("cddocumentotipo_cnh").value
469                            , NUDOCUMENTO: num_cnh.value
470                            , INTERNAUTA_DOCUMENTOTIPO_CATEGORIACNH: asCategorias
471                        });
472                    }
473                }
474                return docs;
475            }()),
476            licitacaoCategoria = $("#ddl_cdLicitacaoCategoria").val() || [];
477
478        var dataNascimento = rdb_pf && rdb_pf.checked ? dtnascimento.value.toDate() : null;
479
480        if (hdf_stDadosPessoais.value == "False" || dataNascimento == false)
481            dataNascimento = null;
482
483        var municipio = (cdpais.value == 1 ? cdmunicipio.value : -1),
484            CEP = nucep.value;
485
486        if (hdf_stEndereco.value == "False") {
487            municipio = -1,
488                CEP = null;
489        }
490        var ckbAutorizacaoDados = false;
491        var lgpd = document.getElementById("pnlLGPD");
492        if (lgpd != null) {
493            ckbAutorizacaoDados = document.getElementById('ckbAutorizacaoDados');
494        }
495        var Internauta =
496        {
497            EDEMAIL: edmail.value,
498            DSSENHA: dssenha.value.replace(/^\s+|\s+$/g, ""),
499            NMINTERNAUTA: nminternauta.value,
500            DMTIPOUSUARIO: (rdb_pf.checked) ? 1 : 2,
501            NUDOCUMENTO: txt_nuDocumento.value,
502            NMRESPONSAVEL: txt_nmResponsavel.value,
503            NUDDDTELEFONE: nudddtelefone.value,
504            NUTELEFONE: nutelefone.value,
505            NURAMAL: nuramal.value,
506            NUDDDCELULAR: nudddcelular.value,
507            NUCELULAR: nucelular.value,
508            ISPOSSUINEWSLETTER: (int_cad.IsEnableNewsletter().value) ? $('#chk_receber_newsletter').prop('checked') : false,
509            DADOPOSTAL:
510            {
511                //cdBairro: cdbairro.value,
512                cdBairro: -1,
513                cdPais: cdpais.value,
514                cdMunicipio: municipio,
515                nmMunicipioExterior: (cdpais.value == 1 ? '' : nmmunicipioexterior.value),
516                nmEstadoExterior: (cdpais.value == 1 ? '' : nmestadoexterior.value),
517                nmBairro: nmbairro.value,
518                cdLogradouroTipo: (cdlogradourotipo.value == "" ? -1 : cdlogradourotipo.value),
519                nmLogradouro: nmlogradouro.value,
520                dsNumeroResidencia: dsnumeroresidencia.value,
521                dsComplemento: dscomplemento.value,
522                nuCEP: CEP
523            },
524            DADOPESSOAL:
525            {
526                //tipo dateTime possui restrições ao valor passado, ocasionando exceção durante o parse
527                //dtNascimento: rdb_pf && rdb_pf.checked ? dtnascimento.value.toDate() : null, 
528                dtNascimento: dataNascimento,
529                cdNacionalidade: cdnacionalidade.value,
530                nmNaturalidade: nmnaturalidade.value,
531                dmEstadoCivil: dmestadocivil.value,
532                dmSexo: dmsexo.value,
533                stPcd: (chk_pcd.checked)
534            },
535            DADOSCAPTCHA: {
536                captchaid: isEnabledCaptcha ? txt_captcha_cad.Captcha.Id : "",
537                instanceid: isEnabledCaptcha ? txt_captcha_cad.Captcha.InstanceId : "",
538                userinput: isEnabledCaptcha ? txt_captcha_cad.value : ""
539            },
540            IMAGEM: {
541                cdImagem: hdf_cdImagem.value,
542                idImagem: hdf_idImagem.value,
543                nmImagemExtensao: hdf_nmImagemExtensao.value,
544                dsDescricao: "Imagem do internauta",
545                nuAltura: hdf_nuAlturaImagem.value,
546                nuLargura: hdf_nuLarguraImagem.value,
547                nuTamanho: hdf_nuTamanhoImagem.value,
548                dtCriacao: int_cad.GetDateInClientTimeZone().value,
549                stExibeRepositorio: false,
550                stAcessoPublico: false
551            },
552            INTERNAUTA_DOCUMENTOTIPO: docs,
553            INTERNAUTA_LICITACAOCATEGORIA: licitacaoCategoria,
554            stDadosLicitacao: hdf_stDadosLicitacao.value.toLowerCase() == 'true' ? true : false,
555            stDadosPessoais: hdf_stDadosPessoais.value.toLowerCase() == 'true' ? true : false,
556            stDadosPostais: hdf_stEndereco.value.toLowerCase() == 'true' ? true : false,
557            stDocPessoais: hdf_stDocPessoais.value.toLowerCase() == 'true' ? true : false,
558            stAutorizacaoDados: ckbAutorizacaoDados.checked
559        };
560
561        PortalFacil.classe = Internauta;
562
563        int_cad.Save(PortalFacil.classe, function (res) {
564            if (res.error == null) {
565
566                var msgRetorno = "",
567                    action = new MessageAction();
568
569                //default action.Ok
570                action.Ok = function () { Message.Hide() };
571
572                if ([0, 4].contains(res.value)) {
573                    if (hdf_redir.value != "-1") {
574                        if (hdf_redir.value == "uc_enquete.aspx" || hdf_redir.value == "uc_comentario.aspx")
575                            action.Ok = function () { Message.Hide(); window.close(); };
576                        else
577                            action.Ok = function () { window.location = hdf_redir.value; };
578                    }
579                    else
580                        action.Ok = function () { window.location = "default.aspx"; };
581
582                    action.Cancel = function () { window.location = "default.aspx"; };
583
584                    var sMsg = "";
585                    if (res.value == 0) {
586                        if (hdf_redir.value != "-1" && hdf_redir.value != "uc_enquete.aspx" && hdf_redir.value != "uc_comentario.aspx")
587                            action.Ok = function () { window.location = "int_cad.aspx?redir=" + hdf_redir.value; };
588                        else
589                            action.Ok = function () { window.location = "default.aspx"; };
590
591                        if (hdf_mensagemCadastroCustom.value != "")
592                            sMsg = hdf_mensagemCadastroCustom.value;
593                        else if (hdf_redir.value != "-1" && hdf_redir.value != "uc_enquete.aspx" && hdf_redir.value != "uc_comentario.aspx" && hdf_redir.value != "custom/sol_ace_sol_cad.aspx")
594                            sMsg = "Cadastro realizado com sucesso. Um e-mail será enviado para a sua caixa de mensagens, contendo um link para ativação do seu cadastro. Caso o e-mail não seja enviado à caixa de mensagens, favor consultar o spam. Clique em \"Ok\" para retornar à página de login.";
595                        else
596                            sMsg = "Cadastro realizado com sucesso. Um e-mail será enviado para a sua caixa de mensagens, contendo um link para ativação do seu cadastro. Caso o e-mail não seja enviado à caixa de mensagens, favor consultar o spam. Clique em \"Ok\" para retornar à página principal do Portal.";
597                    }
598                    else {
599                        if (hdf_redir.value != "-1") {
600                            if (hdf_redir.value == "uc_enquete.aspx" || hdf_redir.value == "uc_comentario.aspx")
601                                sMsg = "Cadastro atualizado com sucesso. Clique em \"Ok\" e acesse novamente a página de origem para dar sequência à ação.";
602                            else
603                                sMsg = "Cadastro atualizado com sucesso. Clique em \"Ok\" para retornar à página de origem.";
604                        }
605                        else
606                            sMsg = "Cadastro atualizado com sucesso. Clique em \"Ok\" para retornar à página principal do Portal.";
607                    }
608                    Message.Show(MessageIcon.Information, MessageButtons.Ok, sMsg, action);
609
610                    return true;
611                }
612                else if (res.value == 1) {
613                    msgRetorno = "Não foi possível concluir o cadastro. O e-mail informado já está cadastrado. É provável que você já tenha um cadastro. Se esqueceu a sua senha, recupere-a por meio da opção \"esqueci minha senha\" na tela de login.";
614                }
615                else if (res.value == 2) {
616                    msgRetorno = "Não foi possível concluir o cadastro. O número de documento informado já está cadastrado. É provável que você já tenha um cadastro. Se esqueceu a sua senha, recupere-a por meio da opção \"esqueci minha senha\" na tela de login.";
617                }
618                else if (res.value == 3) {
619                    msgRetorno = "Ocorreu um erro ao realizar o cadastro, por favor tente novamente em alguns minutos, se o problema persistir entre em contato com o suporte técnico.";
620                }
621                else if (res.value == 5) {
622                    msgRetorno = Msg[8];
623                    action.Ok = function () {
624                        Message.Hide();
625
626                        //Caso o captcha foi ativado depois que o usuário já estava com a página carregada.
627                        if (typeof reloadCaptcha === "undefined") {
628                            window.location.href += (window.location.href.indexOf("?") == -1 ? "?" : "&") + Date.parse(new Date());
629                        } else {
630                            reloadCaptcha(txt_captcha_cad, true);
631                        }
632                    };
633                } else if (res.value == 6) {
634                    msgRetorno = "Não foi possível concluir o cadastro. O documento informado é invalido.";
635                } else if (res.value == 7) {
636                    msgRetorno = "Não foi possível concluir o cadastro. A senha informada não atende aos requisitos de segurança.";
637                }
638
639                Message.Show(MessageIcon.Warning, MessageButtons.Ok, msgRetorno, action);
640            }
641            else {
642                Message.Show(MessageIcon.Warning, MessageButtons.Ok, "Ocorreu um erro ao realizar o cadastro, por favor tente novamente em alguns minutos, se o problema persistir entre em contato com o suporte técnico.");
643            }
644        });
645    };
646
647    this.PortalFacil.Valida_Custom = function () {
648        var num_cnh = document.getElementById("num_cnh");
649        var isValidCustom = true;
650        var MsgValidacao = "Verifique os campos destacados em vermelho, os dados não foram informados corretamente.";
651        var sicCorrespondencia = sessionStorage.getItem("SicCorresp");
652
653        var lbl_tipoPessoa = document.getElementById("lbl_tipoPessoa");
654        lbl_tipoPessoa.style.color = "rgb(0, 0, 0)";
655        lbl_nuDocumento.style.color = "rgb(0, 0, 0)";
656        lbl_nmcompleto.style.color = "rgb(0, 0, 0)";
657        lbl_prefixoCelular.style.color = "rgb(0, 0, 0)";
658        lbl_nuCelular.style.color = "rgb(0, 0, 0)";
659        document.getElementById("lbl_nmResponsavel").style.color = "rgb(0, 0, 0)";
660        lbl_mail.style.color = "rgb(0, 0, 0)";
661        document.getElementById("lbl_senha").style.color = "rgb(0, 0, 0)";
662        document.getElementById("lbl_confirmaSenha").style.color = "rgb(0, 0, 0)";
663        lbl_dtnascimento.style.color = "rgb(0,0,0)";
664        lbl_nacionalidade.style.color = "rgb(0,0,0)";
665        lbl_naturalidade.style.color = "rgb(0,0,0)";
666        lbl_sexo.style.color = "rgb(0,0,0)";
667        lbl_cep.style.color = "rgb(0,0,0)";
668        lbl_pais.style.color = "rgb(0,0,0)";
669        lbl_estado.style.color = "rgb(0,0,0)";
670        lbl_municipio.style.color = "rgb(0,0,0)";
671        lbl_estado2.style.color = "rgb(0,0,0)";
672        lbl_municipio2.style.color = "rgb(0,0,0)";
673
674        //Verifica se escolheu o tipo de pessoa
675        if ((!rdb_pf.checked) && (!rdb_pj.checked)) {
676            lbl_tipoPessoa.style.color = "rgb(250, 0, 0)";
677            isValidCustom = false;
678        }
679
680        if (txt_nuDocumento.value.trim() == "" || !ValidarDocumento(txt_nuDocumento, rdb_pf.checked)) {
681            lbl_nuDocumento.style.color = "rgb(250, 0, 0)";
682            isValidCustom = false;
683        }
684
685        if (nminternauta.value.trim() == "") {
686            lbl_nmcompleto.style.color = "rgb(250, 0, 0)";
687            isValidCustom = false;
688        }
689
690        if (rdb_pj.checked) {
691            if (document.getElementById("txt_nmResponsavel").value == "") {
692                document.getElementById("lbl_nmResponsavel").style.color = "rgb(250, 0, 0)";
693                isValidCustom = false;
694            }
695        }
696
697        if (!isEmail(edmail.value.trim())) {
698            lbl_mail.style.color = "rgb(250, 0, 0)";
699            isValidCustom = false;
700        }
701
702        if (nudddcelular.value.trim() == "") {
703            lbl_prefixoCelular.style.color = "rgb(250, 0, 0)";
704            isValidCustom = false;
705        }
706
707        if (nucelular.value.trim() == "") {
708            lbl_nuCelular.style.color = "rgb(250, 0, 0)";
709            isValidCustom = false;
710        }
711
712        var senhaInformada = document.getElementById("dssenha").value.trim();
713
714        if (!window.isEdicaoCadastro && senhaInformada == "") {
715            document.getElementById("lbl_senha").style.color = "rgb(250, 0, 0)";
716            document.getElementById("lbl_confirmaSenha").style.color = "rgb(250, 0, 0)";
717            isValidCustom = false;
718        }
719        else if (senhaInformada != "") {
720            if (document.getElementById("dssenha").value != document.getElementById("dsConfirmaSenha").value) {
721                document.getElementById("lbl_senha").style.color = "rgb(250, 0, 0)";
722                document.getElementById("lbl_confirmaSenha").style.color = "rgb(250, 0, 0)";
723                isValidCustom = false;
724            }
725            else {
726                /* A politica de senha e do servidor (PasswordPolicy) e e reaplicada la no Save;
727                   a chamada aqui serve so para o cidadao ver o motivo antes de enviar. */
728                var msgSenha = int_cad.ValidarPoliticaSenha(senhaInformada, nminternauta.value, edmail.value).value;
729                if (msgSenha) {
730                    document.getElementById("lbl_senha").style.color = "rgb(250, 0, 0)";
731                    /* O motivo vai em MsgValidacao: o Message.Show do fim da funcao
732                       sobrescreve qualquer aviso exibido aqui dentro. */
733                    MsgValidacao = msgSenha;
734                    isValidCustom = false;
735                }
736            }
737        }
738
739        var isSic = hdf_redir.value == "sic_cad.aspx" || hdf_redir.value == "sic_pag.aspx" || hdf_redir.value == "sic_lis.aspx";
740
741        if (rdb_pf.checked) {
742            if (hdf_stDadosPessoais.value == "True" && ((isSic == true && hdf_stTornaCamposInternautaOpcionaisSic.value != "True") || isSic == false)) {
743                if (dtnascimento.value.trim() == "") {
744                    lbl_dtnascimento.style.color = "rgb(250,0,0)";
745                    isValidCustom = false;
746                }
747
748                if (cdnacionalidade.value == "-1") {
749                    lbl_nacionalidade.style.color = "rgb(250,0,0)";
750                    isValidCustom = false;
751                }
752
753                if (nmnaturalidade.value.trim() == "") {
754                    lbl_naturalidade.style.color = "rgb(250,0,0)";
755                    isValidCustom = false;
756                }
757
758                if (dmsexo.value == "" || dmsexo.value == "-1") {
759                    lbl_sexo.style.color = "rgb(250,0,0)";
760                    isValidCustom = false;
761                }
762            }
763        }
764
765        if (hdf_stDadosPessoais.value == "True") {
766            //Valida CNH, exigindo que pelo menos uma categoria seja selecionada
767            if (num_cnh && INT_CAD.trim(num_cnh.value).length > 0) {
768                var isValidCategoria = false;
769
770                INT_CAD.each(document.getElementsByName("cdcategoriacnh"), function () {
771                    if (this.checked === true) {
772                        isValidCategoria = true;
773                        return true; //break loop
774                    }
775                }, function () {
776                    if (!isValidCategoria) {
777                        INT_CAD.each(document.getElementsByName("cdcategoriacnh"), function () {
778                            this.parentNode.getElementsByTagName("span")[0].style.color = "rgb(255, 0, 0)";
779                        });
780                        isValidCustom = false;
781                    } else {
782                        INT_CAD.each(document.getElementsByName("cdcategoriacnh"), function () {
783                            this.parentNode.getElementsByTagName("span")[0].style.color = "rgb(0, 0, 0)";
784                        });
785                    }
786                });
787            }
788        }
789
790        if (hdf_stEndereco.value == "True" && ((isSic == true && hdf_stTornaCamposInternautaOpcionaisSic.value != "True") || isSic == false)) {
791            var numeroCEP = nucep.value.replace(/\D/g, '')
792            if (numeroCEP != '' && numeroCEP.length != 8) {
793                lbl_cep.style.color = "rgb(250,0,0)";
794                isValidCustom = false;
795            }
796
797            if (cdpais.value == "-1") {
798                lbl_pais.style.color = "rgb(250,0,0)";
799                isValidCustom = false;
800            }
801
802            if (cdpais.value == 1) {
803                if (cduf.value == "-1" || cduf.value == "") {
804                    lbl_estado.style.color = "rgb(250,0,0)";
805                    isValidCustom = false;
806                }
807                if (cdmunicipio.value == "-1") {
808                    lbl_municipio.style.color = "rgb(250,0,0)";
809                    isValidCustom = false;
810                }
811            }
812            else {
813                if (nmestadoexterior.value.trim() == "") {
814                    lbl_estado2.style.color = "rgb(250,0,0)";
815                    isValidCustom = false;
816                }
817                if (nmmunicipioexterior.value.trim() == "") {
818                    lbl_municipio2.style.color = "rgb(250,0,0)";
819                    isValidCustom = false;
820                }
821            }
822
823            if (sicCorrespondencia == "true" && hdf_redir.value == "sic_cad.aspx") {
824                if (nucep.value.trim() == "") {
825                    lbl_cep.style.color = "rgb(250, 0, 0)";
826                    isValidCustom = false;
827                }
828
829                var numeroCEP = nucep.value.replace(/\D/g, '')
830                if (numeroCEP != '' && numeroCEP.length != 8) {
831                    lbl_cep.style.color = "rgb(250, 0, 0)";
832                    isValidCustom = false;
833                }
834
835                if (nmbairro.value == "") {
836                    lbl_bairro.style.color = "rgb(250, 0, 0)";
837                    isValidCustom = false;
838                }
839
840                if (cdlogradourotipo.value == "-1") {
841                    lbl_tipo_logradouro.style.color = "rgb(250, 0, 0)";
842                    isValidCustom = false;
843                }
844
845                if (nmlogradouro.value.trim() == "") {
846                    lbl_logradouro.style.color = "rgb(250, 0, 0)";
847                    isValidCustom = false;
848                }
849
850                if (dsnumeroresidencia.value.trim() == "") {
851                    lbl_numero.style.color = "rgb(250, 0, 0)";
852                    isValidCustom = false;
853                }
854            }
855        }
856
857        var ckbAutorizacaoDados = false;
858        var lgpd = document.getElementById("pnlLGPD");
859        if (lgpd != null) {
860            var ckbAutorizacaoDados = document.getElementById('ckbAutorizacaoDados');
861
862            if (!ckbAutorizacaoDados.checked) {
863                MsgValidacao = "Esta página requer a autorização do uso dos dados pessoais.";
864                isValidCustom = false;
865            }
866        }
867
868        if (!isValidCustom) {
869            Message.Show(MessageIcon.Warning
870                , MessageButtons.Ok
871                , MsgValidacao
872                , MessageAction.Cancel);
873        }
874
875        return isValidCustom;
876    };
877
878    //Extende a classe String
879    String.prototype.toDate = function () {
880        data = this;
881        var formatoValido = /[0-9]{2}\/[0-9]{2}\/[0-9]{4}/;
882        var valido = false;
883        if (!formatoValido.test(data))
884            return false;
885        else {
886            var arD = data.split("/");
887            var dia = arD[0];
888            var mes = arD[1];
889            var ano = arD[2];
890            var MyData = Convert.ToDate(data, "dd/MM/yyyy");
891            if ((MyData.getMonth() + 1 != mes) || (MyData.getDate() != dia) || (MyData.getFullYear() != ano))
892                return false;
893            else
894                return MyData;
895        }
896
897    };
898
899    //Extende a classe Date
900    Date.prototype.toDDMMYY = function () {
901        return Convert.ToString(this, "dd/MM/yyyy");
902    };
903
904    //Extende a classe Array
905    Array.prototype.contains = function (element) {
906        for (var i = 0; i < this.length; i++) {
907            if (this[i] == element) {
908                return true;
909            }
910        }
911        return false;
912    };
913
914    var btSenha = document.getElementById("bt_senha");
915    if (btSenha) {
916        btSenha.onclick = function () {
917            var txt_captcha_rec_sen = document.getElementById("txt_captcha_rec_sen"),
918                isEnabledCaptcha = txt_captcha_rec_sen && txt_captcha_rec_sen.Captcha ? true : false, indefinido;
919
920            //Processa dados
921            function callback(validateItemCollection, validationResult, isValid) {
922                var dadosCaptcha = {
923                    captchaid: isEnabledCaptcha ? txt_captcha_rec_sen.Captcha.Id : "",
924                    instanceid: isEnabledCaptcha ? txt_captcha_rec_sen.Captcha.InstanceId : "",
925                    userinput: isEnabledCaptcha ? txt_captcha_rec_sen.value : ""
926                };
927
928                if (isValid) {
929                    int_cad.recupera_senha(txt_idUsuario_rec_sen.value, dadosCaptcha, function (res) {
930                        var codigo = null,
931                            message = "",
932                            action = new MessageAction(),
933                            icon = null;
934
935                        if (res.error == null) {
936                            if (isEnabledCaptcha) {
937                                if (typeof reloadCaptcha === "undefined") {
938                                    window.location.href += (window.location.href.indexOf("?") == -1 ? "?" : "&") + Date.parse(new Date());
939                                } else {
940                                    reloadCaptcha(this.txt_captcha_rec_sen, true);
941                                }
942                            }
943
944                            codigo = res.value.Codigo;
945                            message = res.value.Mensagem;
946                            switch (codigo) {
947                                case 1:
948                                    if (hdf_redir.value != "-1")
949                                        action.Ok = function () { window.location = "int_cad.aspx?redir=" + hdf_redir.value; };
950                                    else
951                                        action.Ok = function () { window.location = "int_cad.aspx"; };
952
953                                    icon = MessageIcon.Information;
954                                    break;
955                                default:
956                                    action.Ok = function () { Message.Hide(); };
957                                    icon = MessageIcon.Error;
958                                    break;
959                            }
960                        } else {
961                            //Erro a nível de server-side.
962                            message = "Não foi possível recuperar a senha neste momento. Por favor, tente novamente mais tarde.";
963                            action.Ok = function () { Message.Hide(); };
964                            icon = MessageIcon.Error;
965                        }
966                        Message.Show(icon, MessageButtons.Ok, message, action);
967                    });
968                }
969            }
970
971            Validate(indefinido,
972                {
973                    durante: isEnabledCaptcha ? formatarValidacao : (new Function()),
974                    depois: callback
975                });
976        };
977    }
978
979    var btlogin = document.getElementById("bt_login");
980    if (btlogin) {
981        btlogin.onclick = function () {
982            lbl_idUsuario.style.color = "rgb(0, 0, 0)";
983            lbl_dsSenha.style.color = "rgb(0, 0, 0)";
984
985            var txt_captcha_login = document.getElementById("txt_captcha_login"),
986                isEnabledCaptcha = txt_captcha_login && txt_captcha_login.Captcha ? true : false, indef
986inido;
987
988            var dadosCaptcha = {
989                captchaid: isEnabledCaptcha ? txt_captcha_login.Captcha.Id : "",
990                instanceid: isEnabledCaptcha ? txt_captcha_login.Captcha.InstanceId : "",
991                userinput: isEnabledCaptcha ? txt_captcha_login.value : ""
992            };
993
994            int_cad.efetuar_login(txt_idUsuario.value.trim(), txt_dsSenha.value.trim(), dadosCaptcha, function (res) {
995                if (res.error == null) {
996                    var codigo = res.value.Codigo,
997                        emsg = res.value.Mensagem,
998                        action = new MessageAction(),
999                        icon = null;
1000
1001                    if (codigo == 1) {
1002                        if (emsg && emsg.indexOf("REQUIRES_2FA:") === 0) {
1003                            var parts = emsg.replace("REQUIRES_2FA:", "").split("|");
1004                            
1005                            var errorExtra = parts.length > 1 ? parts[1] : "";
1006
1007                            $("#fds_dados_login").addClass('hide').hide();
1008                            $("#fds_recuperar_senha").addClass('hide').hide();
1009                            $("#fds_2fa").removeClass('hide').show();
1010                            resetDigits2FA();
1011                            startResendTimer2FA();
1012
1013                            if (errorExtra) {
1014                                Message.Show(MessageIcon.Error, MessageButtons.Ok, errorExtra, action);
1015                            }
1016                            return;
1017                        }
1018                        var contexto = "";
1019                        if (typeof (redir) == "string")
1020                            contexto = redir;
1021                        else
1022                            contexto = "int_cad.aspx";
1023
1024                        var isCadastroCompleto = int_cad.isCadastroCompleto(contexto).value;
1025
1026                        if (isCadastroCompleto.length == 0) {
1027                            if (typeof (redir) == "string") {
1028                                if (redir == "uc_enquete.aspx" || redir == "uc_comentario.aspx")
1029                                    location = "default.aspx";
1030                                else
1031                                    location = redir;
1032                            }
1033                            else {
1034                                if (int_cad.IsAreaInternautaEnable().value == true)
1035                                    location = "int_pag.aspx";
1036                                else if (int_cad.IsRedirectPagPrincipalEnable().value == true)
1037                                    location = "principal"; // FLAG AMIGO MICRO QUE DIRECIONA PARA PAGINA INICIAL
1038                                else
1039                                    location = "int_cad.aspx?formtype=1";
1040                            }
1041                        }
1042                        else {
1043                            emsg = "Identificamos que o seu cadastro está desatualizado para a ação desejada e deve ser completado. Clique em \"OK\" para ser redirecionado à página de cadastro do internauta, onde deverão ser preenchidos os campos obrigatórios. Ao término, o sistema retornará à página de origem."
1044
1045                            if (typeof (redir) == "string")
1046                                action.Ok = function () { window.location = "int_cad.aspx?formtype=1&redir=" + redir; };
1047                            else
1048                                action.Ok = function () { window.location = "int_cad.aspx?formtype=1" };
1049
1050                            if (typeof (redir) == "string")
1051                                if (redir == "sic_pag")
1052                                    emsg = "Devido às exigências da legislação em relação ao controle das estatísticas de Solicitação de Informação, seu cadastro deve ser completado. Portanto, ao clicar em \"OK\" você será redirecionado para a página de cadastro do internauta onde deverá preencher os campos obrigatórios. Ao término, o sistema retornará à esta página de origem.";
1053
1054                            icon = MessageIcon.Information;
1055                            Message.Show(icon, MessageButtons.Ok, emsg, action);
1056                        }
1057                    }
1058                    else {
1059                        switch (codigo) {
1060                            case 3:
1061                                action.Ok = function () { Message.Hide(); };
1062                                icon = MessageIcon.Error;
1063                                lbl_idUsuario.style.color = "rgb(250, 0, 0)";
1064                                lbl_dsSenha.style.color = "rgb(250, 0, 0)";
1065                                break;
1066                            case 4:
1067                                action.Ok = function () { Message.Hide(); };
1068                                icon = MessageIcon.Error;
1069                                lbl_idUsuario.style.color = "rgb(250, 0, 0)";
1070                                lbl_dsSenha.style.color = "rgb(250, 0, 0)";
1071                                break;
1072                            case 5:
1073                                action.Ok = function () { window.location = "ate_env.aspx"; };
1074                                action.Cancel = function () { Message.Hide(); };
1075                                emsg = "Não foi possível efetuar o login, pois seu usuário está bloqueado no sistema. Caso você queira ser desbloqueado, clique em OK para entrar em contato conosco.";
1076                                icon = MessageIcon.Error;
1077                                break;
1078                            case 7:
1079                                action.Ok = function () { Message.Hide(); };
1080                                icon = MessageIcon.Error;
1081                                lbl_idUsuario.style.color = "rgb(0, 0, 0)";
1082                                lbl_dsSenha.style.color = "rgb(0, 0, 0)";
1083                                break;
1084                            default:
1085                                action.Ok = function () { Message.Hide(); };
1086                                icon = MessageIcon.Error;
1087                                break;
1088                        }
1089
1090                        if (codigo == 5)
1091                            Message.Show(icon, MessageButtons.OkCancel, emsg, action);
1092                        else
1093                            Message.Show(icon, MessageButtons.Ok, emsg, action);
1094                    }
1095                }
1096                else {
1097                    var action = new MessageAction(); action.Ok = function () { Message.Hide(); };
1098                    action.Ok = function () { Message.Hide(); };
1099                    Message.Show(MessageIcon.Error, MessageButtons.Ok, "Não foi possível efetuar o login neste momento. Por favor, tente novamente mais tarde.", action);
1100                }
1101            });
1102        };
1103    }
1104})();
1105
1106function carregaDadosInternauta() {
1107    if (hdf_cdinternauta.value != "-1") {
1108        var internauta = int_cad.carregaDadosInternauta(),
1109            o = internauta.value;
1110
1111        var div_info_cad_internauta = document.getElementById("div_info_cad_internauta");
1112
1113        if (internauta.value.STCADASTROATUALIZADO == false) {
1114            var parag = document.createElement("p");
1115            parag.appendChild(document.createTextNode("Atualize o seu cadastro ou confirme os seus dados caso estejam atualizados."));
1116            div_info_cad_internauta.appendChild(parag);
1117            div_info_cad_internauta.style.display = "block";
1118        }
1119        else {
1120            div_info_cad_internauta.style.display = "none";
1121        }
1122
1123        switch (internauta.value.DMTIPOUSUARIO) {
1124            case 1:
1125                rdb_pf.checked = true;
1126                rdb_pj.checked = false;
1127                MostraTipoPessoa("f", hdf_stTelefones.value, hdf_stDadosPessoais.value, hdf_stDocPessoais.value, hdf_stDadosCNH.value, hdf_stEndereco.value, hdf_stDadosLicitacao.value);
1128                break;
1129            case 2:
1130                rdb_pf.checked = false;
1131                rdb_pj.checked = true;
1132                MostraTipoPessoa("j", hdf_stTelefones.value, hdf_stDadosPessoais.value, hdf_stDocPessoais.value, hdf_stDadosCNH.value, hdf_stEndereco.value, hdf_stDadosLicitacao.value);
1133                break;
1134        }
1135
1136        if (internauta.value.IMAGEM.cdImagem != -1) {
1137            hdf_cdImagem.value = internauta.value.IMAGEM.cdImagem == null ? "-1" : internauta.value.IMAGEM.cdImagem;
1138            hdf_idImagem.value = internauta.value.IMAGEM.idImagem == null ? "" : internauta.value.IMAGEM.idImagem;
1139            hdf_nmImagemExtensao.value = internauta.value.IMAGEM.nmImagemExtensao == null ? "" : internauta.value.IMAGEM.nmImagemExtensao;
1140            hdf_nuAlturaImagem.value = internauta.value.IMAGEM.nuAltura == null ? "0" : internauta.value.IMAGEM.nuAltura;
1141            hdf_nuLarguraImagem.value = internauta.value.IMAGEM.nuLargura == null ? "0" : internauta.value.IMAGEM.nuLargura;
1142            hdf_nuTamanhoImagem.value = internauta.value.IMAGEM.nuTamanho == null ? "0" : internauta.value.IMAGEM.nuTamanho;
1143            $("#img_cdImagem").attr("src", "/img_hdl.ashx?dmLocal=2&width=90&height=90")
1144        }
1145
1146        if (internauta.value.ISVALIDDOCIDENTIFICADOR === 1) {
1147            txt_nuDocumento.setAttribute("readonly", "readonly");
1148            INT_CAD.each(document.getElementsByName("dmtipousuario"), function () {
1149                this.setAttribute("disabled", "disabled");
1150            })
1151        }
1152
1153        //Documento
1154        var
1155            idList = (o.DMTIPOUSUARIO === 1 ? INT_CAD.idListPF : INT_CAD.idListPJ).replace(/(\.|#)/g, "")
1156            , contexto = document.getElementById(idList)
1157            , btnAddDoc = document.getElementById("bt_add_documento")
1158            , cddocumentotipo, nudocumento;
1159
1160        for (var i = 0; i < o.INTERNAUTA_DOCUMENTOTIPO.length; i++) {
1161            if (o.INTERNAUTA_DOCUMENTOTIPO[i].INTERNAUTA_DOCUMENTOTIPO_CATEGORIACNH.length == 0) {
1162
1163                btnAddDoc.onclick();
1164
1165                cddocumentotipo = INT_CAD.get(".cddocumentotipo", contexto);
1166                nudocumento = INT_CAD.get(".txt_documento", contexto);
1167
1168                INT_CAD.usageDoc(o.INTERNAUTA_DOCUMENTOTIPO[i].CDDOCUMENTOTIPO, true);
1169
1170                cddocumentotipo[cddocumentotipo.length - 1].value = o.INTERNAUTA_DOCUMENTOTIPO[i].CDDOCUMENTOTIPO;
1171                cddocumentotipo[cddocumentotipo.length - 1].prev = {};
1172                cddocumentotipo[cddocumentotipo.length - 1].prev.v = o.INTERNAUTA_DOCUMENTOTIPO[i].CDDOCUMENTOTIPO;
1173                cddocumentotipo[cddocumentotipo.length - 1].prev.i = cddocumentotipo[cddocumentotipo.length - 1].selectedIndex;
1174                cddocumentotipo[cddocumentotipo.length - 1].options[cddocumentotipo[cddocumentotipo.length - 1].selectedIndex].setAttribute("data-cddocumentotipo", o.INT
1174ERNAUTA_DOCUMENTOTIPO[i].CDINTERNAUTA_DOCUMENTOTIPO);
1175
1176
1177                nudocumento[nudocumento.length - 1].value = o.INTERNAUTA_DOCUMENTOTIPO[i].NUDOCUMENTO;
1178
1179            }
1180            else {
1181                document.getElementById("num_cnh").value = o.INTERNAUTA_DOCUMENTOTIPO[i].NUDOCUMENTO;
1182
1183                var ar_cdcategoriacnh = document.getElementsByName("cdcategoriacnh", "input");
1184                var yt = ar_cdcategoriacnh.length;
1185
1186                for (var y = 0; y < yt; y++) {
1187                    if (o.INTERNAUTA_DOCUMENTOTIPO[i].INTERNAUTA_DOCUMENTOTIPO_CATEGORIACNH.contains(ar_cdcategoriacnh[y].value)) {
1188                        ar_cdcategoriacnh[y].checked = true;
1189                    }
1190                    else {
1191                        ar_cdcategoriacnh[y].checked = false;
1192                    }
1193                }
1194
1195            }
1196        }
1197
1198        INT_CAD.toggleBtnAddDocs();
1199
1200        edmail.setAttribute("readonly", "readonly");
1201        div_dados_cadastro.Visible = true;
1202
1203        document.getElementById("txt_nuDocumento").value = (internauta.value.NUDOCUMENTO == null) ? "" : internauta.value.NUDOCUMENTO;
1204
1205        function FormatString(objeto, sMask) {
1206            var i, nCount, sValue, fldLen, mskLen, bolMask, sCod;
1207
1208            sValue = objeto.value;
1209
1210            // Limpa todos os caracteres de formatação que
1211            // já estiverem no campo.
1212            sValue = sValue.toString().replace(":", "");
1213            sValue = sValue.toString().replace(":", "");
1214            sValue = sValue.toString().replace("-", "");
1215            sValue = sValue.toString().replace("-", "");
1216            sValue = sValue.toString().replace(".", "");
1217            sValue = sValue.toString().replace(".", "");
1218            sValue = sValue.toString().replace("/", "");
1219            sValue = sValue.toString().replace("/", "");
1220            sValue = sValue.toString().replace("(", "");
1221            sValue = sValue.toString().replace("(", "");
1222            sValue = sValue.toString().replace(")", "");
1223            sValue = sValue.toString().replace(")", "");
1224            sValue = sValue.toString().replace(" ", "");
1225            sValue = sValue.toString().replace(" ", "");
1226            sValue = sValue.toString().replace(",", "");
1227            fldLen = sValue.length;
1228            mskLen = sMask.length;
1229
1230            i = 0;
1231            nCount = 0;
1232            sCod = "";
1233            mskLen = fldLen;
1234
1235            while (i <= mskLen) {
1236                bolMask = ((sMask.charAt(i) == ":") || (sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
1237                bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ") || (sMask.charAt(i) == ","))
1238
1239                if (bolMask) {
1240                    sCod += sMask.charAt(i);
1241                    mskLen++;
1242                } //if
1243                else {
1244                    sCod += sValue.charAt(nCount);
1245                    nCount++;
1246                } //Fim do else
1247                i++;
1248            } //Fim do while
1249
1250            objeto.value = sCod;
1251        }
1252
1253
1254        if (o.DMTIPOUSUARIO === 1) {
1255            FormatString(document.getElementById("txt_nuDocumento"), '999.999.999-99');
1256        } else if (o.DMTIPOUSUARIO === 2) {
1257            FormatString(document.getElementById("txt_nuDocumento"), '99.999.999/9999-99')
1258        }
1259
1260        nminternauta.value = (internauta.value.NMINTERNAUTA == null) ? "" : internauta.value.NMINTERNAUTA;
1261        txt_nmResponsavel.value = (internauta.value.NMRESPONSAVEL == null) ? "" : internauta.value.NMRESPONSAVEL;
1262        edmail.value = (internauta.value.EDEMAIL == null) ? "" : internauta.value.EDEMAIL;
1263        nudddtelefone.value = (internauta.value.NUDDDTELEFONE == null) ? "" : internauta.value.NUDDDTELEFONE;
1264        nutelefone.value = (internauta.value.NUTELEFONE == null) ? "" : internauta.value.NUTELEFONE;
1265        nuramal.value = (internauta.value.NURAMAL == null) ? "" : internauta.value.NURAMAL;
1266        nudddcelular.value = (internauta.value.NUDDDCELULAR == null) ? "" : internauta.value.NUDDDCELULAR;
1267        nucelular.value = (internauta.value.NUCELULAR == null) ? "" : internauta.value.NUCELULAR;
1268        /* A senha nao volta mais do servidor: o banco guarda apenas o hash PBKDF2. Na edicao os
1269           campos ficam em branco e a senha so muda se o cidadao preencher os dois. */
1270        window.isEdicaoCadastro = true;
1271        dssenha.value = "";
1272        dsConfirmaSenha.value = "";
1273
1274        if (int_cad.IsEnableNewsletter().value) {
1275            if (internauta.value.ISPOSSUINEWSLETTER)
1276                $('#chk_receber_newsletter').prop('checked', true);
1277            else
1278                $('#chk_receber_newsletter').prop('checked', false);
1279        }
1280
1281        //Dados Pessoais
1282        dtnascimento.value = (internauta.value.DADOPESSOAL.dtNascimento == null) ? "" : internauta.value.DADOPESSOAL.dtNascimento.toDDMMYY();
1283        cdnacionalidade.value = internauta.value.DADOPESSOAL.cdNacionalidade;
1284        nmnaturalidade.value = (internauta.value.DADOPESSOAL.nmNaturalidade == null) ? "" : internauta.value.DADOPESSOAL.nmNaturalidade;
1285        dmestadocivil.value = internauta.value.DADOPESSOAL.dmEstadoCivil;
1286        dmsexo.value = internauta.value.DADOPESSOAL.dmSexo;
1287        chk_pcd.checked = (internauta.value.DADOPESSOAL.stPcd == null) ? false : internauta.value.DADOPESSOAL.stPcd;
1288
1289
1290
1291        //Dados endereço
1292        cdpais.value = internauta.value.DADOPOSTAL.cdPais;
1293
1294        cdpais.onchange();
1295
1296        cduf.value = internauta.value.DADOPOSTAL.cdUF;
1297
1298        if (cduf.value != "") {
1299
1300            cduf.onchange(
1301                function () {
1302                    cdmunicipio.value = (internauta.value.DADOPOSTAL.cdMunicipio == null) ? "-1" : internauta.value.DADOPOSTAL.cdMunicipio;
1303                    //cdmunicipio.onchange();
1304                });
1305        }
1306
1307        nmestadoexterior.value = (internauta.value.DADOPOSTAL.nmEstadoExterior == null) ? "" : internauta.value.DADOPOSTAL.nmEstadoExterior;
1308        nmmunicipioexterior.value = (internauta.value.DADOPOSTAL.nmMunicipioExterior == null) ? "" : internauta.value.DADOPOSTAL.nmMunicipioExterior;
1309        //cdbairro.value = internauta.value.DADOPOSTAL.cdBairro;
1310        nmbairro.value = (internauta.value.DADOPOSTAL.nmBairro == null) ? "" : internauta.value.DADOPOSTAL.nmBairro;
1311        cdlogradourotipo.value = internauta.value.DADOPOSTAL.cdLogradouroTipo;
1312        nmlogradouro.value = (internauta.value.DADOPOSTAL.nmLogradouro == null) ? "" : internauta.value.DADOPOSTAL.nmLogradouro;
1313        dsnumeroresidencia.value = (internauta.value.DADOPOSTAL.dsNumeroResidencia == null) ? "" : internauta.value.DADOPOSTAL.dsNumeroResidencia;
1314        nucep.value = (internauta.value.DADOPOSTAL.nuCEP == null) ? "" : internauta.value.DADOPOSTAL.nuCEP;
1315        dscomplemento.value = (internauta.value.DADOPOSTAL.dsComplemento == null) ? "" : internauta.value.DADOPOSTAL.dsComplemento;
1316
1317        try {
1318
1319            if (cdpais.value == null || cdpais.value == "") {
1320                //Ao incluir seleciona o Brasil
1321                cdpais.value = 1;
1322                //cdpais.onchange();
1323
1324                nmestadoexterior.style.display = "none";
1325                document.getElementById("estado2").style.display = "none";
1326                nmmunicipioexterior.style.display = "none";
1327                document.getElementById("municipio2").style.display = "none";
1328                cduf.style.display = "";
1329                document.getElementById("estado1").style.display = "";
1330                cdmunicipio.style.display = "";
1331                document.getElementById("municipio1").style.display = "";
1332            }
1333        } catch (e) {
1334
1335        }
1336
1337        $("#ddl_cdLicitacaoCategoria").val(internauta.value.INTERNAUTA_LICITACAOCATEGORIA).trigger("change");
1338    }
1339    else {
1340
1341        try {
1342            //Ao incluir seleciona o Brasil
1343            cdpais.value = 1;
1344            //cdpais.onchange();
1345
1346            nmestadoexterior.style.display = "none";
1347            document.getElementById("estado2").style.display = "none";
1348            nmmunicipioexterior.style.display = "none";
1349            document.getElementById("municipio2").style.display = "none";
1350            cduf.style.display = "";
1351            document.getElementById("estado1").style.display = "";
1352            cdmunicipio.style.display = "";
1353            document.getElementById("municipio1").style.display = "";
1354        } catch (e) {
1355
1356        }
1357
1358        var div_info_cad_internauta = document.getElementById("div_info_cad_internauta");
1359        if (div_info_cad_internauta)
1360            div_info_cad_internauta.style.display = "none";
1361    }
1362}
1363
1364//Trata click no botão dmTipoUsuario
1365function MostraTipoPessoa(tipo, stTelefone, stDadosPessoais, stDocPessoais, stDadosCNH, stEndereco, stDadosLicitacao) {
1366
1367    INT_CAD.alternateDocumentType(tipo);
1368
1369    if (tipo == "f") {
1370        document.getElementById("div_dados_cadastro").style.display = "block";
1371        //if (stTelefone == "False") {
1372        //    document.getElementById("div_telefones").style.display = "none";
1373        //    document.getElementById("div_celular").style.display = "none";
1374        //}
1375
1376        if (stDadosPessoais == "True") {
1377            document.getElementById("fds_dados_pessoais").style.display = "block";
1378        }
1379        else {
1380            document.getElementById("fds_dados_pessoais").style.display = "none";
1381        }
1382
1383        if (stDocPessoais == "True") {
1384            document.getElementById("fds_documentos_pessoais").style.display = "block";
1385        }
1386        else {
1387            document.getElementById("fds_documentos_pessoais").style.display = "none";
1388        }
1389
1390        var categoria_cnh = document.getElementById("categoria_cnh");
1391        if (categoria_cnh) {
1392            categoria_cnh.style.display = (stDadosCNH == "True" ? "block" : "none");
1393        }
1394
1395        if (stEndereco == "True") {
1396            document.getElementById("fds_dados_postais").style.display = "block";
1397        }
1398        else {
1399            document.getElementById("fds_dados_postais").style.display = "none";
1400        }
1401
1402        if (stDadosLicitacao == "True") {
1403            document.getElementById("fds_categorias_licitacao").style.display = "block";
1404        }
1405        else {
1406            document.getElementById("fds_categorias_licitacao").style.display = "none";
1407        }
1408
1409        document.getElementById("nmResponsavel").style.display = "none";
1410
1411        document.getElementById("lbl_nuDocumento").innerHTML = "CPF:";
1412        document.getElementById("lbl_nmcompleto").innerHTML = "Nome Completo:";
1413
1414        document.getElementById("rdb_pj").checked = false;
1415        document.getElementById("rdb_pf").checked = true;
1416
1417        rdb_pf.onchange = function () {
1418            txt_nuDocumento.setAttribute("maxLength", 14);
1419
1420            if (window.ActiveXObject) {
1421                txt_nuDocumento.onkeypress = function () {
1422                    return ApplyMask(this, "999.999.999-99", event);
1423                    //txt_nuDocumento.setAttribute("onkeypress", "ApplyMask(this, "999.999.999-99", event)");
1424                };
1425            }
1426            else {
1427                txt_nuDocumento.setAttribute("onkeypress", "ApplyMask(this, '999.999.999-99', event)");
1428            }
1429
1430            dtnascimento.setAttribute("maxLength", 10);
1431            if (window.ActiveXObject) {
1432                dtnascimento.onkeypress = function () {
1433                    return ApplyMask(this, "99/99/9999", event);
1434
1435                };
1436            }
1437            else {
1438                dtnascimento.setAttribute("onkeypress", "ApplyMask(this, '99/99/9999', event)");
1439            }
1440
1441            nucep.setAttribute("maxLength", 10);
1442            if (window.ActiveXObject) {
1443                nucep.onkeypress = function () {
1444                    return ApplyMask(this, "99.999-999", event);
1445                };
1446            }
1447            else {
1448                nucep.setAttribute("onkeypress", "ApplyMask(this, '99.999-999', event)");
1449            }
1450
1451
1452        };
1453        rdb_pf.onchange();
1454
1455
1456
1457    }
1458    else if (tipo == "j") {
1459        document.getElementById("div_dados_cadastro").style.display = "block";
1460
1461        //if (stTelefone == "False") {
1462        //    document.getElementById("div_telefones").style.display = "none";
1463        //    document.getElementById("div_celular").style.display = "none";
1464        //}
1465
1466        document.getElementById("fds_dados_pessoais").style.display = "none";
1467
1468        if (stDocPessoais == "True") {
1469            document.getElementById("fds_documentos_pessoais").style.display = "block";
1470        }
1471        else {
1472            document.getElementById("fds_documentos_pessoais").style.display = "none";
1473        }
1474
1475        if (document.getElementById("categoria_cnh") != null)
1476            document.getElementById("categoria_cnh").style.display = "none";
1477
1478        if (stEndereco == "True") {
1479            document.getElementById("fds_dados_postais").style.display = "block";
1480        }
1481        else {
1482            document.getElementById("fds_dados_postais").style.display = "none";
1483        }
1484
1485        if (stDadosLicitacao == "True") {
1486            document.getElementById("fds_categorias_licitacao").style.display = "block";
1487        }
1488        else {
1489            document.getElementById("fds_categorias_licitacao").style.display = "none";
1490        }
1491
1492        document.getElementById("nmResponsavel").style.display = "block";
1493        document.getElementById("lbl_nuDocumento").innerHTML = "CNPJ:";
1494
1495        document.getElementById("lbl_nmcompleto").innerHTML = "Razão Social:";
1496        document.getElementById("lbl_nmResponsavel").innerHTML = "Nome Responsável:";
1497
1498        document.getElementById("rdb_pj").checked = true;
1499        document.getElementById("rdb_pf").checked = false;
1500
1501        rdb_pj.onchange = function () {
1502            txt_nuDocumento.setAttribute("maxLength", 18);
1503            if (window.ActiveXObject) {
1504                txt_nuDocumento.onkeypress = function () {
1505                    return ApplyMask(this, "99.999.999/9999-99", event);
1506                };
1507
1508                nucep.setAttribute("maxLength", 10);
1509                if (window.ActiveXObject) {
1510                    nucep.onkeypress = function () {
1511                        return ApplyMask(this, "99.999-999", event);
1512                    };
1513                }
1514                else {
1515                    nucep.setAttribute("onkeypress", "ApplyMask(this, '99.999-999', event)");
1516                }
1517
1518            }
1519            else {
1520                txt_nuDocumento.setAttribute("onkeypress", "ApplyMask(this, '99.999.999/9999-99', event)");
1521            }
1522
1523        };
1524
1525    }
1526
1527
1528    /*nudddcelular.onchange =
1529        function ()
1530        {
1531            document.getElementById("nucelular").value = "";
1532
1533           
1534                nucelular.setAttribute("maxlength", 10);
1535                if (window.ActiveXObject)
1536                {
1537                    nucelular.onkeypress = function ()
1538                    {
1539                        return ApplyMask(this, "99999-9999", event);
1540                    };
1541                }
1542                else
1543                {
1544                    nucelular.setAttribute("onkeypress", "ApplyMask(this, '99999-9999', event)");
1545                } 
1546        };*/
1547
1548
1549    cascade();
1550
1551}
1552
1553function cascade() {
1554    var un = ["undefined", null, "null"];
1555
1556    //    document.getElementById("estado1").style.display = "none";
1557    //    document.getElementById("estado2").style.display = "none";
1558    //    document.getElementById("municipio1").style.display = "none";
1559    //    document.getElementById("municipio2").style.display = "none";
1560
1561
1562    /*if (!un.contains(typeof cdmunicipio))
1563    {
1564        cdmunicipio.onchange = function ()
1565        {
1566            if (this.value == 1)//Cidade do Cliente.
1567            {
1568                nmbairro.style.display = "none";
1569                document.getElementById("bairro2").style.display = "none";
1570                cdbairro.style.display = "";
1571                document.getElementById("bairro1").style.display = "";
1572                
1573
1574            }
1575            else
1576            {
1577                nmbairro.style.display = "";
1578                document.getElementById("bairro2").style.display = "";
1579                cdbairro.style.display = "none";
1580                document.getElementById("bairro1").style.display = "none";
1581            }
1582            return this;
1583        };
1584        cdmunicipio.onchange();
1585    }*/
1586
1587    if (!un.contains(typeof cduf)) {
1588        cduf.onchange = function () {
1589            //Propaga o escopo do parametros da função pai para
1590            //função filha para resolver um problema de escopo de var.
1591            int_cad.GetCidade(this.value, (function (parametros) {
1592                return function (res) {
1593                    if (res.error == null) {
1594                        var t = res.value.length;
1595                        var c = cdmunicipio.options.length;
1596
1597                        //var callback = cdmunicipio.onchange;
1598                        var selectParentNode = cdmunicipio.parentNode;
1599                        var newSelectObj = cdmunicipio.cloneNode(false); // Make a shallow copy
1600                        selectParentNode.replaceChild(newSelectObj, cdmunicipio);
1601
1602                        cdmunicipio = document.getElementById("cdmunicipio");
1603                        //cdmunicipio.onchange = callback;
1604                        cdmunicipio.options.add(new Option("Selecione", -1));
1605
1606                        /*if (!(t > 0))
1607                        {
1608                            cdmunicipio.onchange();
1609                            return;
1610                        }*/
1611
1612                        for (var i = 0; i < t; i++) {
1613                            cdmunicipio.options.add(
1614                                new Option(res.value[i].NMMUNICIPIO
1615                                    , res.value[i].CDMUNICIPIO)
1616                            );
1617                        }
1618                    }
1619                    if (parametros.length > 0 && typeof (parametros[0]) == "function") {
1620                        parametros[0]();
1621                    }
1622                }
1623            })(arguments));
1624        };
1625        //cduf.onchange();
1626        //cdmunicipio.onchange();
1627    }
1628
1629    if (!un.contains(typeof cdpais)) {
1630        cdpais.onchange = function () {
1631            if (this.value == 1)//Brasil
1632            {
1633                nmestadoexterior.style.display = "none";
1634                document.getElementById("estado2").style.display = "none";
1635                nmmunicipioexterior.style.display = "none";
1636                document.getElementById("municipio2").style.display = "none";
1637                cduf.style.display = "";
1638                document.getElementById("estado1").style.display = "";
1639                cdmunicipio.style.display = "";
1640                document.getElementById("municipio1").style.display = "";
1641            }
1642            else {
1643                nmestadoexterior.style.display = "";
1644                document.getElementById("estado2").style.display = "";
1645                nmmunicipioexterior.style.display = "";
1646                document.getElementById("municipio2").style.display = "";
1647                cduf.style.display = "none";
1648                document.getElementById("estado1").style.display = "none";
1649                cdmunicipio.style.display = "none";
1650                document.getElementById("municipio1").style.display = "none";
1651                cdmunicipio.value = -1;
1652                //cdmunicipio.onchange();
1653            }
1654        };
1655        //cdpais.onchange();
1656
1657    }
1658}
1659
1660function VerificaEmail() {
1661    var Internauta =
1662    {
1663        EDEMAIL: edmail.value
1664    }
1665
1666    PortalFacil.classe = Internauta;
1667
1668    var res = int_cad.VerificaEmail(PortalFacil.classe);
1669
1670    if (res.error == null) {
1671        var isValidCustom = true;
1672        var msgRetorno = "",
1673            action = new MessageAction();
1674
1675        action.Ok = function () {
1676            Message.Hide();
1677            edmail.focus();
1678            document.getElementById("lbl_mail").style.color = "rgb(250, 0, 0)";
1679            //edmail.value = "";
1680        };
1681        if (res.value == 1) {
1682            msgRetorno = "O e-mail informado já está cadastrado. É provável que você já tenha um cadastro. Se esqueceu a sua senha, recupere-a por meio da opção \"esqueci minha senha\" na tela de login.";
1683            isValidCustom = false;
1684        }
1685        else if (res.value == 0) {
1686            document.getEl
1686ementById("lbl_mail").style.color = "rgb(0, 0, 0)";
1687            isValidCustom = true;
1688        }
1689
1690
1691        if (!isValidCustom) {
1692            Message.Show(MessageIcon.Warning, MessageButtons.Ok, msgRetorno, action);
1693        }
1694        else {
1695            lbl_nuDocumento.style.color = "rgb(0, 0, 0)";
1696        }
1697    }
1698}
1699
1700function VerificaDocumento() {
1701
1702    var Internauta =
1703    {
1704        DMTIPOUSUARIO: (rdb_pf.checked) ? 1 : 2,
1705        NUDOCUMENTO: txt_nuDocumento.value
1706    };
1707
1708    PortalFacil.classe = Internauta;
1709
1710    var res = int_cad.VerificaDocumento(PortalFacil.classe);
1711
1712    if (res.error == null) {
1713
1714        var isValidCustom = true;
1715        var msgRetorno = "",
1716            action = new MessageAction();
1717
1718        //default action.Ok
1719        action.Ok = function () {
1720            Message.Hide();
1721            txt_nuDocumento.focus();
1722            document.getElementById("lbl_nuDocumento").style.color = "rgb(250, 0, 0)";
1723            //txt_nuDocumento.value = "";
1724        };
1725        if (res.value == 2) {
1726            msgRetorno = "O número de documento informado já está cadastrado. É provável que você já tenha um cadastro. Se esqueceu a sua senha, recupere-a por meio da opção \"esqueci minha senha\" na tela de login.";
1727            isValidCustom = false;
1728        }
1729        else if (res.value == 6) {
1730            msgRetorno = "O número do documento é inválido.";
1731            isValidCustom = false;
1732        }
1733
1734        else if (!ValidarDocumento(txt_nuDocumento, document.getElementById("rdb_pf").checked)) {
1735            isValidCustom = false;
1736            msgRetorno = "O número do documento é inválido.";
1737        }
1738
1739        if (res.value == 0) {
1740            document.getElementById("lbl_nuDocumento").style.color = "rgb(0, 0, 0)";
1741            isValidCustom = true;
1742        }
1743
1744
1745        if (!isValidCustom) {
1746            Message.Show(MessageIcon.Warning, MessageButtons.Ok, msgRetorno, action);
1747        }
1748        else {
1749            lbl_nuDocumento.style.color = "rgb(0, 0, 0)";
1750        }
1751    }
1752}
1753
1754//Função para validação do documento CPF ou CNPJ
1755function ValidarDocumento(_campo_documento, isPessoaFisica) {
1756
1757    var valido = true;
1758
1759
1760    if (_campo_documento.value == "") {
1761        return (false);
1762    }
1763
1764
1765    //Retira pontuação
1766    var campo_documento = _campo_documento.value;
1767    campo_documento = campo_documento.replace(/\D/g, "");//Usando expressão regular para tirar tudo que não seja número.
1768
1769
1770    if (((campo_documento.length == 11) && (campo_documento == 11111111111) || (campo_documento == 22222222222) || (campo_documento == 33333333333) || (campo_documento == 44444444444) || (campo_documento == 55555555555) || (campo_documento == 66666666666) || (campo_documento == 77777777777) || (campo_documento == 88888888888) || (campo_documento == 99999999999) || (campo_documento == 00000000000))) {
1771        return (false);
1772    }
1773
1774
1775    if (!((campo_documento.length == 11) || (campo_documento.length == 14))) {
1776        return (false);
1777    }
1778
1779    var checkOK = "0123456789";
1780    var checkStr = campo_documento;
1781    var allValid = true;
1782    var allNum = "";
1783    for (i = 0; i < checkStr.length; i++) {
1784        ch = checkStr.charAt(i);
1785        for (j = 0; j < checkOK.length; j++)
1786            if (ch == checkOK.charAt(j))
1787                break;
1788        if (j == checkOK.length) {
1789            allValid = false;
1790            break;
1791        }
1792        allNum += ch;
1793    }
1794    if (!allValid) {
1795        return (false);
1796    }
1797
1798    var chkVal = allNum;
1799    var prsVal = parseFloat(allNum);
1800    if (chkVal != "" && !(prsVal > "0")) {
1801        return (false);
1802    }
1803
1804    if (isPessoaFisica) {
1805        if (campo_documento.length == 11) {
1806            var tot = 0;
1807
1808            for (i = 2; i <= 10; i++)
1809                tot += i * parseInt(checkStr.charAt(10 - i));
1810
1811            if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(9))) {
1812                return (false);
1813            }
1814
1815            tot = 0;
1816
1817            for (i = 2; i <= 11; i++)
1818                tot += i * parseInt(checkStr.charAt(11 - i));
1819
1820            if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(10))) {
1821                return (false);
1822            }
1823        }
1824        else {
1825            return (false);
1826        }
1827    }
1828    else {
1829        var tot = 0;
1830        var peso = 2;
1831
1832        for (i = 0; i <= 11; i++) {
1833            tot += peso * parseInt(checkStr.charAt(11 - i));
1834            peso++;
1835            if (peso == 10) {
1836                peso = 2;
1837            }
1838        }
1839
1840        if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(12))) {
1841            return (false);
1842        }
1843
1844        tot = 0;
1845        peso = 2;
1846
1847        for (i = 0; i <= 12; i++) {
1848            tot += peso * parseInt(checkStr.charAt(12 - i));
1849            peso++;
1850            if (peso == 10) {
1851                peso = 2;
1852            }
1853        }
1854
1855        if ((tot * 10 % 11 % 10) != parseInt(checkStr.charAt(13))) {
1856            return (false);
1857        }
1858    }
1859    return (valido);
1860}
1861
1862function CarregaMunicipio(cdUf, cdMunicipio) {
1863    int_cad.GetCidade(cdUf, (function (parametros) {
1864        return function (res) {
1865            if (res.error == null) {
1866                var t = res.value.length;
1867                var c = cdmunicipio.options.length;
1868
1869                var selectParentNode = cdmunicipio.parentNode;
1870                var newSelectObj = cdmunicipio.cloneNode(false);
1871                selectParentNode.replaceChild(newSelectObj, cdmunicipio);
1872
1873                cdmunicipio = document.getElementById("cdmunicipio");
1874                cdmunicipio.options.add(new Option("Selecione", -1));
1875
1876                for (var i = 0; i < t; i++) {
1877                    if (cdMunicipio == res.value[i].CDMUNICIPIO) {
1878                        var option = new Option(res.value[i].NMMUNICIPIO, res.value[i].CDMUNICIPIO);
1879                        option.selected = true;
1880                        cdmunicipio.options.add(option);
1881                    } else {
1882                        cdmunicipio.options.add(new Option(res.value[i].NMMUNICIPIO, res.value[i].CDMUNICIPIO));
1883                    }
1884                }
1885            }
1886            if (parametros.length > 0 && typeof (parametros[0]) == "function") {
1887                parametros[0]();
1888            }
1889        }
1890    })(arguments));
1891}
1892
1893$(function () {
1894
1895    $('#txt_nuDocumento').blur(function (event) {
1896        VerificaDocumento();
1897    });
1898
1899    $('#edmail').blur(function (event) {
1900        VerificaEmail();
1901    });
1902
1903    $('#ddl_cdLicitacaoCategoria').select2({
1904        language: "pt-BR",
1905        minimumResultsForSearch: 10,
1906        tags: false
1907    });
1908
1909    $('#txt_idUsuario, #txt_idUsuario_rec_sen').blur(function (event) {
1910        var idUsuario = this.value.trim();
1911        if (idUsuario.replace(/[0-9.\-/]/g, '') == '') {
1912            idUsuario = idUsuario.replace(/\D/g, '');
1913            this.value = idUsuario;
1914            if (idUsuario.length > 11) {
1915                ApplyMask(this, '99.999.999/9999-99', event);
1916            }
1917            else {
1918                ApplyMask(this, '999.999.999-99', event);
1919            }
1920        }
1921    });
1922
1923    $('#txt_idUsuario, #txt_idUsuario_rec_sen').focus(function (event) {
1924        var idUsuario = this.value.trim();
1925        if (idUsuario.replace(/[0-9.\-/]/g, '') == '') {
1926            this.value = idUsuario.replace(/\D/g, '');
1927        }
1928    });
1929
1930    $('#rdb_pf, #rdb_pj').click(function (event) {
1931        MostraTipoPessoa(this.value, hdf_stTelefones.value, hdf_stDadosPessoais.value, hdf_stDocPessoais.value, hdf_stDadosCNH.value, hdf_stEndereco.value, hdf_stDadosLicitacao.value);
1932    });
1933
1934    $('.date').datetimepicker({
1935        viewMode: 'days',
1936        format: 'DD/MM/YYYY',
1937        locale: 'pt-BR'
1938    });
1939
1940    $("#btn_imgExcluir").click(function () {
1941        hdf_cdImagem.value = "-1";
1942        hdf_idImagem.value = "";
1943        hdf_nmImagemExtensao.value = "";
1944        hdf_nuAlturaImagem.value = "0";
1945        hdf_nuLarguraImagem.value = "0";
1946        hdf_nuTamanhoImagem.value = "0";
1947        $("#img_cdImagem").attr("src", "cssbase/images/user02.png");
1948    });
1949
1950    $("#btn_imgUpload").click(function () {
1951        var cropperOptions = {
1952            aspectRatio: 1 / 1
1953        };
1954
1955        modalImgPriv.show(cropperOptions);
1956        modalImgPriv.onAfterSaveImage = function (fileData) {
1957            var refresh = new Date().getTime();
1958
1959            hdf_cdImagem.value = -1;
1960            hdf_idImagem.value = fileData.Guid;
1961            hdf_nmImagemExtensao.value = fileData.Extension.replace(/\./g, '');
1962            hdf_nuAlturaImagem.value = fileData.Height;
1963            hdf_nuLarguraImagem.value = fileData.Width;
1964            hdf_nuTamanhoImagem.value = Math.round(fileData.Length / 1024);
1965
1966            //Imagem ainda não associada ao cadastro do internauta
1967            $("#img_cdImagem").attr("src", "/img_hdl.ashx?dmLocal=1&nmArquivo=" + fileData.Name + "&width=90&height=90&refresh=" + refresh);
1968        };
1969    });
1970
1971    //Trata comportamento do input [Confirmação de Senha].
1972    if (dssenha) {
1973        dssenha.onkeydown = function () { dsConfirmaSenha.value = ""; };
1974        dssenha.onchange = dssenha.onkeydown;
1975    }
1976
1977    if (nutelefone) {
1978        nutelefone.onkeydown = function (event) {
1979            event = event || window.event;
1980            if (isCodigoNaoGeografico(this.value)) {
1981                this.maxLength = 12;
1982                ApplyMask(this, '9999-9999999', event);
1983            }
1984            else {
1985                this.maxLength = 9;
1986                ApplyMask(this, '9999-9999', event);
1987            }
1988        }
1989    }
1990
1991    carregaDadosInternauta();
1992});
1993
1994function verificaEmail() {
1995    const emailInput = document.getElementById('edmail');
1996    const email = emailInput.value.trim();
1997    const emailRegex = /[!#$%^&*()+=[\]{};:"\\|,<>\/?]+|[áàãâéèêíïóôõöúüçñ]/;
1998    let isValidCustom = true;
1999    let msgRetorno = "";
2000
2001    const action = new MessageAction();
2002    action.Ok = function () {
2003        Message.Hide();
2004    };
2005
2006    if (email === '') {
2007        msgRetorno = "Digite um endereço de e-mail válido.";
2008        isValidCustom = false;
2009    } else if (emailRegex.test(email)) {
2010        msgRetorno = "Endereço de e-mail inválido. Certifique-se de digitar um endereço válido.";
2011        isValidCustom = false;
2012    }
2013
2014    if (!isValidCustom) {
2015        const lbl_edMail = document.getElementById("lbl_mail");
2016        lbl_edMail.style.color = "rgb(250, 0, 0)";
2017
2018        Message.Show(MessageIcon.Warning, MessageButtons.Ok, msgRetorno, action);
2019        edmail.focus();
2020    } else {
2021        const lbl_nuDocumento = document.getElementById("lbl_nuDocumento");
2022        lbl_nuDocumento.style.color = "rgb(0, 0, 0)";
2023    }
2024}
2025
2026
2027
2028
2029$("#bt_confirmar_2fa").click(function () {
2030    var code = $("#txt_codigo2FA_log").val().trim();
2031    var action = new MessageAction(); action.Ok = function () { Message.Hide(); };
2032    if (code.length !== 6) {
2033        Message.Show(MessageIcon.Error, MessageButtons.Ok, "Por favor, digite o código de verificação.", action);
2034        return;
2035    }
2036
2037    int_cad.Confirmar2FA(code, function (res2FA) {
2038        if (res2FA.error == null && res2FA.value.Codigo == 1) {
2039            var contexto = typeof (redir) == "string" ? redir : "int_cad.aspx";
2040            var isCadastroCompleto = int_cad.isCadastroCompleto(contexto).value;
2041
2042            if (isCadastroCompleto.length == 0) {
2043                if (typeof (redir) == "string") {
2044                    if (redir == "uc_enquete.aspx" || redir == "uc_comentario.aspx")
2045                        location = "default.aspx";
2046                    else
2047                        location = redir;
2048                } else {
2049                    if (int_cad.IsAreaInternautaEnable().value == true)
2050                        location = "int_pag.aspx";
2051                    else if (int_cad.IsRedirectPagPrincipalEnable().value == true)
2052                        location = "principal";
2053                    else
2054                        location = "int_cad.aspx?formtype=1";
2055                }
2056            } else {
2057                emsg = "Identificamos que o seu cadastro está desatualizado para a ação desejada e deve ser completado. Clique em \"OK\" para ser redirecionado à página de cadastro do internauta, onde deverão ser preenchidos os campos obrigatórios. Ao término, o sistema retornará à página de origem.";
2058                if (typeof (redir) == "string")
2059                    action.Ok = function () { window.location = "int_cad.aspx?formtype=1&redir=" + redir; };
2060                else
2061                    action.Ok = function () { window.location = "int_cad.aspx?formtype=1"; };
2062                Message.Show(MessageIcon.Information, MessageButtons.Ok, emsg, action);
2063            }
2064        } else {
2065            var msgErr = (res2FA.error == null ? res2FA.value.Mensagem : "Falha na verificação do código.");
2066            Message.Show(MessageIcon.Error, MessageButtons.Ok, msgErr, action);
2067        }
2068    });
2069});
2070
2071$("#bt_reenviar_2fa").click(function () {
2072    var action = new MessageAction(); action.Ok = function () { Message.Hide(); };
2073    int_cad.Reenviar2FA(function (resReenviar) {
2074        if (resReenviar.error == null && resReenviar.value.Codigo == 1) {
2075            Message.Show(MessageIcon.Information, MessageButtons.Ok, "Novo código enviado com sucesso para o seu e-mail.", action);
2076        } else {
2077            var msgErr = (resReenviar.error == null ? resReenviar.value.Mensagem : "Falha ao reenviar o código.");
2078            Message.Show(MessageIcon.Error, MessageButtons.Ok, msgErr, action);
2079        }
2080    });
2081});
2082
2083$("#bt_voltar_2fa").click(function () {
2084    $("#fds_2fa").addClass('hide').hide();
2085    $("#fds_dados_login").removeClass('hide').show();
2086});
2087
2088$("#txt_codigo2FA_log").keypress(function (e) {
2089    if (e.which == 13) {
2090        e.preventDefault();
2091        $("#bt_confirmar_2fa").trigger("click");
2092    }
2093});
2094
2095function resetDigits2FA() {
2096    var $digits = $("#div_codigo2FA_log_digitos .input_2fa_digit");
2097    $digits.val("");
2098    $("#txt_codigo2FA_log").val("");
2099    $digits.eq(0).focus();
2100}
2101function startResendTimer2FA() {
2102    var seconds = 60, $button = $("#bt_reenviar_2fa"), label = "Reenviar C" + String.fromCharCode(243) + "digo";
2103    clearInterval(window.intCadTwoFactorTimer);
2104    function render() {
2105        if (seconds <= 0) { $button.val(label).prop("disabled", false); return true; }
2106        $button.val(label + " (00:" + (seconds < 10 ? "0" : "") + seconds + ")").prop("disabled", true);
2107        return false;
2108    }
2109    render();
2110    window.intCadTwoFactorTimer = setInterval(function () { seconds--; if (render()) clearInterval(window.intCadTwoFactorTimer); }, 1000);
2111}
2112$(function () {
2113    var $digits = $("#div_codigo2FA_log_digitos .input_2fa_digit");
2114    function syncCode() { $("#txt_codigo2FA_log").val($digits.map(function () { return this.value; }).get().join("")); }
2115    $digits.on("input", function () { var index=$digits.index(this); this.value=this.value.replace(/\D/g, "").slice(-1); if(this.value && index < 5)$digits.eq(index + 1).focus(); syncCode(); })
2116        .on("keydown", function (e) { var index=$digits.index(this); if(e.which===8 && !this.value && index>0){$digits.eq(index-1).val("").focus();syncCode();} if(e.which===13){e.preventDefault();$("#bt_confirmar_2fa").trigger("click");} })
2117        .on("paste", function (e) { e.preventDefault(); var clip=(e.originalEvent||e).clipboardData||window.clipboardData, code=clip?clip.getData("text").replace(/\D/g, "").slice(0,6):""; $digits.each(function(i){this.value=code.charAt(i);}); $digits.eq(Math.min(code.length,5)).focus();syncCode(); });
2118    $("#bt_reenviar_2fa").on("click", function () { if(!this.disabled){resetDigits2FA();startResendTimer2FA();} });
2119});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.