var nomesJanelas = new Array();
nomesJanelas.push("player");

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function centerPlayer(tipo) {

	var ie5=document.all&&document.getElementById
	var ns6=document.getElementById&&!document.all
	
	var winWidth = ns6? window.innerWidth-40 : iecompattest().clientWidth - 40;
	var winHeight = ns6? window.innerHeight-40 : iecompattest().clientHeight - 40;	
	
	if (arguments.length > 1) {
		if (arguments[1] != undefined) {
			var scrollY = arguments[1];
		} else {
			var scrollY = 0;
		}
		if (arguments[2] != undefined) {
			var scrollX = arguments[2];
		} else {
			var scrollX = 0;
		}
	} else {
		var scrollY = 0;
		var scrollX = 0;
	}
	
	for (var i = 0; i < nomesJanelas.length; i++) {
		
		var nome = nomesJanelas[i]; 
		
		var popupWidth	= document.getElementById(nome).style.width;	
		var popupWidth	= popupWidth.substr(0,popupWidth.length-2);
		
		var popupHeight 	= document.getElementById(nome).style.height;	
		var popupHeight	= popupHeight.substr(0,popupHeight.length-2);
		
		var winX = Math.ceil((winWidth - popupWidth) / 2);
		var winY = Math.ceil((winHeight - popupHeight) / 2);
		
	
		// POPUP
		winX = (winX - scrollX - ((tipo == "home") ? 78 : 248));
		winY = ((tipo == "home") ? 33 - scrollY : winY - scrollY + 960 );
		
		if (tipo == "home" && winX < 189) {
			winX = 189 - scrollX;
		}
		
		if (tipo == "internas" && winX < 59) {
			winX = 189 - scrollX;
		}
		                          
		if (tipo == "internas" && winY < 550) {
			winY = 0 - scrollY;
		}
		
		document.getElementById(nome).style.left =  winX + 'px';
		document.getElementById(nome).style.top = winY + 'px';
		document.getElementById(nome).style.visibility = "visible";
		
	}

}

function carregaModulo(modulo)
{
	if (modulo == "home") {
		centerPlayer("home");
		window.ConteudoSite.location = 'homenova.php';		
	} else {
		centerPlayer("internas");
		window.ConteudoSite.location = 'index2.php?secao=' + modulo;
	}
}

function resizeBrowser(x,y)
{
	var locationFrame =  window.ConteudoSite.location;
	if(locationFrame.search == "") {
		centerPlayer("home",y,x);
	} else {
		centerPlayer("internas",y,x);
	}
}
