/**
 * Displays a centered popup window
 * @param {String} path URL or path to display
 * @param {Number} width Popup window's width
 * @param {Number} height Popup window's height
 * @param {Boolean} fixed If set to true, the window will neither have a
                          statusbar or scrollbars nor will it be resizable,
                          otherwise both will be available
 * @author CB
 * @version 2006-09-09
 */
function popup(path, width, height, fixed) {

	if (!height || !width) {
		// Width and/or height missing, set window width to
		// default value and set fixed to false
		width = 350;
		height = 250;
		fixed = false;
	}

	if (screen.availWidth) {
		position = 'left=' + (Math.floor(screen.availWidth / 2 - width / 2)) +
		           ',top=' + (Math.floor(screen.availHeight / 2 - height / 2));
	}
	else if (window.screenX) {
		position = 'screenX=' + (window.screenX + 50) + ',screenY=' + (window.screenY + 50);
	}
	else {
		position = 'left=120,top=120';
	}

	if (fixed) {
		attrs = 'status=no,resizable=no,scrollbars=no';
	}
	else {
		attrs = 'status=yes,resizable=yes,scrollbars=yes';
	}

	pp = window.open(path, 'Popup', 'width=' + width + ',height=' + height +
	                 ',' + position + attrs);

	pp.focus();

} // function popup(path, width, height, fixed)


/**
 * Returns inner dimensions (content size) of window
 * @return Object with properties 'width' and 'height' or null,
           if dimensions can't be retrieved
 * @author CB
 * @version 2006-09-09
 */
function windowDimensions() {

	if (self.innerHeight) {
		return {width: self.innerWidth, height: self.innerHeight};
	}
	
	if (document.documentElement && document.documentElement.clientHeight) {
		return {width: document.documentElement.clientWidth, height: document.documentElement.clientHeight};
	}
	
	if (document.body) {
		return {width: document.body.clientWidth, height: document.body.clientHeight};
	}

	return null;

} // function windowDimensions()
