﻿/* fechar DHTML */
function fechar() {
    try {
        var obj = document.getElementById('ctl00_div_dhtml_home');
        if (obj.style.visibility == 'hidden') {
            obj.style.visibility = 'visible';
            obj.style.width = 'auto';
            obj.style.height = 'auto';
        }
        else {
            obj.style.visibility = 'hidden';
            obj.style.overflow = 'hidden';
            obj.style.width = '1px';
            obj.style.height = '1px';
            obj.style.bottom = '1px';
            obj.style.right = '1px';
			//obj.style.left = '-9000px';
			obj.style.display = 'none'
           // alert("aaa" + obj.style.right)
			//alert('123456');
        }

    } catch (e) {
        status = e.message
    }
}

function addLoadEvent(func) { 
    var oldonload = window.onload; 
    if (typeof window.onload != 'function') { 
        window.onload = func; 
    } else { 
        window.onload = function() { 
	        if (oldonload) { 
		        oldonload(); 
	        } 
	        func(); 
        } 
    } 
} 

//window.load = function(){
//   setTimeout(fechar,15000);
//   
//}

/* validar a busca */
function verBusca(){
    var objBusca = document.getElementById("ctl00_txtBusca");
    if ((objBusca.value == "") || (objBusca.value == "buscar")) {
        alert("ATENÇÂO!! \n Digite o que deseja buscar.");
        return false;
    } else {
        if (objBusca.value.lenght < 3) { alert("ATENÇÂO!! \n Digite no mínimo 3 letras."); return false; }
    }
}

function verBusca2(){
    var objBusca = document.getElementById("ctl00_txtFooterBusca");
    if ((objBusca.value == "") || (objBusca.value == "buscar")) {
        alert("ATENÇÂO!! \n Digite o que deseja buscar.");
        return false;
    } else {
        if (objBusca.value.lenght < 3) { alert("ATENÇÂO!! \n Digite no mínimo 3 letras."); return false; }
    }
}
    
function setOver() {
    try{
    
        var arrLi = document.getElementById("content_central").getElementsByTagName("li");

        for (var i = 0; i < arrLi.length; i++) {
            if ((arrLi[i].id != undefined) && (arrLi[i].id.indexOf("box_li_") >= 0)) {
                arrLi[i].onmouseover = function() { this.className = "css_bg_" + this.id.substring(this.id.indexOf("_box_li_") + 8); this.getElementsByTagName("strong")[0].className = "over_" + this.getElementsByTagName("strong")[0].className; }
                arrLi[i].onmouseout = function() { this.className = ""; this.getElementsByTagName("strong")[0].className = this.getElementsByTagName("strong")[0].className.substring(5); }
            }
        }
    }catch(e){}
}

function replace_in() {
    try{
        document.getElementById("ctl00_cph_txtMensagem").value = document.getElementById("ctl00_cph_txtMensagem").value.replace(/\n/g, "<br />");
    }catch(e){}
}

function replace_out(box) {
    try{
        box.value = box.value.replace(regX, "<br /> \n");
    }catch(e){}
}
///////////////////////////////////
// exibe o formulario de indicação
///////////////////////////////////
function show_indique(noticia_id) {
    var box = document.createElement("div");

    box.id = "pnl_indique";

    box.style.width = "500px";
    box.style.height = "300px";

    box.style.backgroundColor = "#fff";
    box.style.position = "absolute";
    box.style.border = "solid 1px #A5A5C0";
    box.style.zIndex = "3"

    box.innerHTML = "<div style='width:495px;float:left;padding-top:5px;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_indique();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='margin-left:20px;width:470px;height:270px;float:left;overflow:hidden;' src='/indique.aspx?id=" + noticia_id + "' frameborder='0' scrolling='no'></iframe>"

    document.getElementById("box_form").appendChild(box);
}

function show_indique_2(noticia_id,canal) {
    var box = document.createElement("div");

    box.id = "pnl_indique";

    box.style.width = "500px";
    box.style.height = "300px";

    box.style.backgroundColor = "#fff";
    box.style.position = "absolute";
    box.style.border = "solid 1px #A5A5C0";
    box.style.zIndex = "3"

    box.innerHTML = "<div style='width:495px;float:left;padding-top:5px;'><img style='float:right;cursor:pointer;' onclick='javascript:fechar_indique();' alt='fechar' src='/master/imagem/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='margin-left:20px;width:470px;height:270px;float:left;overflow:hidden;' src='/indique.aspx?id=" + noticia_id + "&canal_id=" + canal + "' frameborder='0' scrolling='no'></iframe>"

    document.getElementById("box_form").appendChild(box);
}

function fechar_indique() {
    if(confirm("tem certeza que deseja cancelar a mensagem?"))
        document.getElementById("box_form").innerHTML = "";
}

////////////////////////////////////////////////////////////////////////////////////
// Verifica qual campo está sendo digitado e dá o focus no botão correspondente
////////////////////////////////////////////////////////////////////////////////////
function setFocus(e, botaoId) {
    try{
        var tecla = window.event ? e.keyCode : e.which;

        if (tecla == 13) {
            document.getElementById('ctl00_' + botaoId).focus();
            document.getElementById('ctl00_' + botaoId).click();
        }
    }catch(e){}
}

/////////////////////////////
// Campos de Busca
/////////////////////////////
function limpaBox(Campo, mensagem) {
    if (document.getElementById(Campo).value == mensagem) {
        document.getElementById(Campo).value = "";
    }
}

function verBox(Campo, mensagem) {
    if (document.getElementById(Campo).value == "") {
        document.getElementById(Campo).value = mensagem;
    }
}

function InsereFlash(Arquivo, Largura, Altura, FlashVars) {
    document.write('<object codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"');
    document.write('height="' + Altura + '" width="' + Largura + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>');
    document.write('<param name="_cx" value="15425">');
    document.write('<param name="_cy" value="741">');
    document.write('<param name="FlashVars" value="' + FlashVars + '">');
    document.write('<param name="Movie" value="' + Arquivo + '">');
    document.write('<param name="Src" value="' + Arquivo + '">');
    document.write('<param name="WMode" value="Transparent">');
    document.write('<param name="Play" value="-1">');
    document.write('<param name="Loop" value="-1">');
    document.write('<param name="Quality" value="High">');
    document.write('<param name="SAlign" value="">');
    document.write('<param name="Menu" value="-1">');
    document.write('<param name="Base" value="">');
    document.write('<param name="AllowScriptAccess" value="">');
    document.write('<param name="Scale" value="noscale">');
    document.write('<param name="DeviceFont" value="0">');
    document.write('<param name="EmbedMovie" value="0">');
    document.write('<param name="BGColor" value="">');
    document.write('<param name="SWRemote" value="">');
    document.write('<param name="MovieData" value="">');
    document.write('<param name="SeamlessTabbing" value="1">');
    document.write('<param name="Profile" value="0">');
    document.write('<param name="ProfileAddress" value="">');
    document.write('<param name="ProfilePort" value="0">');
    document.write('<embed src="' + Arquivo + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ');
    document.write('type="application/x-shockwave-flash" width="' + Largura + '" height="' + Altura + '" FlashVars="' + FlashVars + '" ');
    document.write('_cx="15425" _cy="741" WMode="Transparent" Menu="-1" Scale="noscale" DeviceFont="0" EmbedMovie="0" SeamlessTabbing="1" Profile="0" ProfilePort="0"></embed>');
    document.write('</object>');
}

////////////////////////////////////////
// aumenta fonte
////////////////////////////////////////
function sizeFont(elem, acao) {
    try{
        // tamanho inicial da fonte (em px)
        var tamInic = 14;
        // Tamanho mÃ­nimo da [b]fonte (em px)
        var tamMin = 12;
        // Tamanho mÃ¡ximo da fonte (em px)
        var tamMax = 17;
        
        // Pega o tamanho da fonte. Se nÃ£o foi setada ainda (primeira vez que a funÃ§Ã£o Ã© executada) terÃ¡ como tamanho padrÃ£o 'tamInic'.
        if (document.getElementById(elem).style.fontSize == "") {
            var tamFonte = tamInic;
        } else {
            var tamFonte = parseInt(document.getElementById(elem).style.fontSize);
        }
        switch (acao) {
            // Aumenta o tamanho, enquanto foi menor que 'tamMax' 
            case '+':
                if (tamFonte < tamMax)
                    document.getElementById(elem).style.fontSize = (tamFonte + 1) + "px";
                break;
            // Diminui o tamanbo, enquanto for maior que 'tamMin' 
            case '-':
                if (tamFonte > tamMin)
                    document.getElementById(elem).style.fontSize = (tamFonte - 1) + "px";
                break;
        }
    }catch(e){}
}

/////////////////////////////////
// aplicar alpha
///////////////////////////////
function setAlpha(target, alpha) {
    target.style.filter = "alpha(opacity=" + alpha + ")";
    target.style.opacity = alpha / 100;
}
