/*******************************************************************************
	General functions for all pages
*******************************************************************************/

// globals

var TOP_SECTION_HEIGHT = 152;		// size of banner
var MENU_WIDTH         = 0;		// as set in stylesheet
var MENU_OFFSET        = -333;		// from left edge of top-right banner image
var menu_showing       = false;	// is menu currently visible? 

/******************************************************************************/

function setContentSize()
{
	/*
		Reset main content area to just fill page
		Requires that we know exact size of fixed page elements (header and
		borders) for current setup - seems we can't just $&"*%&^! read them!
	*/

	var fixed_height = TOP_SECTION_HEIGHT;
	var total_height = document.body.clientHeight;
	
	if (document.getElementById("content-left"))
		document.getElementById("content-left").style.height = total_height - fixed_height;
}


/******************************************************************************/

function menuShow()
{
	/*
		Popup menu (positioned to line up with image) and set menu_showing flag.
		Called onMouseOver both the banner image and the menu itself (so that the
		menu stays visible when the mouse is over it)
	*/
	
	var menu = document.getElementById('menu');
	var page_width = document.all ? document.body.clientWidth : innerWidth;
	
	menu.style.left       = page_width/2 + MENU_OFFSET;
	menu.style.top        = TOP_SECTION_HEIGHT - 10;
	menu.style.visibility = 'visible';
	
	menu_showing = true;
}


/******************************************************************************/

function menuOut()
{
	/*
		Called onMouseOut either the banner image or the menu itself
		
		Unsets flag, but waits for half a second before calling menuHide, in case
		mouse was leaving this object to move over the other one (in which case
		the flag will be set again and the menu will stay visible as required)
		
		Necessary in order to prevent the menu disappearing as you try to move
		the mouse over it!
	*/
	
	menu_showing = false;
	setTimeout('menuHide()',500);
}


/******************************************************************************/

function menuHide()
{
	/*
		Just hide the menu if flag is unset (called after a timeout - see above)
	*/
	
	if (menu_showing) return;
	document.getElementById('menu').style.visibility = 'hidden';
}

/******************************************************************************/

function submenuShow()
{
	/*
		Popup submenu (positioned to line up with image) and set submenu_showing flag.
		Called onMouseOver both the banner image and the submenu itself (so that the
		submenu stays visible when the mouse is over it)
	*/
		
	var page_width = document.all ? document.body.clientWidth : innerWidth;
	var menu = document.getElementById('menu');
	
	var submenu = document.getElementById('submenu');
		
	var menuleft = menu.style.left;
	var menutop = menu.style.top;

	var submenuleft = menu.style.left
	var submenutop = menu.style.top	
				
	submenu.style.left       = eval("60 + 30");
	submenu.style.top        = eval("60 + 30");
	submenu.style.visibility = 'visible';

		
	submenu_showing = true;
}


/******************************************************************************/

function submenuOut()
{
	/*
		Called onMouseOut either the banner image or the menu itself
		
		Unsets flag, but waits for half a second before calling submenuHide, in case
		mouse was leaving this object to move over the other one (in which case
		the flag will be set again and the submenu will stay visible as required)
		
		Necessary in order to prevent the submenu disappearing as you try to move
		the mouse over it!
	*/
	
	submenu_showing = false;
	setTimeout('submenuHide()',500);
}


/******************************************************************************/

function submenuHide()
{
	/*
		Just hide the submenu if flag is unset (called after a timeout - see above)
	*/
	
	if (submenu_showing) return;
	document.getElementById('submenu').style.visibility = 'hidden';
}

