/// POPUPS
///
/// Abertura de janelas de apoio.
///
x=function(){
var EM = 0, EX = 0;


// Abre uma nova janela com o endereço e dimensões especificadas.
W.pop = function (uri, w, h, optNm, optL, optT, optNoScroll, optNoResz) {
	var sw = screen.availWidth, sh = screen.availHeight, t, l, props;
	// Calcular dimensões e coordenadas.
	EM || measureEMX_();
	w = translateCoord_(w, sw);
	h = translateCoord_(h, sh);
	l = optL ? translateCoord_ (optL - 1, sw) : Math.floor ((sw - w) / 2);
	t = optT ? translateCoord_ (optT - 1, sh) : (Math.floor ((sh - h) / 2) - 3 * EM);
	// Criar as propriedades.
	props = "location=no,status=no,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",scrollbars=" + yn_(!optNoScroll) + ",resizable=" + yn_(!optNoResz);
	// Abrir.
	t = W.open (uri, optNm || "pop", props)
	try {	t.focus ()	}	catch (e) {}

	return t;

	// Retorna o valor em píxeis correspondente a C.
	function translateCoord_(c, sd) {
		var unit = "", conv = 1;

		if (isNaN (c)) {
			// Extraír a indicação da coordenada.
			if (c.substr (-1) == "%") {
				unit = "%";
				conv = sd / 100
			}
			else switch (unit = c.substr (-2)) {
			case "em":
				conv = EM;
				break;
			case "ex":
				conv = EX;
				break;
			case "px":
				break;
			default:
				return 0;
			}
			c = +c.slice (0, c.length - unit.length);
			if (isNaN (c)) return 0
		}

		return Math.floor (c * conv)
	}

	// Coloca os tamanhos em píxeis das unidades "em" e "ex" nas variáveis globais EM e EX.
	function measureEMX_() {
		var el, st, b = D.body;
		if (!b) return EM = 15;
		el = __med__ = D.createElement ("P");
		el.innerHTML = "0";
		st = el.style;
		st.overflow = "hidden";
		st.display = "block";
		st.visibility = "hidden";
		st.position = "absolute";
		st.width = "1em";
		st.height = "1ex";
		b.appendChild (el);

		EM = el.offsetWidth;
		EX = el.offsetHeight;
		b.removeChild (el)
	}

	// Retorna B na forma "yes" ou "no".
	function yn_(b) {	return b ? "yes" : "no"	}
}

}();


Im ("popups")

