/* centered_popup.js - Open a centered popup window
 * Copyright (C) 2006 David Obwaller <david.obwaller@gmail.com>
 */
function centered_popup(href, name, options) {
	var x, y, width, height;
	var popup_x, popup_y, popup_width=400, popup_height=300;
	var popup_win;
	var option_parts, tmp, i;

	/* Look for width and height values */
	option_parts = options.split(',');
	for (i = 0; i < option_parts.length; i++) {
		tmp = option_parts[i].split('=');
		if (tmp.length > 1) {
			switch (tmp[0]) {
			case 'width':
				popup_width = tmp[1];
				break;
			case 'height':
				popup_height = tmp[1];
				break;
			}
		}
	}

	if (navigator.appName=='Netscape') {
		x = window.screenX;
		y = window.screenY;
		width = window.outerWidth;
		height = window.outerHeight;
	} else {
		width = screen.width;
		height = screen.height;
		x = 0;
		y = 0;
	}

	popup_x = (width/2)-(popup_width/2);
	popup_x = popup_x + x;

	popup_y = (height/2)-(popup_height/2);
	popup_y = popup_y + y;

	if (options.length)
		options = ','+options;

	popup_win = window.open(href, name, 'width='+popup_width+',height='+popup_height+',top='+popup_y+',left='+popup_x+options);

	return popup_win;
}

var Popup = {
    centered: centered_popup
}

