function pop_inc_mensagem(id,i)
{      
	if(i<=100){
		muda_posicao(id,i);
		muda_opacidade(id,i);
		i=Math.round(i) + 2;
		setTimeout("pop_inc_mensagem('" + id + "','" + i + "')", 10);
	}
	
}

function muda_opacidade(id,opacity) 
{ 
	if(opacity>100){
		opacity=100;
	}
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	//object.filter = "alpha(opacity=" + opacity + ")"; 
} 

// Funções para exibir janela de Mensagem ao Usuario
function muda_posicao(id,i)
{
	var posicao = i - 100;
	var object = document.getElementById(id).style;
	object.bottom = posicao + "px";
}

function verificaMsgUsuario()
{
    // Chama aqui também pois essa página pode ser acessada sem ser pela funcoes_master
    if (document.documentElement && document.documentElement.clientWidth)
    { 
        lar = document.documentElement.clientWidth; 
        alt = document.documentElement.clientHeight;
    }
    else if(window.innerWidth)
    { 
        lar = window.innerWidth; 
        alt = window.innerHeight; 
    }
    else if(document.body.clientWidth)
    { 
        lar = document.body.clientWidth; 
        alt = document.body.clientHeight; 
    }     

    width = document.getElementById("div_msgUsuario").style.width.replace("px","").replace("%","");
    document.getElementById("div_msgUsuario").style.left = ((lar-width)/2)-7+'px';    

    if (document.getElementById(MsgUsuarioControl).value == "1") 
    {
        if (document.getElementById(divjanelaespecifica_msgusuario).value == 1)
            document.getElementById("div_msgUsuario").style.zIndex = '300'; /*Z-INDEX do div_fundo mais 1*/
        else
            document.getElementById("div_msgUsuario").style.zIndex = '298'; /*Z-INDEX do div_fundo menos 1*/            
    
        document.getElementById("div_msgUsuario").style.display = 'inline-block';        
        if (document.getElementById(showAnimMsgUsuario).value == "1")
        {
            pop_inc_mensagem('div_msgUsuario', 0);
            document.getElementById(showAnimMsgUsuario).value = "0";
        }
        
        document.getElementById("espaco_msgUsuario").style.display = 'inline';
    } 
    else 
    {
        document.getElementById("div_msgUsuario").style.display = 'none';  
        document.getElementById("espaco_msgUsuario").style.display = 'none';      
    } 
}

function MsgUsuarioClear()
{
    document.getElementById(div_mensagens).innerHTML = "";
}

function MsgUsuarioAddShow(msg,tipo,janelaespecifica)
{
    MsgUsuarioClear();
    MsgUsuarioAdd(msg);
    MsgUsuarioShow(tipo,janelaespecifica);    
}

function MsgUsuarioAdd(msg)
{
    document.getElementById(div_mensagens).innerHTML = document.getElementById(div_mensagens).innerHTML + msg;
}

function MsgUsuarioShow(tipo,janelaespecifica)
{
    if (tipo == "tmErro")
    {
        document.getElementById(div_mensagens).style.backgroundImage = "url(/imagens/fundo_mensagem_vermelho.png)";
        document.getElementById(btFecharMensagens).style.backgroundImage = "url(/imagens/fechar_mensagem_vermelho.png)";
    }
    else if (tipo == "tmConfirmacao")
    {
        document.getElementById(div_mensagens).style.backgroundImage = "url(/imagens/fundo_mensagem_verde.png)";
        document.getElementById(btFecharMensagens).style.backgroundImage = "url(/imagens/fechar_mensagem_verde.png)";
    }
    else
    {
        document.getElementById(div_mensagens).style.backgroundImage = "url(/imagens/fundo_mensagem_laranja.png)";
        document.getElementById(btFecharMensagens).style.backgroundImage = "url(/imagens/fechar_mensagem_laranja.png)";
    }
    document.getElementById(MsgUsuarioControl).value = "1";
    document.getElementById(showAnimMsgUsuario).value = "1";
    document.getElementById(divjanelaespecifica_msgusuario).value = (janelaespecifica ? "1" : "0");
    atualiza();
}

function MsgUsuarioHide()
{
    document.getElementById(MsgUsuarioControl).value = "0";
    document.getElementById(divjanelaespecifica_msgusuario).value = "0";
    atualiza();    
}