function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function centerLayers() {

	var ie5=document.all&&document.getElementById
	var ns6=document.getElementById&&!document.all
	
	//winWidth = ns6? window.innerWidth-20 : iecompattest().clientWidth;
	var winWidth = 760;
	var winHeight = ns6? window.innerHeight-20 : iecompattest().clientHeight;	
	
	var popupWidth		= document.getElementById("FloatingLayer").style.width;	
	var popupWidth		= popupWidth.substr(0,popupWidth.length-2);
	
	var popupHeight 	= document.getElementById("FloatingLayer").style.height;	
	var popupHeight		= popupHeight.substr(0,popupHeight.length-2);
	
	var winX = Math.ceil((winWidth - popupWidth) / 2);
	var winY = Math.ceil((winHeight - popupHeight	) / 2);
	
	// CARREGANDO
	//document.getElementById("LoadingContent").style.left = Math.ceil((winWidth - 130) / 2);
	document.getElementById("LoadingContent").style.left = '315px';
	
	// POPUP
	document.getElementById("FloatingLayer").style.left = winX;
	document.getElementById("FloatingLayer").style.top = (scrollY() + winY) + 'px';

}

function scrollY() {
	
	var scrolledY = 0;
	
	var ie5=document.all&&document.getElementById
	var ns6=document.getElementById&&!document.all
	
	if (ns6)  {
		scrolledY = window.pageYOffset;
	} else  {
		scrolledY = document.body.scrollTop;
	}
	
	return scrolledY;
	
}

/*******************************************************************************************
CARREGANDO
*******************************************************************************************/

function mostraCarregando() {	
	
	// fecha a popup
	fechaPopup();
	
	// abre o carregando
	ToggleFloatingLayer("LoadingContent",1);	
	
}

function escondeCarregando() {	
	scrollTo(0,0);
	ToggleFloatingLayer("LoadingContent",0);
}


/*******************************************************************************************
EVENTOS
*******************************************************************************************/

window.onresize = centerLayers;



