/************************************************************************************
 																						
 	FILE:			menuScript.js													
 																					
 	DESCRIPTION:	This file contains the javascript to show and hide				
 					popup menus.  The functions are meant to be called				
 					by a mouse event... either a click or a rollover				
 																					
 	VERSIONS:																	
  		09-14-2001 by fred.peck@tesser.com
 			File created.	
		
		12-28-2001 by fred.peck@tesser.com
			Added support for Netscape 6 
  																						
************************************************************************************/



// -------------------- GLOBAL VARIABLES -------------------------------- //

	var zindex = 100;			// used to make sure the menu is always on top.
	var t;						// used in the timeouts before hiding the menus
	var time = 500;				// number of milliseconds to wait between a mouseout and hiding the menu
	
	var visibleMenu = null;		// holds the name of the visible menu, if one exists
	
	
	// We use global variables for the below because passing variables using setTimeout is dicey.
		
		//var globalEvent;		// global store for the event used to trigger the action
		var globalMenu;			// global store for the menu to show or hide
				

		
	
function overMenuImage(menu, image) {
	changeOver(image);
	showMenu(menu);
}


function outMenuImage(menu, image) {
	changeOut(image);
	hideMenu(menu);
}

	
	
	
	
		
	
/*-----------------------------------------------------------------------
	
	METHODS:		showMenu and hideMenu 
	
	DESCRIPTION:	These functions show and hide menus on a mouse event.  
					Becuase IE and Netscape handle DHTML differently, 
					they call a functions customized to each browser
	
	VARIABLES:	
		callingEvent (event):	The event that called the method
		menu (string):			The name of the menu to show 
		
------------------------------------------------------------------------*/  
function showMenu (menu) {
	
	if(t)
		clearTimeout(t);
	
	if (navigator.appName == "Netscape")  
	{
		if (parseInt(navigator.appVersion) < 5)
		{
			globalMenu = 'document.' + menu;
			showMenuNN();
		}
		else
		{
			globalMenu = document.getElementById(menu);
			showMenuIE();
		}
	}
	 
	else 
	{
		globalMenu = menu;
		showMenuIE();
	}
}


function hideMenu (menu) {
	
	if (navigator.appName == "Netscape") 
	{
		if (parseInt(navigator.appVersion) < 5)
		{
			globalMenu = 'document.' + menu;
			t = setTimeout("hideMenuNN()", time);
		}
		else
		{
			globalMenu = document.getElementById(menu);
			t = setTimeout("hideMenuIE()", time);
		}
		
	}
	else 
	{
		globalMenu = menu;
		t = setTimeout("hideMenuIE()", time);
	}
}


/* ------------------------- IE MENU FUNCTIONS -------------------------
 
	METHODS:		showMenuIE and hideMenuIE
	
	DESCRIPTION:	Displays and hides the specified menu in IE.  
					These use global variables that need to be defined 
					before they are called, and are meant to be called 
					from the showMenu and hideMenu functions.
	
	VARIABLES (these are global vars that have to be defined outside):
		globalMenu (string):	The name of the menu to show 

-----------------------------------------------------------------------*/
function showMenuIE() 
{
	
	globalMenu = eval(globalMenu);

	// Position the Menu
	//globalMenu.style.left = event.clientX - event.offsetX - 2;
	//globalMenu.style.top = event.clientY - event.offsetY - 2;
	
	// Clear the visible menu if it's not this one
	if((visibleMenu != null) && (visibleMenu != globalMenu)) 
	{	
		visibleMenu.style.visibility="hidden";
		visibleMenu = null;
	}
	
	if (globalMenu.style.visibility == "hidden") 
	{
		globalMenu.style.visibility="visible";	// Show the layer
		globalMenu.style.zIndex=zindex++; 		// Put the layer on top
		visibleMenu = globalMenu;	
	} 
} 

function hideMenuIE()
{
	globalMenu=eval(globalMenu);
	globalMenu.style.visibility="hidden";
	visibleMenu = null;
}



/* ------------------------- NN MENU FUNCTIONS -------------------------
 
	METHODS:		showMenuNN and hideMenuNN
	
	DESCRIPTION:	Displays and hides the specified menu in NN.  
					These use global variables that need to be defined 
					before they are called, and are meant to be called 
					from the showMenu and hideMenu functions.
	
	VARIABLES (these are global vars that have to be defined outside):
		globalEvent (event):	The event that called the calling method
		globalMenu (string):	The name of the menu to show 
	 
-----------------------------------------------------------------------*/
function showMenuNN()
{	
	globalMenu = eval(globalMenu);
	
	// Position the Menu
	//globalMenu.left = globalEvent.pageX - globalEvent.layerX + 150;
	//globalMenu.top = globalEvent.pageY - globalEvent.layerY + 55;
	
	if((visibleMenu != null) && (visibleMenu != globalMenu)) 
	{	
		visibleMenu.visibility="hide";
		visibleMenu = null;
	}
	
	globalMenu.zIndex++ // Make sure it's on top
	globalMenu.visibility="show";
	visibleMenu = globalMenu;

} 

function hideMenuNN()
{
	globalMenu = eval(globalMenu);
	globalMenu.visibility="hide";
	visibleMenu = null;
	return false;
}





