function Coordinate(x, y) {
	function intValue(n){return parseInt(Number(n))}
	var _x = intValue(x),
		_y = intValue(y);
	this.getX = function(){return _x};
	this.getY = function(){return _y};
}

function windowSize(win) {
	var width = 0, height = 0, aux, coord;
	if (!win) {
		win = window;
	}
	if (typeof(win.innerWidth) == "number") {
		// Non-IE
		width = win.innerWidth;
		height = win.innerHeight;
	}
	else if ((aux = win.document.documentElement) && (aux.clientWidth || aux.clientHeight)) {
		// IE 6+ in "standards compliant mode"
		width = aux.clientWidth;
		height = aux.clientHeight;
	}
	else if ((aux = win.document.body) && (aux.clientWidth || aux.clientHeight)) {
		// IE 4 compatible
		width = aux.clientWidth;
		height = aux.clientHeight;
	}
	return new Coordinate(width, height);
}

function scrollOffset(win) {
	var scrOfX = 0, scrOfY = 0, aux, coord;
	if (!win) {
		win = window;
	}
	if (typeof(win.pageYOffset) == "number") {
		// Netscape compliant
		scrOfX = win.pageXOffset;
		scrOfY = win.pageYOffset;
	}
	else if ((aux = win.document.body) && (aux.scrollLeft || aux.scrollTop)) {
		// DOM compliant
		scrOfX = aux.scrollLeft;
		scrOfY = aux.scrollTop;
	}
	else if ((aux = win.document.documentElement) && (aux.scrollLeft || aux.scrollTop)) {
		// IE6 standards compliant mode
		scrOfX = aux.scrollLeft;
		scrOfY = aux.scrollTop;
	}
	return new Coordinate(scrOfX, scrOfY);
}

function resizePopup(id) {
	if (window.frameElement) {
		if (!id) {
			id = "popupContainer";
		}

		var lmnt = document.getElementById(id);
		if (lmnt) {
			try {
				var winSize = windowSize(parent),
					scrollY = scrollOffset(parent).getY(),
					width   = lmnt.offsetWidth,
					height  = lmnt.offsetHeight,
					top     = parseInt(scrollY + (winSize.getY() - height) / 2),
					left    = parseInt((winSize.getX() - width) / 2),
					wfs = window.frameElement.style;
				wfs.width  = width+"px";
				wfs.height = height+"px";
				wfs.top    = (top > 0?  top:  0)+"px";
				wfs.left   = (left > 0? left: 0)+"px";
			}
			catch (e) {
			}
		}
	}
}
