// menu_funct.js - Aspen Menuing System

// Using W3C DOM, all modern browsers should support this including
// Netscape 6 and later (tested fine on Netscape 7)
// Internet Explorer 5 and later (tested fine on IE6)
// Internet Explorer 5 and later on Mac (tested fine)
// Mozilla (tested fine on 0.99)
// Konqueror (tested fine on Konq 3)
// Opera 5 and later (untested)
w3c = (document.getElementById)? true:false
// Netscape 4 and older will use this (currently does not work)
ns4 = (document.layers)? true:false
// Internet Explorer 4 and older will use this (not implemented)
ie4 = (document.all)? true:false

// Global variables with default values
var timeout = false;
var curtitle = '';
var curmenu = '';
	
// Get style settings reference
function GetSRef(inobj)
{
	// W3C compliant method
	if(w3c)
		return document.getElementById(inobj).style;
	else if(ns4)
		return document.layers[inobj];
//		else
//			alert('Sorry we do not recognise your browser's DOM model');
}
	
// Get object settings reference
function GetRef(inobj)
{
	// W3C compliant method
	if(w3c)
		return document.getElementById(inobj);
	else if(ns4)
		return document.layers[inobj];
//		else
//			alert('Sorry we do not recognise your browser's DOM model');
}

// Display a submenu
function ShowMenu(usetitle, usemenu)
{
	// Get references
	title = GetRef(usetitle);
	menu = GetSRef(usemenu);

	// If there is a menu showing hide it first
	if(curtitle!='')
	{
		timeout = true;
		Poof(GetRef(curtitle), GetSRef(curmenu));
	}
	
	// Set the current menu reference to be this one
	curtitle = usetitle;
	curmenu = usemenu;

	// Display menu, and highlight menu title
	menu.visibility = "visible";
	title.className = "bgcolour3";
}
	
// Hide a submenu
function HideMenu(intitle, inmenu)
{
	// Get references
	usetitle = GetRef(intitle);
	usemenu = GetSRef(inmenu);

	// Set timeout to be true
	timeout = true;

	// Hide menu after 10ms
	setTimeout("Poof(usetitle, usemenu)", 100);
}

// Actual make the menu disappear
function Poof(intitle, inmenu)
{
	// As long as the menu has timed out....
	if(timeout)
	{
		// Give the old colour back to title and hide menu
		intitle.className = "bgcolour4";
		inmenu.visibility = "hidden";

		// Set current menu to none
		curtitle = '';
		curmenu = '';
			
		// No need to timeout until we have a new menu
		timeout = false;
	}
}
	
// Set timeout to false so that the menu doesn't disappear
function KeepMenu()
{
	timeout = false;
}

// Highlight the current selection
function Hilite(useitem)
{
	curitem = GetRef(useitem);
	curitem.className = "bgcolour3";
}

// Remove highlight from current selection
function Lolite(useitem)
{
	curitem = GetRef(useitem);
	curitem.className = "bgcolour4";
}
	
// Navigate to a new page
function BrowseTo(PageID)
{
	location = "index.cfm?PID=" + PageID;
}

// Context sentsitive popup
function PopupMenu(PID, Group)
{
	window.open("W_context.cfm?PID="+ PID + "&Group=" + Group,"floatMenu","width=180,height=400,left=0,top=0,toolbar=no,location=no,scrollbars=no");
}
