//---------------------------------------------------------------
//  Size the page appropriately for the monitor
//---------------------------------------------------------------

function resize_browser(width, height) 
{
	if (width && height) 
  		window.resizeTo(width, height);
	else
	{
  			if (screen.width <= 640)
    			win_width = 640;
  			else
    			win_width = 760;

  			if (screen.height <= 600)
    			win_height = 550;
  			else if (screen.height <= 768)
    			win_height = 740;
  			else 
    			win_height = 910;

  			window.resizeTo(win_width, win_height);
	}
}

/*---------------------------------------------------------------
	IE won't allow a window to change its own chrome via
	Javascript, though Netscape does (did?).  Popper-stoppers
	look for this.
---------------------------------------------------------------*/

function no_chrome()
{
	//	Nope...

	window.self.menubar.visible     = false;
	window.self.toolbar.visible     = false;
	window.self.locationbar.visible = false;
	window.self.personalbar.visible = false;
	window.self.statusbar.visible   = false;

	//	Nope...

	var elem, str;

	str = "toolbar";

	if (document.getElementById) {
		elem = document.getElementById(str);
		elem.style.display = false;
	}
	else 
		document.all[str].style.display = false; 
}


//---------------------------------------------------------------
//	Pop up a new copy of the browser, aimed at the caller's URL
//
//	A handle to the new browser is returned, which can be
//	use to close or otherwise control it.
//---------------------------------------------------------------

function new_browser(		//	open another copy of the browser	
	url						//	open this url, which may have args
){
	obj = window.open(url);
	return(obj);
}

function close_browser(		//	open another copy of the browser	
	obj						//	open this url
){
	obj.close();
}

//---------------------------------------------------------------
//  Feeble attempt to dissuade copying via mouse right click
//---------------------------------------------------------------

function no_right_click(e) 
{
	var message = 
    	"Please respect these copyrighted materials.  You\n"         +
		"may link to any page, but not to a specific image.\n" 

  	if (document.all) 
  	{
   		if (event.button == 2) 
		{
   			alert(message);
   			return false;
   		}
 	}

	//	Only Navigator supports <LAYER>

  	if (document.layers) 
  	{
   		if (e.which == 3) 
		{
     		alert(message);
      		return(false);
    	}
  	}
}

//	Configure mouse activity

function init_mouse_clicks()
{
	if (NO_RIGHT_CLICK) 
	{
		if (document.layers) 
   			document.captureEvents(Event.MOUSEDOWN);

   		document.onmousedown=no_right_click;
	}
}

//	Based on globals, configure the page

function init_page()
{
	init_mouse_clicks();

	if (AUTO_RESIZE)
		resize_browser(0, 0);
}


//---------------------------------------------------------------
//	If the browser winds up showing just a frame instead 
//	of the entire frameset, reframe.  This happens when
//	google (et al) refers to a "_main.php" page instead
//	of the frameset page.
//---------------------------------------------------------------

function reframe_page(filename) 
{
	//	CGB test
	//if (!RUN_LOCAL)
	//	AUTO_REFRAME = false;
 
	if (!AUTO_REFRAME)
		return true;

	if (top == self) 
	{ 
		var newURL = BASE_URL;

		if (filename.charAt(0) == "/")
			newURL += filename; 
		else
			newURL += "/" + filename; 

		top.location.replace(newURL); 
	} 
}

/*---------------------------------------------------------------
	Toggle the display property on/off for a DOM element.i
---------------------------------------------------------------*/

function toggle_display(DOM_element_id)
{
	var elem = document.getElementById(DOM_element_id);

	if (!elem.style.display || elem.style.display == "none")
		elem.style.display = "block";
	else
		elem.style.display = "none";

	return(true);
}

