﻿/* 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 CallBanner(valor){
//	if(valor == '1' ){
//		var banner = document.getElementById('CallBanner');
//		if(banner!=null)
//		{
//			banner.style.height = '363px';
//		}
//	}
//	if(valor == '2'){
//		var banner = document.getElementById('CallBanner');
//		if(banner!=null)
//		{
//			banner.style.height = '90px';
//		}
//	}
//} 

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/img/indique_fechar.gif' /></div>"
    box.innerHTML += "<iframe style='margin-left:20px;width:470px;height:270px;float:left;overflow:hidden;' src='/master/indique.aspx?id=" + noticia_id + "' 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 = "";
}

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 + '" allowScriptAccess="always" 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="always">');
    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 + '" allowScriptAccess="always" 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){}
}

var box = null;
var content = null;
var url;

function buildModal(id,largura,altura,titulo) {
   box = document.createElement("div");
   
   url = "http://image.temmais.com/galeria.aspx?id=" + id;
    
    box.style.width = "100%";
    box.style.height = "100%";
    box.style.backgroundColor = "#ccc";
    box.style.position = "fixed";
    box.style.top = 0
    box.style.left = 0
    box.style.zIndex = "2"
    setAlpha(box,60);
    
    /// add in stage
    document.getElementById("Geral").appendChild(box);
    
    content = document.createElement("div");
    
    content.style.border = "solid 1px #f1f1f1";
    content.style.backgroundColor = "#fff";
    content.style.width = largura + "px";
    content.style.height = (altura+30) + "px";
    content.style.position = "fixed";
    //content.style.top = ((screen.height/2)-(altura/2)-30) + "px";
    content.style.top = "50%";
    content.style.marginLeft = (-(altura/2))+"px";
    //content.style.left = (screen.width/2)-(largura/2) + "px";
    content.style.left = "50%";
    content.style.marginTop = (-(largura/2))+"px";
    content.style.zIndex = "3"
    content.innerHTML = "<div style='width:" + (largura-5) + "px;float:left;padding:2px 2px 2px 2px;float:left;background:#fff;overflow:hidden;'><label id='lblTituloGaleria' name='lblTituloGaleria' style='float:left;padding:2px 0 0 5px;color:#333'>" + titulo + "</label><img style='float:right;cursor:pointer;' onclick='javascript:remover();' alt='fechar' src='/master/img/ico_fechar.jpg' /></div>"
    content.innerHTML += "<iframe style='margin-left:10px;width:" + (largura-20) + "px;height:" + (altura) + "px;float:left;overflow:hidden;' src='" + url + "' frameborder='0' scrolling='no'></iframe>"

    /// add in stage
    document.getElementById("Geral").appendChild(content);
}

function remover(){
    
    if(box!=null)
        document.getElementById("Geral").removeChild(box);
    
    if(content!=null)
        document.getElementById("Geral").removeChild(content);
}

function setAlpha(target, alpha) {
    target.style.filter = "alpha(opacity=" + alpha + ")";
    target.style.opacity = alpha / 100;
}


function setTextoIn(obj,texto)
{
    if(obj.value==texto)
    {
        obj.value='';
    }
}
function setTextoOut(obj,texto)
{
    if(obj.value=='')
    {
        obj.value=texto;
    }
}

