﻿// JScript File

function boxNewsLetter(id)
{
if (document.getElementById(id).style.display == "block")
	
	{
		document.getElementById(id).style.display = "none";
	}
	else
	{
		document.getElementById(id).style.display = "block";		
	}
}

function showIndique(e) {
    if (document.all) e = event;

    var obj = document.getElementById('newsletter');
    //var obj2 = document.getElementById('newsletter');
    //text = document.getElementById('newsletter').value;
    //obj2.innerHTML = text;
    obj.style.display = 'block';
    var st = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
    if (navigator.userAgent.toLowerCase().indexOf('safari') >= 0) st = 0;
    var leftPos = e.clientX - 50;
    if (leftPos < 0) leftPos = 0;
    obj.style.left = leftPos + 'px';
    obj.style.top = e.clientY - obj.offsetHeight - 1 + st + 'px';
}
function hideIndique() {
    document.getElementById('newsletter').style.display = 'none';
}

function changeInnerHTML(divId, html) {
    var e = null;
    if (document.getElementById) {
        e = document.getElementById(divId);
        if (!e) return false;
        if ("innerHTML" in e) {
            e.innerHTML = html; return true
        }
        else if ("firstChild" in e && "data" in e.firstChild) {
            e.firstChild.data = html; return true;
        }
        else {
            return false;
        }
    } else if (document.layers) {
        e = document.layers[divId];
        if (typeof e == "undefined" || !e) {
            e = document[divId];
            if (typeof e == "undefined" || !e) return false;
        }
        e.document.open();
        e.document.write(html);
        e.document.close();
        return true;
    } else if (document.all) {
        e = document.all[divId];
        if (typeof e == "undefined" || !e) return false;
        e.innerHTML = html;
        return true;
    }
    return false;
}


// funcionamento do menu lateral
$(document).ready(function () {

    // Div 1
    $("#divUm").hide();
    $("#um").click(function () {
        $("#divUm").slideToggle("slow");
    });

    // Div 2
    $("#divDois").hide();
    $("#dois").click(function () {
        $("#divDois").slideToggle("slow");
    });

    // Div 3
    $("#divTres").hide();
    $("#tres").click(function () {
        $("#divTres").slideToggle("slow");
    });

    // Div 4
    $("#divQuatro").hide();
    $("#quatro").click(function () {
        $("#divQuatro").slideToggle("slow");
    });

    // Div 5
    $("#divCinco").hide();
    $("#cinco").click(function () {
        $("#divCinco").slideToggle("slow");
    });

    // Div 6
    $("#divSeis").hide();
    $("#seis").click(function () {
        $("#divSeis").slideToggle("slow");
    });

    // Div 7
    $("#divSete").hide();
    $("#sete").click(function () {
        $("#divSete").slideToggle("slow");
    });

    // Div 8
    $("#divOito").hide();
    $("#oito").click(function () {
        $("#divOito").slideToggle("slow");
    });

    // Div 9
    $("#divNove").hide();
    $("#nove").click(function () {
        $("#divNove").slideToggle("slow");
    });

    // Div 10
    $("#divDez").hide();
    $("#dez").click(function () {
        $("#divDez").slideToggle("slow");
    });
});


function abreUpload(x) {

    document.getElementById('Panel1').style.display = x;
}

function divArquivo(obj,comp) {

    var IE = (navigator.appVersion.indexOf("MSIE") > -1);

    function showTR(id, show) {
        var obj = document.getElementById(id);
        obj.style.display = !show ? "none" : IE ? "inline" : "table-row";
    }

    //alert(obj.id + " - " + "ctl00_MainContent_rdb" + comp + "sim");
    if (obj.id == "ctl00_MainContent_rdb" + comp + "sim" && obj.value == "sim") {
        showTR("divArquivo1" + comp, true);
        showTR("divArquivo2" + comp, false);
    }
    else {

        //alert("ctl00_MainContent_trArquivo1B - " + "trArquivo1" + comp)
        showTR("divArquivo1" + comp, false);
        showTR("divArquivo2" + comp, true);
    }

    //ctl00_MainContent_trArquivo1B

}

function getinfo(ddl) {

    var IE = (navigator.appVersion.indexOf("MSIE") > -1);

    function showTR(id, show) {
        var obj = document.getElementById(id);
        obj.style.display = !show ? "none" : IE ? "inline" : "table-row";
    }

    if (ddl.options[ddl.selectedIndex].text == "OUTROS") {
        showTR("Outros", true);
        showTR("ctl00_MainContent_txtOutros", true);
    } else {
        showTR("Outros", false);
        showTR("ctl00_MainContent_txtOutros", false);
    }

}

function getpagamentos(ddl) {

    var IE = (navigator.appVersion.indexOf("MSIE") > -1);

    function showTR(id, show) {
        var obj = document.getElementById(id);
        obj.style.display = !show ? "none" : IE ? "inline" : "table-row";
    }

    if (ddl.options[ddl.selectedIndex].text == "Boleto") {
        showTR("trBanco", false);
        showTR("ctl00_MainContent_trBanco2", false);
        showTR("trAgencia", false);
        showTR("ctl00_MainContent_trAgencia2", false);
    } else {
        showTR("trBanco", true);
        showTR("ctl00_MainContent_trBanco2", true);
        showTR("trAgencia", true);
        showTR("ctl00_MainContent_trAgencia2", true);
    }

}

function tecla(obj, a, id) {

    //alert("entrou");
    var Key = a.keyCode || a.which;
    //alert(id);
    if (Key == "13" || id == 13) {
//        alert("entrou2");
//        alert(obj);
//        alert(obj.value);
        if (obj.value.length < 2) {
            alert('digite no mínimo 3 caracteres para a busca');
            return false;
            //alert("entrou3=" + obj.value.length);
        }
        //alert("entrou4=" + obj.value.length);
        //PageMethods.RegistraClique("BuscaSugerida", "busca-resultado.aspx?parametros=" + $get('menutopo_txt_busca').value, 0, registroubuscasugerida, null);
        window.location.href = 'busca-resultado.aspx?parametros=' + obj.value;
        //alert("redireciona");
        return false;
    }
    else {
        return true;
    }
}
function teclaCampanha(a) {
    var Key = a.keyCode || a.which;
    if (Key == "13") {
        PageMethods.RegistraClique("BuscaSugerida", "../busca-resultado.aspx?parametros=" + $get('txt_busca').value, 0, registroubuscasugeridaCampanha, null);
        return false;
    }
    else {
        return true;
    }
}
function registroubuscasugerida() {
    window.location.href = 'busca-resultado.aspx?parametros=' + $get('menutopo_txt_busca').value;
}
function registroubuscasugeridaCampanha() {
    window.location.href = '../busca-resultado.aspx?parametros=' + $get('txt_busca').value;
}
