tela = {
	moveTo : function(x,y) { window.scroll(x,y); },
	moveBy : function(x,y) { this.moveTo(this.sx()+x,this.sy()+y) },
	sx : function() { return (document.body) ? (document.body.scrollLeft) : (window.pageXOffset) },
	sy : function() { return (document.body) ? (document.body.scrollTop) : (window.pageYOffset) },
	dw : function() { return (document.body) ? (document.body.scrollWidth) : (document.width) },
	dh : function() { return (document.body) ? (document.body.scrollHeight) : (document.height) },
	ww : function() { return (document.body) ? (document.body.clientWidth) : (window.innerWidth) },
	wh : function() { return (document.body) ? (document.body.clientHeight) : (window.innerHeight) },
	sw : function() { return (screen.width) },
	sh : function() { return (screen.height) }
};

function consultarInformacoesAjax(url, objResultado){
	var urlComp = url;
	
	objResultado.innerHTML = "<img src='img/ajax-loader.gif' vspace='200'>";
	
	new Ajax.Request(urlComp, {method: 'get',
	  	onSuccess: function(transport) {
			if (transport.responseText != null){
				objResultado.innerHTML = transport.responseText;
			}
		//onComplete: loadingFechar()
		}
	});
}

function popup(pagina, largura, altura, nome, mais) {

	if(largura > tela.sw()) {
		largura = tela.sw()-50;
		mais = "scrollbars = yes";
	}
	if(altura > tela.sh()) {
		altura = tela.sh()-65;
		mais = "scrollbars = yes";
	}

	calcleft = (tela.sw() / 2) - (largura / 2);
	calctop = (tela.sh() / 2) - (altura / 2);
	
	pop = window.open(''+pagina+'',''+nome+'','width='+largura+',height='+altura+',left='+calcleft+',top='+(calctop-30)+',scrollbars=1'+((mais)?','+mais:''));
	pop.focus();
}

function setPopBodySize(){
	var width = document.body.scrollWidth - document.body.clientWidth;
	var height = document.body.scrollHeight - document.body.clientHeight;
	window.resizeBy(width, height);
	
	calcleft = (tela.sw() / 2) - (document.body.clientWidth / 2);
	calctop = (tela.sh() / 2) - (document.body.clientHeight / 2);
	window.moveTo(calcleft, calctop-25);
}
