function open_window ( s_url, s_name, i_width, i_height, s_param )
{
	if ( i_width <= 0 )
	{
		i_width = screen.availWidth;
	}

	if ( i_height <= 0 )
	{
		i_height = screen.availHeight;
	}

	s_options =
		"directories=no,location=no,menubar=no,status=no,toolbar=no," +
		"resizable=yes,scrollbars=yes," +
		"width=" + i_width + ",height=" + i_height;

	if ( s_param > " " )
	{
		s_options += "," + s_param;
	}

	w = window.open ( s_url, s_name, s_options );
	w.focus();
}

function open_form ( s_url, s_name, s_params )
{
	s_options = "directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no";
	if ( s_params > " " )
		s_options += "," + s_params;
	w = window.open ( s_url, s_name, s_options );
	w.focus();
}

function open_content ( s_submenu_item )
{
	//	debug_form ();
	s_url = s_submenu_item + "/";
	f = document.forms[0];
	e = f.elements;
	s_dir = e["select_report"][e["select_report"].selectedIndex].value;
	s_title = s_submenu_item.replace( /_/gi, " " ) + ' ' +
		e["select_report"][e["select_report"].selectedIndex].text;
	if ( s_dir == "-1" )
	{
		alert ( "Please choose a report!" );
		return;
	}
	s_radio = e["radio_method"];
	j = s_radio.length;
	for ( i=0; i<j; i++ )
	{
		if ( s_radio[i].checked )
			var s_choice = s_radio[i].value;
	}
	switch ( s_choice )
	{
		case "1":	//	indexed table of contents in a frame
			open_window ( "show_content_frame.php?&directory=" + s_url + s_dir +
				"&head_title=" + s_title, "", "", "", "menubar=yes,toolbar=yes,status=yes" );
			break;

		case "2":	//	printer and screen reader-friendly, frameless
			open_window ( "show_content_doc.php?&directory=" + s_url + s_dir +
				"&head_title=" + s_title, "", "", "", "menubar=yes,toolbar=yes,status=yes" );
			break;

		default:
			alert ( "Please choose a viewing method!" );
	}
	//	reset select_report
	e["select_report"].selectedIndex = 0;
}

function debug_form ()
{
	f = document.forms[0];
	e = f.elements;
	s_form = "";
	for ( i = 0; i < e.length; i++ )
	{
		fld = e[i];
		s_form += fld.name + "=" + fld.value + "\n";
	}
	alert ( "Action:\n" + f.action + "\n\nFields:\n" + s_form );
}
