fechar = function() {
	if(window.opener) window.opener.focus();
	window.top.close();
}

abreLink = function(p) {
	if (window.opener && !window.opener.closed) {
		window.opener.location.href = p;
		window.opener.focus();
	} else {
		window.open(p, '_blank');
	}
}

// Função Popup: <a href="arquivo.ext" onclick="popups(this.href,'360','535','1'); return false;"></a>
function abrePopup(pg,nome,fs,w,h,rolagem) {
	if(fs) { // fullscreen
		var w=screen.availWidth,h=screen.availHeight;
		var winObj = window.open("about:blank",nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left=0,top=0');
		winObj.top.location.href=pg;
		with(winObj) { resizeTo(w,h); focus(); }
	} else { // popup normal
		var winObj=window.open("about:blank",nome,'width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+rolagem+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
		winObj.top.location.href=pg;
		winObj.focus();
	}
}

//FUNÇÃO PARA PEGAR OBJETOS
function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		} else {
			this.obj = document.layers.testP.layers[name];
			this.style = document.layers.testP.layers[name];
		}
	}
}
//FUNÇÃO PARA PEGAR A POSIÇÃO X DE UM OBJETO
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
//FUNÇÃO PARA PEGAR A POSIÇÃO Y DE UM OBJETO
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
