/**
 * Function to open a window and set it to be in focus
 */
function openWindow (url, width, height, scrollable, status, window_name, pop_under)
{
	if (typeof width == "undefined" || width <= 0)
	{
		width = 400;
	}

	if (typeof height == "undefined" || height <= 0)
	{
		height = 400;
	}
	
	if (typeof pop_under == "undefined")
	{
		pop_under = false;
	}

	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	if (typeof window_name == "undefined" || window_name == "")
	{
		window_name = "popup";
	}

	status = (typeof status == "undefined" || !status) ? "no" : "yes";

	var opts = new Array();
	opts[opts.length] = "width=" + width;
	opts[opts.length] = "height=" + height;
	opts[opts.length] = "left=" + left;
	opts[opts.length] = "top=" + top;
	opts[opts.length] = "status=" + status;
	opts[opts.length] = "toolbar=no";
	opts[opts.length] = "menubar=no";

	if (typeof scrollable == "undefined" || !scrollable)
	{
		opts[opts.length] = "scrollbars=no";
		opts[opts.length] = "resizable=no";
	} else
	{
		opts[opts.length] = "scrollbars=yes";
		opts[opts.length] = "resizable=yes";
	}

	var win = window.open(url, window_name, opts.join(','));

	if (typeof win != "undefined" && win != null)
	{
		win.blur();
		if (pop_under) {
			win.blur();
			window.focus();
		} else {
			win.focus();
		}
	}
}