function popupInterno(id_div, nome_instancia, largura_popup, altura_popup) {

	// ==================================================================================
	// CONFIGURAÇÕES: ===================================================================
	// ==================================================================================
	var LARGURA_POPUP_PADRAO = 300;
	var ALTURA_POPUP_PADRAO = 200;
	
	// ==================================================================================
	// ATRIBUTOS: =======================================================================
	// ==================================================================================
	this.scrollTop;
	this.altura_html;
	this.adicional_posicao_X = 0;
	this.adicional_posicao_Y = 0

	// ==================================================================================
	// MÉTODOS: =========================================================================
	// ==================================================================================
	
	this.exibir = exibir;
	this.verificarDimensoesInternas = verificarDimensoesInternas;
	this.posicionarPopupInterno = posicionarPopupInterno;
	this.ocultar = ocultar;

	function verificarDimensoesInternas() {
		// VERIFICAR A ALTURA E LARGURA INTERNA DO BROWSER: =============
		if (self.innerHeight) {	
			// todos browsers menos o IE:
			this.largura_interna_janela = self.innerWidth;
			this.altura_interna_janela = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			// IE em strict mode:
			this.largura_interna_janela = document.documentElement.clientWidth;
			this.altura_interna_janela = document.documentElement.clientHeight;
		} else if (document.body) {
			// outros explorers:
			this.largura_interna_janela = document.body.clientWidth;
			this.altura_interna_janela = document.body.clientHeight;
		}
		// VERIFICAR SCROLL:
		if (document.documentElement && document.documentElement.scrollTop) {
			// Internet explorer:
			this.scrollTop = document.documentElement.scrollTop;
		} else if (document.body) {
			// firefox:
			this.scrollTop = document.body.scrollTop;
		} 
	}

	function exibir() {
		this.verificarDimensoesInternas();
		// exibir tampa:
		document.getElementById('popupInterno_tampa').style.display = 'block';
		if(!this.altura_html) {
			document.getElementById('popupInterno_tampa').style.height = this.altura_interna_janela + this.altura_interna_janela + this.altura_interna_janela + this.scrollTop + 'px';
		} else {
			document.getElementById('popupInterno_tampa').style.height = this.altura_html + 'px';
		}
		// exibir janela:
		setTimeout("document.getElementById('" + id_div + "').style.display = 'block'; ", 0);
		// posicionar janela:
		this.posicionarPopupInterno();
		// setar tamanho da janela:
		document.getElementById(id_div).style.width = largura_popup + 'px';
		document.getElementById(id_div).style.height = altura_popup + 'px';
		// setar onscroll:
		window.onscroll = function() { eval(nome_instancia + '.posicionarPopupInterno(true); '); }
		window.onresize = window.onscroll;
	}

	function posicionarPopupInterno(verificar_dimensoes_internas) {
		if(verificar_dimensoes_internas) {
			this.verificarDimensoesInternas();
		}
		// CALCULAR E POSICIONAR: =========================================
		posicaoX = Math.round((this.largura_interna_janela - largura_popup) / 2) + this.adicional_posicao_X;
		posicaoY = this.scrollTop + Math.round((this.altura_interna_janela - altura_popup) / 2) + this.adicional_posicao_Y;
		document.getElementById(id_div).style.top = posicaoY + 'px';
		document.getElementById(id_div).style.left = posicaoX + 'px';
	}
	
	function ocultar() {
		// OCULTAR: 
		document.getElementById('popupInterno_tampa').style.display = 'none';
		document.getElementById(id_div).style.display = 'none';
	}


	// ==================================================================================
	// INICIALIZAÇÃO: ===================================================================
	// ==================================================================================
	
	// SETAR STYLES DA DIV:
	document.getElementById(id_div).style.position = 'absolute';
	document.getElementById(id_div).style.zIndex = '2';
	document.getElementById(id_div).style.display = 'none';
	// LARGURA E ALTURA:
	if(!largura_popup) {
		largura_popup = document.getElementById(id_div).style.width.replace('px', '');
		if(!largura_popup) {
			largura_popup = LARGURA_POPUP_PADRAO;
		}
	}
	if(!altura_popup) {
		altura_popup = document.getElementById(id_div).style.height.replace('px', '');
		if(!altura_popup) {
			altura_popup = ALTURA_POPUP_PADRAO;
		}
	}

	// VERIFICAR ALTURA DO HTML E SCROLL:
	this.verificarDimensoesInternas();

	// Internet explorer:
	this.scrollTop = document.documentElement.scrollTop;
	document.documentElement.scrollTop = 10000;
	this.altura_html = document.documentElement.scrollTop + this.altura_interna_janela;
	document.documentElement.scrollTop = this.scrollTop;

	if (typeof(this.altura_html) != 'number' && document.body) {
		// firefox:
		this.scrollTop = document.body.scrollTop;
		document.body.scrollTop = 10000;
		this.altura_html = document.body.scrollTop + this.altura_interna_janela;
		document.body.scrollTop = this.scrollTop;
	} 
	
	// CRIAR DIV DE TAMPA DO CONTEÚDO;
	if(!document.getElementById('popupInterno_tampa')) {
		divTampa = document.createElement('div');
		divTampa.setAttribute('id', 'popupInterno_tampa');
		document.body.appendChild(divTampa);
	}

}
