function iecompattestPopup(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function centerLayersPopup(layer) {

	ie5=document.all&&document.getElementById
	ns6=document.getElementById&&!document.all
	
	winWidth = ns6? window.innerWidth-20 : iecompattestPopup().clientWidth;
	winHeight = ns6? window.innerHeight-20 : iecompattestPopup().clientHeight;	
	
	layerWidth		= document.getElementById(layer).style.width;	
	layerWidth		= layerWidth.substr(0,layerWidth.length-2);
	
	layerHeight 	= document.getElementById(layer).style.height;	
	layerHeight		= layerHeight.substr(0,layerHeight.length-2);
	
	//alert("valor de widt da janela: "+winWidth+"\nvalor de heigth da janela: "+winHeight+"\nvalor de widt da LAYER: "+layerWidth+"\nvalor de heigth da LAYER: "+layerHeight+"\n");
	winX = Math.ceil((winWidth - layerWidth) / 2);
	winY = Math.ceil((winHeight - layerHeight) / 2);
	
	//alert("valor de left da LAYER: "+winX+"\nTOP da LAYER: "+winY);
	if (winX < 24) {
		winX = 24;
	}
	
	if (winY < 0) {
		winY = 0;
	}
	
	// ANIMAÇÃO DA HOME
	document.getElementById(layer).style.left = winX;
	document.getElementById(layer).style.top = winY;

}

function mostraAnimacao(layer) {	
	centerLayersPopup(layer);
	document.getElementById(layer).style.display = 'inline';
}
function escondeAnimacao(layer) {	
	document.getElementById(layer).style.display = 'none';
}

function esconder(tempo,layer)
{
	setTimeout('escondeAnimacao("'+layer+'")',tempo);	
}

window.onresize = function () { 
	var elementos = document.getElementsByTagName("div");
	var div_ativo   = "";
	
	for(var i=0; i<elementos.length;i++){
         if(elementos[i].style.display=="inline"){
              div_ativo = elementos[i].id;
		 }
	}
	
	centerLayersPopup(div_ativo); 
}