var child_window = null;

function openWindow(theURL,winName,width,height) {
	var x = 0;
	var y = 0;
	var resizable_scrollbars_text = "scrollbars=yes,resizable=yes";
	
	if (width > height) {
		height += 140;	
	}
	else {
		width += 280;
	}

	if (window.screen) {
		var screen_width = screen.availWidth;
		var screen_height = screen.availHeight;
		if ( (screen_width > width) && (screen_height > height) )
		{
			resizable_scrollbars_text = "scrollbars=no,resizable=yes";
		}
		width = Math.min (screen_width, width);
		height = Math.min (screen_height, height);
		// center the window
		x = Math.max (0, (screen_width - width) / 2);
		y = Math.max (0, (screen_height - height) / 2);
	}
	// scrollbars=no shouldn't be necessary,  but ie5 mac doesn't size the window appropriately if omitted
	child_window = window.open(theURL, winName, "width=" + width + ",height=" + height + ",left=" + x + ",screenX=" + x + ",top=" + y + ",screenY=" + y + ",status=no," + resizable_scrollbars_text);
	//child_window = window.open(theURL, winName);
	child_window.focus();
	if (child_window && child_window.open && !child_window.closed) {
		child_window.focus(); // ie 5.0 win is deaf?
	}
	return false;
}
