﻿window.onerror = TrataErro;

function TrataErro() {
    return true;
}


var dtCh = "/";
var minYear = 1900;
var maxYear = 2100;

function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag) {
    var i;
    var returnString = "";
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary(year) {
    return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }
        if (i == 2) { this[i] = 29 }
    }
    return this
}

function isDate(dtStr) {
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh)
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)
    var strMonth = dtStr.substring(0, pos1)
    var strDay = dtStr.substring(pos1 + 1, pos2)
    var strYear = dtStr.substring(pos2 + 1)
    strYr = strYear
    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (pos1 == -1 || pos2 == -1) {
        //alert("The date format should be : mm/dd/yyyy")
        return false
    }
    if (strMonth.length < 1 || month < 1 || month > 12) {
        //alert("Please enter a valid month")
        return false
    }
    if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        //alert("Please enter a valid day")
        return false
    }
    if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        //alert("Please enter a valid 4 digit year between " + minYear + " and " + maxYear)
        return false
    }
    if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        //alert("Please enter a valid date")
        return false
    }
    return true
}

function ValidateForm() {
    var dt = document.frmSample.txtDate
    if (isDate(dt.value) == false) {
        dt.focus()
        return false
    }
    return true
}

function isCPF(st) {
    if (st.length > 0) {
        st = st.replace(".", "");
        st = st.replace(".", "");
        st = st.replace("-", "");
    }
    if (st == "")
        return (false);
    l = st.length;

    //aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho
    if ((l == 9) || (l == 8)) {
        for (i = l; i < 10; i++) {
            st = '0' + st
        }
    }
    l = st.length;
    st2 = "";
    for (i = 0; i < l; i++) {
        caracter = st.substring(i, i + 1);
        if ((caracter >= '0') && (caracter <= '9'));
        st2 = st2 + caracter;
    }
    if ((st2.length > 11) || (st2.length < 10))
        return (false);
    if (st2.length == 10)
        st2 = '0' + st2;
    digito1 = st2.substring(9, 10);
    digito2 = st2.substring(10, 11);
    digito1 = parseInt(digito1, 10);
    digito2 = parseInt(digito2, 10);
    sum = 0; mul = 10;
    for (i = 0; i < 9; i++) {
        digit = st2.substring(i, i + 1);
        tproduct = parseInt(digit, 10) * mul;
        sum += tproduct;
        mul--;
    }
    dig1 = (sum % 11);
    if (dig1 == 0 || dig1 == 1)
        dig1 = 0;
    else
        dig1 = 11 - dig1;
    if (dig1 != digito1)
        return (false);
    sum = 0;
    mul = 11;
    for (i = 0; i < 10; i++) {
        digit = st2.substring(i, i + 1);
        tproduct = parseInt(digit, 10) * mul;
        sum += tproduct;
        mul--;
    }
    dig2 = (sum % 11);
    if (dig2 == 0 || dig2 == 1)
        dig2 = 0;
    else
        dig2 = 11 - dig2;
    if (dig2 != digito2)
        return (false);
    return (true);
}

function ajaxInit() {
    var req;
    try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (ex) {
            try {
                req = new XMLHttpRequest();
            } catch (exc) {
                alert("Esse browser não tem recursos para uso do Ajax");
                req = null;
            }
        }
    }
    return req;
}

function EnviarEnquete() {
    form = document.frmEnquete;
    Selecionado = null;
    for (z = 0; z < form.Resposta.length; z++) {
        if (form.Resposta[z].checked) {
            Selecionado = z;
        }
    }
    if (Selecionado == null) {
        alert("Atenção: selecione uma resposta para votar nesta enquete!");
    } else {
        idPergunta = form.idPergunta.value;
        document.getElementById("enquete").style.display = "none";
        document.getElementById("enquete_loading").style.display = "block";
        document.getElementById("enquete_erro").style.display = "none";
        document.getElementById("enquete_ok").style.display = "none";        
        ajax2 = ajaxInit();
        resultado = "";
        if (ajax2) {
            ajax2.open("GET", "votar.asp?idPergunta=" + idPergunta + "&Resposta=" + form.Resposta[Selecionado].value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
            ajax2.setRequestHeader("Content-type", "charset=iso-8859-1");
            ajax2.onreadystatechange = function() {
                if (ajax2.readyState == 4) {
                    if (ajax2.status == 200) {
                        resultado = ajax2.responseText;
                        timerID = setTimeout("ExibeResultado('" + resultado + "')", 1000);
                    }
                }
            }
            ajax2.send(null);
        }
    }
}

ValorParcialEnquete = "";

function ExibeResultado(Valor) {
    document.getElementById("enquete").style.display = "none";
    document.getElementById("enquete_loading").style.display = "none";
    if (Valor.length == 0) {
       document.getElementById("enquete_erro").style.display = "block";
       document.getElementById("enquete_ok").style.display = "none";
    } else {
       document.getElementById("enquete_erro").style.display = "none";
       document.getElementById("enquete_ok").style.display = "block";
       ValorParcialEnquete = Valor;
    }
}

function ExibeResultadoCalendario(Valor) {
    document.getElementById("calendario_loading").style.display = "none";
    if (Valor.length == 0) {
        document.getElementById("calendario_erro").style.display = "block";
        document.getElementById("calendario").style.display = "none";
    } else {    
        document.getElementById("calendario_erro").style.display = "none";
        document.getElementById("calendario").style.display = "block";
        document.getElementById("calendario").innerHTML = Valor;
    }
}

function TentarNovamente() {
    document.getElementById("enquete").style.display = "block";
    document.getElementById("enquete_loading").style.display = "none";
    document.getElementById("enquete_erro").style.display = "none";
    document.getElementById("enquete_ok").style.display = "none";
}

function AlterarMes(Valor) {
    if (document.getElementById("calendario_loading").style.display == "none") {
        MesAtual = parseInt(document.frmMesAtual.Mes.value);
        AnoAtual = parseInt(document.frmMesAtual.Ano.value);
        if ((MesAtual == 1) && (Valor == -1)) {
            MesAtual = 12;
            AnoAtual = AnoAtual - 1;
        } else if ((MesAtual == 12) && (Valor == 1)) {
            MesAtual = 1;
            AnoAtual = AnoAtual + 1;
        } else {
            MesAtual = MesAtual + Valor;
        }
        document.frmMesAtual.Mes.value = MesAtual;
        document.frmMesAtual.Ano.value = AnoAtual;
        document.getElementById("MesAno").innerHTML = ExibeMes(MesAtual) + " de " + AnoAtual + "<br />";
        document.getElementById("calendario").style.display = "none";
        document.getElementById("calendario_erro").style.display = "none";
        document.getElementById("calendario_loading").style.display = "block";
        ajax3 = ajaxInit();
        resultado2 = "";
        if (ajax3) {
            ajax3.open("GET", "calendario.asp?Mes=" + MesAtual + "&Ano=" + AnoAtual + "&Rand=" + Math.ceil(Math.random() * 100000), true);
            ajax3.setRequestHeader("Content-type", "charset=iso-8859-1");
            ajax3.onreadystatechange = function() {
                if (ajax3.readyState == 4) {
                    if (ajax3.status == 200) {
                        resultado2 = ajax3.responseText;
                        timerID = setTimeout("ExibeResultadoCalendario('" + resultado2 + "')", 1000);
                    }
                }
            }
            ajax3.send(null);
        }
    }
}

function ExibeMes(Mes) {
    if (Mes == 1) {
        return "Janeiro";
    }
    if (Mes == 2) {
        return "Fevereiro";
    }
    if (Mes == 3) {
        return "Março";
    }
    if (Mes == 4) {
        return "Abril";
    }
    if (Mes == 5) {
        return "Maio";
    }
    if (Mes == 6) {
        return "Junho";
    }
    if (Mes == 7) {
        return "Julho";
    }
    if (Mes == 8) {
        return "Agosto";
    }
    if (Mes == 9) {
        return "Setembro";
    }
    if (Mes == 10) {
        return "Outubro";
    }
    if (Mes == 11) {
        return "Novembro";
    }
    if (Mes == 12) {
        return "Dezembro";
    }
}

function ExibeResultadoParcial() {
    document.getElementById("enquete").style.display = "block";
    document.getElementById("enquete_loading").style.display = "none";
    document.getElementById("enquete_erro").style.display = "none";
    document.getElementById("enquete_ok").style.display = "none";
    document.getElementById("enquete").innerHTML = ValorParcialEnquete;
}

function ExibeTituloDia(Dia) {
    document.getElementById("dia_" + Dia).style.display = "block";
}

function OcultaTituloDia(Dia) {
    document.getElementById("dia_" + Dia).style.display = "none";
}

TickerInicial = 1;
timerIDTicker = null;

function IniciaTicker(Valor0) {
    timerIDTicker = setTimeout("CarregaTicker(" + Valor0 + ")", 6000);
}

function AlterarNoticia(Valor1) {
    TickerInicial = TickerInicial + Valor1;
    if (TickerInicial > TotalTickers) {
        TickerInicial = 1;
    }
   
    if (TickerInicial == 0) {
        TickerInicial = TotalTickers;
    }
    clearTimeout(timerIDTicker);
    Carrega2Ticker(Valor1);
}

function CarregaTicker(Valor2) {
    TickerInicial = TickerInicial + Valor2;
    if (TickerInicial > TotalTickers) {
        TickerInicial = 1;
    }
    if (TickerInicial == 0) {
        TickerInicial = TotalTickers;
    }
    document.getElementById("ticker_imagem_" + TickerInicial).style.display = "block";
    Extensao = document.getElementById("ticker_link_" + TickerInicial).href.substring(document.getElementById("ticker_link_" + TickerInicial).href.length - 3, document.getElementById("ticker_link_" + TickerInicial).href.length);
    if ((Extensao == "gif") || (Extensao == "jpg") || (Extensao == "png")) {
        document.getElementById("ticker_central_cen_texto").innerHTML = "<table cellspacing='0' cellpadding='0' border='1' height='30' width='100%'><tr><td valign='middle'><a href='" + document.getElementById("ticker_link_" + TickerInicial).href + "' title='" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "' class='lightview'>" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "</a></td></tr></table>";
    } else {
        document.getElementById("ticker_central_cen_texto").innerHTML = "<table cellspacing='0' cellpadding='0' border='1' height='30' width='100%'><tr><td valign='middle'><a href='" + document.getElementById("ticker_link_" + TickerInicial).href + "' title='" + document.getElementById("ticker_imagem_" + TickerInicial).alt + " :: :: width: 800, height: 600' class='lightview'>" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "</a></td></tr></table>";
    }
    if (Valor2 < 0) {
        if (TickerInicial == TotalTickers) {
            document.getElementById("ticker_imagem_1").style.display = "none";
        } else {
            document.getElementById("ticker_imagem_" + (TickerInicial - Valor2)).style.display = "none";
        }
    } else {
        if (TickerInicial == 1) {
            document.getElementById("ticker_imagem_" + TotalTickers).style.display = "none";
        } else {
            document.getElementById("ticker_imagem_" + (TickerInicial - Valor2)).style.display = "none";
        }
    }
    IniciaTicker(1);
}

function Carrega2Ticker(Valor3) {
    document.getElementById("ticker_imagem_" + TickerInicial).style.display = "block";
    Extensao = document.getElementById("ticker_link_" + TickerInicial).href.substring(document.getElementById("ticker_link_" + TickerInicial).href.length - 3, document.getElementById("ticker_link_" + TickerInicial).href.length);
    if ((Extensao == "gif") || (Extensao == "jpg") || (Extensao == "png")) {
        document.getElementById("ticker_central_cen_texto").innerHTML = "<table cellspacing='0' cellpadding='0' border='1' height='30' width='100%'><tr><td valign='middle'><a href='" + document.getElementById("ticker_link_" + TickerInicial).href + "' title='" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "' class='lightview'>" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "</a></td></tr></table>";
    } else {
        document.getElementById("ticker_central_cen_texto").innerHTML = "<table cellspacing='0' cellpadding='0' border='1' height='30' width='100%'><tr><td valign='middle'><a href='" + document.getElementById("ticker_link_" + TickerInicial).href + "' title='" + document.getElementById("ticker_imagem_" + TickerInicial).alt + " :: :: width: 800, height: 600' class='lightview'>" + document.getElementById("ticker_imagem_" + TickerInicial).alt + "</a></td></tr></table>";
    }
    if (Valor3 < 0) {
        if (TickerInicial == TotalTickers) {
            document.getElementById("ticker_imagem_1").style.display = "none";
        } else {
            document.getElementById("ticker_imagem_" + (TickerInicial - Valor3)).style.display = "none";
        }
    } else {
        if (TickerInicial == 1) {
            document.getElementById("ticker_imagem_" + TotalTickers).style.display = "none";
        } else {
            document.getElementById("ticker_imagem_" + (TickerInicial - Valor3)).style.display = "none";
        }
    }
    timerIDTicker = setTimeout("CarregaTicker(1)", 6000);
}

function CadastrarNewsletter() {
    Nome = document.frmNewsletter.Nome;
    Email = document.frmNewsletter.Email;
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome Completo!");
        Nome.focus();
        return;
    }
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouPonto < AchouArroba) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }     
    document.getElementById("formNewsletter").style.display = "none";
    document.getElementById("erroNewsletter").style.display = "none";
    document.getElementById("erro2Newsletter").style.display = "none";
    document.getElementById("okNewsletter").style.display = "none";
    document.getElementById("loadingNewsletter").style.display = "block";
    ajaxNewsletter = ajaxInit();
    resultado = "";
    if (ajaxNewsletter) {
        ajaxNewsletter.open("GET", "cadastro_newsletter.asp?Nome=" + Nome.value + "&Email=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxNewsletter.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxNewsletter.onreadystatechange = function() {
            if (ajaxNewsletter.readyState == 4) {
                if (ajaxNewsletter.status == 200) {
                    resultado = ajaxNewsletter.responseText;
                    timerID = setTimeout("ExibeResultadoNewsletter('" + resultado + "')", 1000);
                } else {
                    timerID = setTimeout("ExibeResultadoNewsletter('0')", 1000);
                }
            }
        }
        ajaxNewsletter.send(null);
    }
}

function ExibeResultadoNewsletter(resultado) {
    if (resultado == "0") {
        document.getElementById("formNewsletter").style.display = "none";
        document.getElementById("erroNewsletter").style.display = "block";
        document.getElementById("erro2Newsletter").style.display = "none";
        document.getElementById("okNewsletter").style.display = "none";
        document.getElementById("loadingNewsletter").style.display = "none";        
    }
    if (resultado == "1") {
        document.getElementById("formNewsletter").style.display = "none";
        document.getElementById("erroNewsletter").style.display = "none";
        document.getElementById("erro2Newsletter").style.display = "block";
        document.getElementById("okNewsletter").style.display = "none";
        document.getElementById("loadingNewsletter").style.display = "none";
    }
    if (resultado == "2") {
        document.getElementById("formNewsletter").style.display = "none";
        document.getElementById("erroNewsletter").style.display = "none";
        document.getElementById("erro2Newsletter").style.display = "none";
        document.getElementById("okNewsletter").style.display = "block";
        document.getElementById("loadingNewsletter").style.display = "none";
    }
}

function TentarNovamenteNewsletter() {
    document.getElementById("formNewsletter").style.display = "block";
    document.getElementById("erroNewsletter").style.display = "none";
    document.getElementById("erro2Newsletter").style.display = "none";
    document.getElementById("okNewsletter").style.display = "none";
    document.getElementById("loadingNewsletter").style.display = "none";
}

function OKNewsletter() {
    document.getElementById("formNewsletter").style.display = "block";
    document.getElementById("erroNewsletter").style.display = "none";
    document.getElementById("erro2Newsletter").style.display = "none";
    document.getElementById("okNewsletter").style.display = "none";
    document.getElementById("loadingNewsletter").style.display = "none";
    document.frmNewsletter.Nome.value = "";
    document.frmNewsletter.Email.value = ""
    document.frmNewsletter.Nome.focus();
}

function FiltrarMidia() {
    document.frmMidia.submit();
}

function Login() {
    Usuario = document.frmLogin.Usuario;
    Senha = document.frmLogin.Senha;
    if (Usuario.value.length == 0) {
        alert("Digite o seu Usuário!");
        Usuario.focus();
        return;
    }
    if (Senha.value.length == 0) {
        alert("Digite a sua Senha!");
        Senha.focus();
        return;
    }
    document.getElementById("formLogin").style.display = "none";
    document.getElementById("erroLogin").style.display = "none";
    document.getElementById("erro2Login").style.display = "none";
    document.getElementById("okLogin").style.display = "none";
    document.getElementById("loadingLogin").style.display = "block";
    ajaxLogin = ajaxInit();
    resultado = "";
    if (ajaxLogin) {
        ajaxLogin.open("GET", "efetuar_login.asp?Usuario=" + Usuario.value + "&Senha=" + Senha.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxLogin.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxLogin.onreadystatechange = function() {
            if (ajaxLogin.readyState == 4) {                
                if (ajaxLogin.status == 200) {
                    resultado = ajaxLogin.responseText;
                    timerID = setTimeout("ExibeResultadoLogin('" + resultado + "')", 1000);
                } else {
                    timerID = setTimeout("ExibeResultadoLogin('0')", 1000);
                }
            }
        }
        ajaxLogin.send(null);
    }
}

SegundosLogin = 3;
SegundosCadastro = 3;

function ExibeResultadoLogin(resultado) {
    if (resultado == "0") {
        document.getElementById("formLogin").style.display = "none";
        document.getElementById("erroLogin").style.display = "block";
        document.getElementById("erro2Login").style.display = "none";
        document.getElementById("okLogin").style.display = "none";
        document.getElementById("loadingLogin").style.display = "none";
    }
    if (resultado == "1") {
        document.getElementById("formLogin").style.display = "none";
        document.getElementById("erroLogin").style.display = "none";
        document.getElementById("erro2Login").style.display = "block";
        document.getElementById("okLogin").style.display = "none";
        document.getElementById("loadingLogin").style.display = "none";
    }
    if (resultado == "2") {
        document.getElementById("formLogin").style.display = "none";
        document.getElementById("erroLogin").style.display = "none";
        document.getElementById("erro2Login").style.display = "none";
        document.getElementById("okLogin").style.display = "block";
        document.getElementById("loadingLogin").style.display = "none";
        document.getElementById("texto_login").innerHTML = "<font color=\"#c2000b\">Caso não seja redirecionado automaticamente, <a href=\"verifica_cadastro.asp\"><font color=\"#c2000b\"><b>clique aqui</b></font></a>!</font>";
        timerIDLogin = setTimeout("ContagemLogin()", 1000);
    }
}

function ContagemLogin() {
    SegundosLogin--;
    if (SegundosLogin == 0) {
        location.href = "verifica_cadastro.asp";
    } else {
        document.getElementById("segundos").innerHTML = SegundosLogin + " segundo(s)";
        timerIDLogin = setTimeout("ContagemLogin()", 1000);
    }
}

function TentarNovamenteLogin() {
    document.getElementById("formLogin").style.display = "block";
    document.getElementById("erroLogin").style.display = "none";
    document.getElementById("erro2Login").style.display = "none";
    document.getElementById("okLogin").style.display = "none";
    document.getElementById("loadingLogin").style.display = "none";
}

function OKLogin() {
    document.getElementById("formLogin").style.display = "block";
    document.getElementById("erroLogin").style.display = "none";
    document.getElementById("erro2Login").style.display = "none";
    document.getElementById("okLogin").style.display = "none";
    document.getElementById("loadingLogin").style.display = "none";
    document.frmLogin.Usuario.value = "";
    document.frmLogin.Senha.value = ""
    document.frmLogin.Usuario.focus();
}

function EnviarSenha() {
    Usuario = document.frmEsqueciSenha.Usuario;
    if (Usuario.value.length == 0) {
        alert("Digite o seu Usuário!");
        Usuario.focus();
        return;
    }
    document.getElementById("formEsqueciSenha").style.display = "none";
    document.getElementById("erroEsqueciSenha").style.display = "none";
    document.getElementById("erro2EsqueciSenha").style.display = "none";
    document.getElementById("okEsqueciSenha").style.display = "none";
    document.getElementById("loadingEsqueciSenha").style.display = "block";
    ajaxEsqueciSenha = ajaxInit();
    resultado = "";
    if (ajaxEsqueciSenha) {
        ajaxEsqueciSenha.open("GET", "enviar_senha.asp?Usuario=" + Usuario.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxEsqueciSenha.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxEsqueciSenha.onreadystatechange = function() {
            if (ajaxEsqueciSenha.readyState == 4) {
                if (ajaxEsqueciSenha.status == 200) {
                    resultado = ajaxEsqueciSenha.responseText;
                    timerID = setTimeout("ExibeResultadoEsqueciSenha('" + resultado + "')", 1000);
                } else {
                timerID = setTimeout("ExibeResultadoEsqueciSenha('0')", 1000);
                }
            }
        }
        ajaxEsqueciSenha.send(null);
    }
}

function TentarNovamenteEsqueciSenha() {
    document.getElementById("formEsqueciSenha").style.display = "block";
    document.getElementById("erroEsqueciSenha").style.display = "none";
    document.getElementById("erro2EsqueciSenha").style.display = "none";
    document.getElementById("okEsqueciSenha").style.display = "none";
    document.getElementById("loadingEsqueciSenha").style.display = "none";
}

function OKEsqueciSenha() {
    document.getElementById("formEsqueciSenha").style.display = "block";
    document.getElementById("erroEsqueciSenha").style.display = "none";
    document.getElementById("erro2EsqueciSenha").style.display = "none";
    document.getElementById("okEsqueciSenha").style.display = "none";
    document.getElementById("loadingEsqueciSenha").style.display = "none";
    document.frmEsqueciSenha.Usuario.value = "";
    document.frmEsqueciSenha.Usuario.focus();
}

function ExibeResultadoEsqueciSenha(resultado) {
    if (resultado == "0") {
        document.getElementById("formEsqueciSenha").style.display = "none";
        document.getElementById("erroEsqueciSenha").style.display = "block";
        document.getElementById("erro2EsqueciSenha").style.display = "none";
        document.getElementById("okEsqueciSenha").style.display = "none";
        document.getElementById("loadingEsqueciSenha").style.display = "none";
    } else if (resultado == "1") {
        document.getElementById("formEsqueciSenha").style.display = "none";
        document.getElementById("erroEsqueciSenha").style.display = "none";
        document.getElementById("erro2EsqueciSenha").style.display = "block";
        document.getElementById("okEsqueciSenha").style.display = "none";
        document.getElementById("loadingEsqueciSenha").style.display = "none";
    } else {
        document.getElementById("formEsqueciSenha").style.display = "none";
        document.getElementById("erroEsqueciSenha").style.display = "none";
        document.getElementById("erro2EsqueciSenha").style.display = "none";
        document.getElementById("okEsqueciSenha").style.display = "block";
        document.getElementById("loadingEsqueciSenha").style.display = "none";
        splitResultado = resultado.split("|");
        document.getElementById("email_esquecisenha").innerHTML = splitResultado[1];
    }
}

function bloquearTeclas(e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }

    keychar = String.fromCharCode(key);
    reg = /\d/;
    return reg.test(keychar);
}

function bloquearTeclas2(e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }

    keychar = String.fromCharCode(key);
    if ((keychar == "0") || (keychar == "1") || (keychar == "2") || (keychar == "3") || (keychar == "4") || (keychar == "5") || (keychar == "6") || (keychar == "7") || (keychar == "8") || (keychar == "9")) {
        return false;
    }
    //reg = /\d/;
    //return reg.test(keychar);
    return keychar;
}

function FormataCPF(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.CPF.value.length > 0) {
            if (document.frmCadastro.CPF.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    CPF = document.frmCadastro.CPF.value + character;
                } else {
                    CPF = document.frmCadastro.CPF.value;
                }
            } else {
                CPF = document.frmCadastro.CPF.value;
            }
            CPF = CPF.replace("-", "");
            CPF = CPF.replace("/", "");
            CPF = CPF.replace(".", "");
            CPF = CPF.replace(".", "");
            CPF = CPF.replace(".", "");
            for (x = CPF.length; x <= 10; x++) {
                CPF = "0" + CPF;
            }
            CPF = CPF.substring(CPF.length - 11, CPF.length);
            CPF = CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11);
            document.frmCadastro.CPF.value = CPF;
            return true;
        }
    }
}

function FormataCPF2() {
    if (document.frmCadastro.CPF.value.length > 0) {
        if (document.frmCadastro.CPF.value.length > 1) {
            CPF = document.frmCadastro.CPF.value;
        } else {
            CPF = document.frmCadastro.CPF.value;
        }
        CPF = CPF.replace("-", "");
        CPF = CPF.replace("/", "");
        CPF = CPF.replace(".", "");
        CPF = CPF.replace(".", "");
        CPF = CPF.replace(".", "");
        for (x = CPF.length; x <= 10; x++) {
            CPF = "0" + CPF;
        }
        CPF = CPF.substring(CPF.length - 11, CPF.length);
        CPF = CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11);
        document.frmCadastro.CPF.value = CPF;
    }
}

function FormataRG2() {
    if (document.frmCadastro.RG.value.length > 0) {
        if (document.frmCadastro.RG.value.length > 1) {
            RG = document.frmCadastro.RG.value;
        } else {
            RG = document.frmCadastro.RG.value;
        }
        RG = RG.replace("-", "");
        RG = RG.replace("/", "");
        RG = RG.replace(".", "");
        RG = RG.replace(".", "");
        RG = RG.replace(".", "");
        for (x = RG.length; x <= 9; x++) {
            RG = "0" + RG;
        }
        RG = RG.substring(RG.length - 9, RG.length);
        RG = RG.substring(0, 2) + "." + RG.substring(2, 5) + "." + RG.substring(5, 8) + "-" + RG.substring(8, 9);
        document.frmCadastro.RG.value = RG;
    }
}

function FormataRG(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.RG.value.length > 0) {
            if (document.frmCadastro.RG.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    RG = document.frmCadastro.RG.value + character;
                } else {
                    RG = document.frmCadastro.RG.value;
                }
            } else {
                RG = document.frmCadastro.RG.value;
            }
            RG = RG.replace("-", "");
            RG = RG.replace("/", "");
            RG = RG.replace(".", "");
            RG = RG.replace(".", "");
            RG = RG.replace(".", "");
            for (x = RG.length; x <= 9; x++) {
                RG = "0" + RG;
            }
            RG = RG.substring(RG.length - 9, RG.length);
            RG = RG.substring(0, 2) + "." + RG.substring(2, 5) + "." + RG.substring(5, 8) + "-" + RG.substring(8, 9);
            document.frmCadastro.RG.value = RG;
            return true;
        }
    }
}

function FormataCep(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.Cep.value.length > 0) {
            if (document.frmCadastro.Cep.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    Cep = document.frmCadastro.Cep.value + character;
                } else {
                    Cep = document.frmCadastro.Cep.value;
                }
            } else {
                Cep = document.frmCadastro.Cep.value;
            }
            Cep = Cep.replace("-", "");
            Cep = Cep.replace("/", "");
            Cep = Cep.replace(".", "");
            Cep = Cep.replace(".", "");
            Cep = Cep.replace(".", "");
            for (x = Cep.length; x <= 7; x++) {
                Cep = "0" + Cep;
            }
            Cep = Cep.substring(Cep.length - 8, Cep.length);
            Cep = Cep.substring(0, 5) + "-" + Cep.substring(5, 8);
            document.frmCadastro.Cep.value = Cep;
            return true;
        }
    }
}

function FormataCep2() {
    //if (document.frmCadastro.Cep.value.length == 0) {
    //    document.getElementById("tabela_endereco").style.display = "none";
    //} else {
        Cep = document.frmCadastro.Cep.value;
        Cep = Cep.replace("-", "");
        Cep = Cep.replace("/", "");
        Cep = Cep.replace(".", "");
        Cep = Cep.replace(".", "");
        Cep = Cep.replace(".", "");
        for (x = Cep.length; x <= 7; x++) {
            Cep = "0" + Cep;
        }
        Cep = Cep.substring(Cep.length - 8, Cep.length);
        Cep = Cep.substring(0, 5) + "-" + Cep.substring(5, 8);
        document.frmCadastro.Cep.value = Cep;
        document.getElementById("loading_cep1").style.display = "block";
        document.getElementById("loading_cep2").style.display = "block";
        ajax3 = ajaxInit();
        resultado = "";
        if (ajax3) {
            ajax3.open("GET", "cep.asp?CEP=" + Cep, true);
            ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            ajax3.onreadystatechange = function() {
                if (ajax3.readyState == 4) {
                    if (ajax3.status == 200) {
                        resultado = unescape(ajax3.responseText);
                        if (resultado.length > 0) {
                            splitResultado = resultado.split("&");
                            if (splitResultado[1] == "resultado=1") {
                                UF = splitResultado[3].replace("uf=", "");
                                while (UF.indexOf("+") >= 0) {
                                    UF = UF.replace("+", " ");
                                }
                                Cidade = splitResultado[4].replace("cidade=", "");
                                while (Cidade.indexOf("+") >= 0) {
                                    Cidade = Cidade.replace("+", " ");
                                }
                                Bairro = splitResultado[5].replace("bairro=", "");
                                while (Bairro.indexOf("+") >= 0) {
                                    Bairro = Bairro.replace("+", " ");
                                }
                                TipoLogradouro = splitResultado[6].replace("tipo_logradouro=", "");
                                while (TipoLogradouro.indexOf("+") >= 0) {
                                    TipoLogradouro = TipoLogradouro.replace("+", " ");
                                }
                                Logradouro = splitResultado[7].replace("logradouro=", "");
                                while (Logradouro.indexOf("+") >= 0) {
                                    Logradouro = Logradouro.replace("+", " ");
                                }
                                document.frmCadastro.Estado.value = UF;
                                document.frmCadastro.Cidade.value = Cidade;
                                document.frmCadastro.Bairro.value = Bairro;
                                document.frmCadastro.Endereco.value = TipoLogradouro + " " + Logradouro;
                                document.getElementById("loading_cep1").style.display = "none";
                                document.getElementById("loading_cep2").style.display = "none";
                            } else {
                                document.getElementById("loading_cep1").style.display = "none";
                                document.getElementById("loading_cep2").style.display = "none";
                                document.frmCadastro.Estado.value = "";
                                document.frmCadastro.Cidade.value = "";
                                document.frmCadastro.Bairro.value = "";
                                document.frmCadastro.Endereco.value = "";
                                alert("CEP Inválido!");
                                //document.frmCadastro.Cep.focus();
                            }
                        }
                    } else {
                        document.getElementById("loading_cep1").style.display = "none";
                        document.getElementById("loading_cep2").style.display = "none";
                        document.frmCadastro.Estado.value = "";
                        document.frmCadastro.Cidade.value = "";
                        document.frmCadastro.Bairro.value = "";
                        document.frmCadastro.Endereco.value = "";
                        alert("CEP Inválido!");
                        //document.frmCadastro.Cep.focus();
                    }
                }
            }
            ajax3.send(null);
        }
        //}
}


function FormataTelefone(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.Telefone.value.length > 0) {
            if (document.frmCadastro.Telefone.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    Telefone = document.frmCadastro.Telefone.value + character;
                } else {
                    Telefone = document.frmCadastro.Telefone.value;
                }
            } else {
                Telefone = document.frmCadastro.Telefone.value;
            }
            Telefone = Telefone.replace("-", "");
            Telefone = Telefone.replace("/", "");
            Telefone = Telefone.replace(".", "");
            Telefone = Telefone.replace(".", "");
            Telefone = Telefone.replace(".", "");
            for (x = Telefone.length; x <= 7; x++) {
                Telefone = "0" + Telefone;
            }
            Telefone = Telefone.substring(Telefone.length - 8, Telefone.length);
            Telefone = Telefone.substring(0, 4) + "-" + Telefone.substring(4, 8);
            document.frmCadastro.Telefone.value = Telefone;
            return true;
        }
    }
}

function FormataTelefone2() {
    if (document.frmCadastro.Telefone.value.length > 0) {
        if (document.frmCadastro.Telefone.value.length > 1) {
            Telefone = document.frmCadastro.Telefone.value;
        } else {
            Telefone = document.frmCadastro.Telefone.value;
        }
        Telefone = Telefone.replace("-", "");
        Telefone = Telefone.replace("/", "");
        Telefone = Telefone.replace(".", "");
        Telefone = Telefone.replace(".", "");
        Telefone = Telefone.replace(".", "");
        for (x = Telefone.length; x <= 7; x++) {
            Telefone = "0" + Telefone;
        }
        Telefone = Telefone.substring(Telefone.length - 8, Telefone.length);
        Telefone = Telefone.substring(0, 4) + "-" + Telefone.substring(4, 8);
        document.frmCadastro.Telefone.value = Telefone;
        return true;
    }
}

function FormataTelefoneFax(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.Fax.value.length > 0) {
            if (document.frmCadastro.Fax.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    Fax = document.frmCadastro.Fax.value + character;
                } else {
                    Fax = document.frmCadastro.Fax.value;
                }
            } else {
                Fax = document.frmCadastro.Fax.value;
            }
            Fax = Fax.replace("-", "");
            Fax = Fax.replace("/", "");
            Fax = Fax.replace(".", "");
            Fax = Fax.replace(".", "");
            Fax = Fax.replace(".", "");
            for (x = Fax.length; x <= 7; x++) {
                Fax = "0" + Fax;
            }
            Fax = Fax.substring(Fax.length - 8, Fax.length);
            Fax = Fax.substring(0, 4) + "-" + Fax.substring(4, 8);
            document.frmCadastro.Fax.value = Fax;
            return true;
        }
    }
}

function FormataTelefoneFax2() {
    if (document.frmCadastro.Fax.value.length > 0) {
        if (document.frmCadastro.Fax.value.length > 1) {
            Fax = document.frmCadastro.Fax.value;
        } else {
            Fax = document.frmCadastro.Fax.value;
        }
        Fax = Fax.replace("-", "");
        Fax = Fax.replace("/", "");
        Fax = Fax.replace(".", "");
        Fax = Fax.replace(".", "");
        Fax = Fax.replace(".", "");
        for (x = Fax.length; x <= 7; x++) {
            Fax = "0" + Fax;
        }
        Fax = Fax.substring(Fax.length - 8, Fax.length);
        Fax = Fax.substring(0, 4) + "-" + Fax.substring(4, 8);
        document.frmCadastro.Fax.value = Fax;
        return true;
    }
}

function FormataTelefoneCelular(e) {
    if (!e) var e = window.event;
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if ((code >= 93) && (code <= 105)) {
        code = code - 48;
    }
    var character = String.fromCharCode(code);
    if (((code >= 48) && (code <= 57)) || (code == 46) || (code == 8)) {
        if (document.frmCadastro.Celular.value.length > 0) {
            if (document.frmCadastro.Celular.value.length > 1) {
                if ((code >= 48) && (code <= 57)) {
                    Celular = document.frmCadastro.Celular.value + character;
                } else {
                    Celular = document.frmCadastro.Celular.value;
                }
            } else {
                Celular = document.frmCadastro.Celular.value;
            }
            Celular = Celular.replace("-", "");
            Celular = Celular.replace("/", "");
            Celular = Celular.replace(".", "");
            Celular = Celular.replace(".", "");
            Celular = Celular.replace(".", "");
            for (x = Celular.length; x <= 7; x++) {
                Celular = "0" + Celular;
            }
            Celular = Celular.substring(Celular.length - 8, Celular.length);
            Celular = Celular.substring(0, 4) + "-" + Celular.substring(4, 8);
            document.frmCadastro.Celular.value = Celular;
            return true;
        }
    }
}

function FormataTelefoneCelular2() {
    if (document.frmCadastro.Celular.value.length > 0) {
        if (document.frmCadastro.Celular.value.length > 1) {
            Celular = document.frmCadastro.Celular.value;
        } else {
            Celular = document.frmCadastro.Celular.value;
        }
        Celular = Celular.replace("-", "");
        Celular = Celular.replace("/", "");
        Celular = Celular.replace(".", "");
        Celular = Celular.replace(".", "");
        Celular = Celular.replace(".", "");
        for (x = Celular.length; x <= 7; x++) {
            Celular = "0" + Celular;
        }
        Celular = Celular.substring(Celular.length - 8, Celular.length);
        Celular = Celular.substring(0, 4) + "-" + Celular.substring(4, 8);
        document.frmCadastro.Celular.value = Celular;
        return true;
    }
}

function GravarDadosCadastro() {
    NovaSenha = document.frmCadastro.NovaSenha;
    ConfirmaNovaSenha = document.frmCadastro.ConfirmaNovaSenha;
    Nome = document.frmCadastro.Nome;
    Email = document.frmCadastro.Email;
    Creci = document.frmCadastro.Creci;
    RG = document.frmCadastro.RG;
    DiaNascimento = document.frmCadastro.DiaNascimento;
    MesNascimento = document.frmCadastro.MesNascimento;
    AnoNascimento = document.frmCadastro.AnoNascimento;
    CPF = document.frmCadastro.CPF;
    Cep = document.frmCadastro.Cep;
    Sexo = document.frmCadastro.Sexo;
    Endereco = document.frmCadastro.Endereco;
    Bairro = document.frmCadastro.Bairro;
    Cidade = document.frmCadastro.Cidade;
    Estado = document.frmCadastro.Estado;
    DDDTelefone = document.frmCadastro.DDDTelefone;
    Telefone = document.frmCadastro.Telefone;
    DDDCelular = document.frmCadastro.DDDCelular;
    Celular = document.frmCadastro.Celular;
    DDDFax = document.frmCadastro.DDDFax;
    Fax = document.frmCadastro.Fax;
    if (NovaSenha.value.length == 0) {
        alert("Digite a Nova Senha!");
        NovaSenha.focus();
        return;
    }
    if (NovaSenha.value.length <= 5) {
        alert("A Nova Senha deve ter mais do que 5 caracteres!");
        NovaSenha.focus();
        return;
    }
    if (NovaSenha.value != ConfirmaNovaSenha.value) {
        alert("Senhas não coincidem. Verifique!");
        ConfirmaNovaSenha.focus();
        return;
    }
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome completo!");
        Nome.focus();
        return;
    }
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouPonto < AchouArroba) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    if (RG.value.length == 0) {
        alert("Digite o seu RG!");
        RG.focus();
        return;
    }
    if (CPF.value.length == 0) {
        alert("Digite o seu CPF!");
        CPF.focus();
        return;
    }
    if (isCPF(CPF.value) == false) {
        alert("CPF inválido!");
        CPF.focus();
        return;
    }
    if (DiaNascimento.value.length == 0) {
        alert("Informe o Dia do seu Nascimento!");
        DiaNascimento.focus();
        return;
    }
    if (MesNascimento.value.length == 0) {
        alert("Informe o Mês do seu Nascimento!");
        MesNascimento.focus();
        return;
    }
    if (AnoNascimento.value.length == 0) {
        alert("Informe o Ano do seu Nascimento!");
        AnoNascimento.focus();
        return;
    }
    DataTemp = MesNascimento.value + "/" + DiaNascimento.value + "/" + AnoNascimento.value;
    if (isDate(DataTemp) == false) {
        alert("Data de Nascimento inválida. Verifique!");
        DiaNascimento.focus();
        return;
    }
    if (Sexo.value.length == 0) {
        alert("Informe o seu Sexo!");
        Sexo.focus();
        return;
    }
    if (Cep.value.length == 0) {
        alert("Digite o seu CEP!");
        Cep.focus();
        return;
    }
    if (document.getElementById("loading_cep1").style.display == "block") {
        alert("Aguarde, verificando CEP!");
        return;
    }
    if (Endereco.value.length == 0) {
        alert("Digite o seu Endereço!");
        Endereco.focus();
        return;
    }
    if (Bairro.value.length == 0) {
        alert("Digite o seu Bairro!");
        Bairro.focus();
        return;
    }
    if (Cidade.value.length == 0) {
        alert("Digite a sua Cidade!");
        Cidade.focus();
        return;
    }
    if (Estado.value.length == 0) {
        alert("Digite o seu Estado!");
        Estado.focus();
        return;
    }
    if (DDDTelefone.value.length == 0) {
        alert("Digite o DDD do seu Telefone!");
        DDDTelefone.focus();
        return;
    }
    if (Telefone.value.length == 0) {
        alert("Digite o seu Telefone!");
        Telefone.focus();
        return;
    }
    if (DDDCelular.value.length == 0) {
        alert("Digite o DDD do seu Celular!");
        DDDCelular.focus();
        return;
    }
    if (Celular.value.length == 0) {
        alert("Digite o seu Celular!");
        Celular.focus();
        return;
    }
    document.getElementById("formCadastro").style.display = "none";
    document.getElementById("loadingCadastro").style.display = "block";
    document.getElementById("okCadastro").style.display = "none";
    document.getElementById("erroCadastro").style.display = "none";
    ajaxCadastro = ajaxInit();
    resultado2 = "";
    if (ajaxCadastro) {
        ajaxCadastro.open("GET", "gravar_cadastro.asp?ConfirmaNovaSenha=" + ConfirmaNovaSenha.value + "&Nome=" + Nome.value + "&Email=" + Email.value + "&Creci=" + Creci.value + "&RG=" + RG.value + "&CPF=" + CPF.value + "&DataNascimento=" + DataTemp + "&Sexo=" + Sexo.value + "&Cep=" + Cep.value + "&Endereco=" + Endereco.value + "&Bairro=" + Bairro.value + "&Cidade=" + Cidade.value + "&Estado=" + Estado.value + "&DDDTelefone=" + DDDTelefone.value + "&Telefone=" + Telefone.value + "&DDDCelular=" + DDDCelular.value + "&Celular=" + Celular.value + "&DDDFax=" + DDDFax.value + "&Fax=" + Fax.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxCadastro.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxCadastro.onreadystatechange = function() {
            if (ajaxCadastro.readyState == 4) {
                if (ajaxCadastro.status == 200) {
                    resultado2 = ajaxCadastro.responseText;
                    timerID = setTimeout("ExibeResultadoCadastro('" + resultado2 + "')", 1000);                    
                } else {
                    timerID = setTimeout("ExibeResultadoCadastro('0')", 1000);
                }
            }
        }
        ajaxCadastro.send(null);
    }
}

function ExibeResultadoCadastro(resultado2) {
    if (resultado2 == "0") {
        document.getElementById("formCadastro").style.display = "none";
        document.getElementById("loadingCadastro").style.display = "none";
        document.getElementById("okCadastro").style.display = "none";
        document.getElementById("erroCadastro").style.display = "block";
    }
    if (resultado2 == "1") {
        document.getElementById("formCadastro").style.display = "none";
        document.getElementById("loadingCadastro").style.display = "none";
        document.getElementById("okCadastro").style.display = "block";
        document.getElementById("erroCadastro").style.display = "none";
        timerIDCadastro = setTimeout("ContagemCadastro()", 1000);
    }
}

function TentarNovamenteGravarCadastro() {
    document.getElementById("formCadastro").style.display = "block";
    document.getElementById("loadingCadastro").style.display = "none";
    document.getElementById("okCadastro").style.display = "none";
    document.getElementById("erroCadastro").style.display = "none";
}

function ContagemCadastro() {
    SegundosCadastro--;
    if (SegundosCadastro == 0) {
        location.href = "associado.asp";
    } else {
        document.getElementById("segundos_associado").innerHTML = SegundosCadastro + " segundo(s)";
        timerIDCadastro = setTimeout("ContagemCadastro()", 1000);
    }
}

function toggle(id) {
    for (x = 1; x <= 10; x++) {
        document.getElementById("sciesp_regionais_dir_" + x).style.display = "none";
    }
    if ((id >= 1) && (id <= 10)) {
        document.getElementById("sciesp_regionais_dir_" + id).style.display = "block";
    }
    loadMap(id);
}

function VerificaPesquisa() {
    if (document.frmGoogle.q.value.length == 0) {
        alert("Digite a palavra que você deseja pesquisar!");
        document.frmGoogle.q.focus();
    } else {
        document.frmGoogle.submit();
    }
}

function VerificaPesquisaSubmit() {
    if (document.frmGoogle.q.value.length == 0) {
        alert("Digite a palavra que você deseja pesquisar!");
        document.frmGoogle.q.focus();
        return false;
    } else {
        return true;
    }
}
function MudaDivEvento() {
    if (document.getElementById("EventoEscolhido").value == 0) {
        alert("Escolha primeiramente um evento!");
        return;
    }
    document.getElementById("eventos").style.display = "none";
    document.getElementById("dados_pessoais").style.display = "block";
}
function EscolheEvento(Valor, Indice) {
    for (z = 1; z <= document.getElementById("TotalEventos").value; z++) {
        if (z == parseInt(Indice)) {
            document.getElementById("Evento" + z).style.border = '2px solid';
            document.getElementById("Evento" + z).style.borderColor = '#c4000b'; 
        } else {

        document.getElementById("Evento" + z).style.border = '0px solid';
        }            
    }
    document.getElementById("EventoEscolhido").value = Valor;
}
