﻿function ExibirTelefones() {
    var estadoSelecionado = document.getElementById('selectEstado').value;
    var divTelefone = document.getElementById('divTelefone');
    var telefones = new Array();

    telefones[0] = "SP;<b>São Paulo</b>;<b>(11) 26663334</b>".split(";")
    telefones[1] = "RJ;<b>Rio de Janeiro</b>;<b>(21) 21696564</b>".split(";")
    telefones[2] = "MG;<b>Belo Horizonte</b>;<b>(31) 30454341</b>".split(";")
    telefones[3] = "PR;<b>Curitiba</b>;<b>(41) 32082726</b>".split(";")
    telefones[4] = "RS;<b>Porto Alegre</b>;<b>(51) 30422030</b>".split(";")
    telefones[5] = "DF;<b>Brasília</b>;<b>(61) 21055105</b>".split(";")
    telefones[6] = "BA;<b>Salvador</b>;<b>(71) 34163163</b>".split(";")

    var conteudo = "";
    var cont = 0;

    for (i = 0; i < telefones.length; i++) {
        if (estadoSelecionado == telefones[i][0]) {
            cont += 1;

            if (cont == 1) {
                conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
            }
            else {
                if ((cont % 2) == 0) {
                    conteudo += "<tr><td class=\"grid_view_esquerda_bg\"></td><td class=\"grid_view_item_bg_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg\"></td></tr>";
                    //conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
                }
                else {
                    conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
                    //conteudo += "<tr><td class=\"grid_view_esquerda_bg\"></td><td class=\"grid_view_item_bg_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg\"></td></tr>";
                }
            }
        }
    }

    if (conteudo == "" && estadoSelecionado != "") {
        conteudo = "<p>No momento ainda não temos nenhum telefone no seu estado " + estadoSelecionado + ".</p><p class=\"texto\">Por favor, entre em contato através do telefone: <strong>(51) 30422030</strong>.</p>";
    }
    else if (estadoSelecionado != "") {
        conteudo = conteudo.replace("[cont]", cont).replace("[cont]", cont)
        conteudo = "<table class=\"grid_view ultimo_item\" style=\"width:260px;\"><tr><td class=\"grid_view_topo_esquerda_bg\"></td><td class=\"grid_view_topo_bg\" colspan=\"2\"></td><td class=\"grid_view_topo_direita_bg\"></td></tr><tr><td class=\"grid_view_esquerda_bg\"></td><td style=\"padding-bottom: 5px;\"><strong>Cidade</strong></td><td style=\"padding-bottom: 5px;\"><strong>Telefone</strong></td><td class=\"grid_view_direita_bg\"></td></tr>" + conteudo + "<tr class=\"baixo\"><td class=\"grid_view_rodape_esquerda_bg\"></td><td class=\"grid_view_rodape_bg\" colspan=\"2\"></td><td class=\"grid_view_rodape_direita_bg\"></td></tr></table>";
    }

    divTelefone.innerHTML = conteudo;
}

function ExibirTelefones() {
    var estadoSelecionado = document.getElementById('selectEstado').value;
    var divTelefone = document.getElementById('divTelefone');
    var telefones = new Array();

    telefones[0] = "SP;<b>São Paulo</b>;<b>(11) 40620909</b>".split(";")
    telefones[1] = "SP;Campinas;(19) 40620909".split(";")
    telefones[2] = "SP;Jundiaí;(11) 48360909".split(";")
    telefones[3] = "SP;Santos;(13) 40620909".split(";")
    telefones[4] = "SP;Sorocaba;(15) 40620909".split(";")
    telefones[5] = "RJ;<b>Rio de Janeiro</b>;<b>(21) 40620909</b>".split(";")
    telefones[6] = "MG;<b>Belo Horizonte</b>;<b>(31) 40620909</b>".split(";")
    telefones[7] = "PR;<b>Curitiba</b>;<b>(41) 40620909</b>".split(";")
    telefones[8] = "PR;Arapongas;(43) 30550909".split(";")
    telefones[9] = "PR;Apucarana;(43) 40630909".split(";")
    telefones[10] = "PR;Campo Mourão;(44) 30160909".split(";")
    telefones[11] = "PR;Cascavel;(45) 40620909".split(";")
    telefones[12] = "PR;Cianorte;(44) 30180909".split(";")
    telefones[13] = "PR;Foz do Iguaçu;(45) 40520909".split(";")
    telefones[14] = "PR;Francisco Beltrão;(46) 40540909".split(";")
    telefones[15] = "PR;Guarapuava;(42) 40520909".split(";")
    telefones[16] = "PR;Londrina;(43) 40620909".split(";")
    telefones[17] = "PR;Marialva;(44) 30150909".split(";")
    telefones[18] = "PR;Maringá;(44) 40620909".split(";")
    telefones[19] = "PR;Paranaguá;(41) 40640909".split(";")
    telefones[20] = "PR;Paranavai;(44) 40630909".split(";")
    telefones[21] = "PR;Pato Branco;(46) 40550909".split(";")
    telefones[22] = "PR;Ponta Grossa;(42) 40620909".split(";")
    telefones[23] = "PR;Rolândia;(43) 30150909".split(";")
    telefones[24] = "PR;Toledo;(45) 30550909".split(";")
    telefones[25] = "PR;Umuarama;(44) 30550909".split(";")
    telefones[26] = "SC;<b>Florianópolis</b>;<b>(48) 40620909</b>".split(";")
    telefones[27] = "SC;Blumenau;(47) 40520909".split(";")
    telefones[28] = "SC;Brusque;(47) 40530909".split(";")
    telefones[29] = "SC;Criciúma;(48) 40530909".split(";")
    telefones[30] = "SC;Itajaí;(47) 40540909".split(";")
    telefones[31] = "SC;Jaraguá do Sul;(47) 30540909".split(";")
    telefones[32] = "SC;Joinville;(47) 40620909".split(";")
    telefones[33] = "SC;Tubarão;(48) 30520909".split(";")
    telefones[34] = "RS;<b>Porto Alegre</b>;<b>(51) 40620909</b>".split(";")
    telefones[35] = "RS;Bento Gonçalves;(54) 30550909".split(";")
    telefones[36] = "RS;Caxias do Sul;(54) 40620909".split(";")
    telefones[37] = "RS;Erechim;(54) 40640909".split(";")
    telefones[38] = "RS;Farroupilha;(54) 30560909".split(";")
    telefones[39] = "RS;Santa Cruz do Sul;(51) 30560909".split(";")
    telefones[40] = "RS;Montenegro;(51) 30570909".split(";")
    telefones[41] = "RS;Passo Fundo;(54) 40520909".split(";")
    telefones[42] = "RS;Pelotas;(53) 40620909".split(";")
    telefones[43] = "RS;Rio Grande;(53) 40520909".split(";")
    telefones[44] = "RS;Santa Maria;(55) 40620909".split(";")
    telefones[45] = "DF;<b>Brasília</b>;<b>(61) 40620909</b>".split(";")
    telefones[46] = "GO;<b>Goiânia</b>;<b>(62) 40520909</b>".split(";")
    telefones[47] = "GO;Anápolis;(62) 40510909".split(";")
    telefones[48] = "TO;<b>Palmas</b>;<b>(63) 40520909</b>".split(";")
    telefones[49] = "MT;<b>Cuiabá</b>;<b>(65) 40620909</b>".split(";")
    telefones[50] = "MS;<b>Campo Grande</b>;<b>(67) 40620909</b>".split(";")
    telefones[51] = "AC;<b>Rio Branco</b>;<b>(68) 40620909</b>".split(";")
    telefones[52] = "RO;<b>Porto Velho</b>;<b>(69) 40620909</b>".split(";")
    telefones[53] = "BA;<b>Salvador</b>;<b>(71) 40620909</b>".split(";")
    telefones[54] = "PE;<b>Recife</b>;<b>(81) 40620909</b>".split(";")
    telefones[55] = "CE;<b>Fortaleza</b>;<b>(85) 40620909</b>".split(";")
    telefones[56] = "PB;<b>João Pessoa</b>;<b>(83) 40620909</b>".split(";")
    telefones[57] = "PB;Campina Grande;<b>(83) 40640909</b>".split(";")

    var conteudo = "";
    var cont = 0;

    for (i = 0; i < telefones.length; i++) {
        if (estadoSelecionado == telefones[i][0]) {
            cont += 1;

            if (cont == 1) {
                conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
            }
            else {
                if ((cont % 2) == 0) {
                    conteudo += "<tr><td class=\"grid_view_esquerda_bg\"></td><td class=\"grid_view_item_bg_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg\"></td></tr>";
                    //conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
                }
                else {
                    conteudo += "<tr><td class=\"grid_view_esquerda_bg_alternado\"></td><td class=\"grid_view_item_bg_alternado_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg_alternado\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg_alternado\"></td></tr>";
                    //conteudo += "<tr><td class=\"grid_view_esquerda_bg\"></td><td class=\"grid_view_item_bg_titulo\">" + telefones[i][1] + "</td><td class=\"grid_view_item_bg\">" + telefones[i][2] + "</td><td class=\"grid_view_direita_bg\"></td></tr>";
                }
            }
        }
    }

    if (conteudo == "" && estadoSelecionado != "") {
        conteudo = "<p>No momento ainda não temos nenhum telefone no seu estado " + estadoSelecionado + ".</p><p class=\"texto\">Por favor, entre em contato através do telefone: <strong>(11) 40620909</strong>.</p>";
    }
    else if (estadoSelecionado != "") {
        conteudo = conteudo.replace("[cont]", cont).replace("[cont]", cont)
        conteudo = "<table class=\"grid_view ultimo_item\" style=\"width:260px;\"><tr><td class=\"grid_view_topo_esquerda_bg\"></td><td class=\"grid_view_topo_bg\" colspan=\"2\"></td><td class=\"grid_view_topo_direita_bg\"></td></tr><tr><td class=\"grid_view_esquerda_bg\"></td><td style=\"padding-bottom: 5px;\"><strong>Cidade</strong></td><td style=\"padding-bottom: 5px;\"><strong>Telefone</strong></td><td class=\"grid_view_direita_bg\"></td></tr>" + conteudo + "<tr class=\"baixo\"><td class=\"grid_view_rodape_esquerda_bg\"></td><td class=\"grid_view_rodape_bg\" colspan=\"2\"></td><td class=\"grid_view_rodape_direita_bg\"></td></tr></table>";
    }

    divTelefone.innerHTML = conteudo;
}

//abrir("http://www.redehost.com.br") - abre na mesma janela
//abrir("http://www.redehost.com.br","_blank") - abre em uma nova janela
//abrir("http://www.redehost.com.br","popup",500,800) - abre em uma janela popup
var popUpWin = 0;
function abrir(URLStr, NomeJanela, width, height) {
    if (NomeJanela == "_blank") {
        window.open(URLStr, '_blank', '');
    }
    if (NomeJanela == "popup") {
        var top = (screen.height / 2) - (height / 2);
        var left = (screen.width / 2) - (width / 2);

        if (popUpWin) {
            if (!popUpWin.closed) popUpWin.close();
        }
        popUpWin = open(URLStr, 'popUpWin', 'toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top + '');
    }
    if (NomeJanela == "modal") {
        caixa = "window.showModelessDialog(URLStr, 'popUpWin', 'Resizable:no; DialogHeight:" + height + "px; DialogWidth:" + width + "px; Edge:raised; Help:no; Scroll:no; Status:no; Center:yes;');";
        eval(caixa);
    }
    if (NomeJanela == "") {
        window.location.href = URLStr;
    }
}


//FUNÇÕES DA PESQUISA DO WHOIS

//Funções que definem o status da pesquisa de um domínio
function statusDisponivel(imagem) {
    document.getElementById("imgEstatus_" + imagem).src = "/imagens/whois/disponivel.png";
    document.getElementById("imgEstatus_" + imagem).alt = "Domínio disponível para registro.";
    document.getElementById("imgEstatus_" + imagem).title = "Domínio disponível para registro.";

    document.getElementById("registrar_" + imagem).style.display = "inline";
    document.getElementById("whois_" + imagem).style.display = "none";
}

function statusIndisponivel(imagem) {
    document.getElementById("imgEstatus_" + imagem).src = "/imagens/whois/indisponivel.png";
    document.getElementById("imgEstatus_" + imagem).alt = "Domínio já registrado.";
    document.getElementById("imgEstatus_" + imagem).title = "Domínio já registrado.";

    document.getElementById("registrar_" + imagem).style.display = "none";
    document.getElementById("whois_" + imagem).style.display = "inline";
}

function statusPesquisando(imagem) {
    document.getElementById("imgEstatus_" + imagem).src = "/imagens/whois/pesquisando.gif";
    document.getElementById("imgEstatus_" + imagem).alt = "Pesquisando disponibilidade do domínio...";
    document.getElementById("imgEstatus_" + imagem).title = "Pesquisando disponibilidade do domínio...";

    document.getElementById("registrar_" + imagem).style.display = "none";
    document.getElementById("whois_" + imagem).style.display = "none";
}

function ProcessarDominios(nomeDominio, extensao, userContext) {
    statusPesquisando(userContext);
    PageMethods.ProcessarDominios(nomeDominio, extensao, onSuccess, onFailed, userContext, null);
}

function onSuccess(result, userContext, methodName) {
    if (result) {
        statusDisponivel(userContext);
    }
    else {
        statusIndisponivel(userContext);
    }
}

function onFailed(result, userContext, methodName) {
    statusIndisponivel(userContext);
}

//Função que exibe a Popup do consultor
function abrePopupConsultor(alturaPopup, nomeControle) {
    var objTarget = document.getElementById(nomeControle);
    
    if (parseInt(objTarget.style.height.replace("px", "")) < alturaPopup) {
        objTarget.style.height = (parseInt(objTarget.style.height.replace("px", "")) + 10) + 'px';
        
        window.setTimeout("abrePopupConsultor('" + alturaPopup + "','" + nomeControle + "')", "15");
    }
}

//Função responsável por redimensionar a altura algum objeto
function RedimensiosarAlturaObjeto(evento, novaAltura, nomeObjeto) {
    var objTarget = document.getElementById(nomeObjeto);

    if (evento == 'expandir') {

        if (parseInt(objTarget.style.height.replace("px", "")) < novaAltura) {

            objTarget.style.display = '';
            objTarget.style.height = (parseInt(objTarget.style.height.replace("px", "")) + 5) + 'px';

            window.setTimeout("RedimensiosarAlturaObjeto('" + evento + "','" + novaAltura + "','" + nomeObjeto + "')", "15");
        }
    }
    else if (evento == 'recolher') {

        objTarget.style.overflow = 'hidden';

        if (parseInt(objTarget.style.height.replace("px", "")) > novaAltura) {
            objTarget.style.height = (parseInt(objTarget.style.height.replace("px", "")) - 5) + 'px';

            window.setTimeout("RedimensiosarAlturaObjeto('" + evento + "','" + novaAltura + "','" + nomeObjeto + "')", "15");
        }
        else {
            objTarget.style.display = 'none';
        }
    }
}

function HintInput(evento, target, fraseInput, classCSSOff, classCSSOn) {
    var valorInput = document.getElementById(target).value;
    var valorInputPadrao = fraseInput; 

    if (evento == 'onfocus') {
        if (valorInput == valorInputPadrao) {
            document.getElementById(target).value = '';
            document.getElementById(target).className = classCSSOn;
        }
    }
    else if (evento == 'onblur') {
        if (valorInput == valorInputPadrao) {
            document.getElementById(target).className = classCSSOff;
        }
        else if (valorInput == '') {
            document.getElementById(target).value = valorInputPadrao;
            document.getElementById(target).className = classCSSOff;
        }
    }
}

//Função que exibe a Popup do consultor
function redimensionarAltura(alturaPopup, nomeControle, alturaFinal) {

    var objTarget = document.getElementById(nomeControle);

    if (redimensionarAltura.arguments.length == 3) {
        objTarget.style.height = 0;
    }

    if (parseInt(objTarget.style.height.replace("px", "")) < alturaFinal) {
        objTarget.style.height = (parseInt(objTarget.style.height.replace("px", "")) + 7) + 'px';
        window.setTimeout("redimensionarAltura('" + alturaPopup + "','" + nomeControle + "')", "15");
    }
}

function mudarCampo(e, quantidadeCaracteres, campoAnterior, campoAtual, campoDestino) {
    //Código ASCII
    //Tab = 9
    //Backspace = 8
    //Shift = 16

    if (e.keyCode == 8) {
        if (campoAtual.value.length == 0 && campoAnterior != null) {
            campoAnterior.value = campoAnterior.value.substr(0, 4);
            setaPosicaoCursor(campoAnterior, campoAnterior.value.length);
        }
    } else {
        if (e.keyCode != 9 && e.keyCode != 16) {
            if (campoAtual.value.length == quantidadeCaracteres && campoDestino != null) {
                campoDestino.focus();
            }
        }
    }
}

function setaPosicaoCursor(campo, posicao) {
    // IE Support
    if (document.selection) {

        // Set focus on the element
        campo.focus();

        // Create empty selection range
        var oSel = document.selection.createRange();

        // Move selection start and end to 0 position
        oSel.moveStart('character', -campo.value.length);

        // Move selection start and end to desired position
        oSel.moveStart('character', posicao);
        oSel.moveEnd('character', 0);
        oSel.select();
    }

    // Firefox support
    else if (campo.selectionStart || campo.selectionStart == '0') {
        campo.selectionStart = posicao;
        campo.selectionEnd = posicao;
        campo.focus();
    }
}

function HintInputPesquisar(evento, target) {
    var valorInput = document.getElementById(target).value;
    var valorInputPadrao = "Digite palavras chave para pesquisar"

    if (evento == 'onfocus') {
        if (valorInput == valorInputPadrao) {
            document.getElementById(target).value = '';
            document.getElementById(target).className = 'pesquisar_duvidas_textbox';
        }
    }
    else if (evento == 'onblur') {
        if (valorInput == valorInputPadrao) {
            document.getElementById(target).className = 'pesquisar_duvidas_textbox_off';
        }
        else if (valorInput == '') {
            document.getElementById(target).value = valorInputPadrao;
            document.getElementById(target).className = 'pesquisar_duvidas_textbox_off';
        }
    }
}

