//-------------------------------------------------------------------------------------------------
// PopUpMenu Module
//
// Mike Schoonover
// July 2008
// 
// Displays and hides sub menus when the mouse cursor is placed over a main menu item.
//

//-------------------------------------------------------------------------------------------------
// hideAllSubMenus
//
// Hides all the sub menus.
//

function hideAllSubMenus() {

document.getElementById('ServicesSubMenu').style.visibility = 'hidden';
document.getElementById('ProductsSubMenu').style.visibility = 'hidden';
//document.getElementById('EducationalSubMenu').style.visibility = 'hidden';
document.getElementById('OnlineToolsSubMenu').style.visibility = 'hidden';
//document.getElementById('GallerySubMenu').style.visibility = 'hidden';
document.getElementById('ContactSubMenu').style.visibility = 'hidden';

}//end of activeImage
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// showMenu
//
// Shows the sub menu specified with id of menuName.
// Hides all the menus first.
//
// Index is a unique numerical identifier for each menu.  It is used to track which menu is
// currently active.  The left most menu item should be 0.
//

function showMenu(menuName, index) {

hideAllSubMenus(); //hide all menus in case one is already visible

document.getElementById(menuName).style.visibility = 'visible';

//flag that the menu is active so it won't be hidden while the cursor is on the item - this
//would happen if the mouse was moved off and then quickly back on again
menuActive[index]=true;

}//end of showMenu
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// hideMenu
//
// Hides the sub menu specified with id of menuName.
//
// Index is a unique numerical identifier for each menu.  It is used to track which menu is
// currently active.  The left most menu item should be 0.
//

function hideMenu(menuName, index) {


//if the flag is true, the cursor has been moved back onto the main menu item so it should not be
//hidden this time - it will be hidden when the mouse moves off again

if (!menuActive[index])
	document.getElementById(menuName).style.visibility = 'hidden';

}//end of hideMenu
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// hideMenuAfterDelay
//
// Hides menu specified by id of menuName after a short delay.  This is usually called by
// onmouseexit to give the user a few seconds to pick a submenu item before it is hidden.
//
// Index is a unique numerical identifier for each menu.  It is used to track which menu is
// currently active.  The left most menu item should be 0.
//

function hideMenuAfterDelay(menuName, index) {


menuActive[index] = false;  //allow menu to be hidden

//create a command string, using menuName to specify the menu to hide
var cmd="hideMenu('" + menuName + "', " + index + ")";

//Setup a timer to execute the command string which will call the hideMenu function to
//hide the specified sub menu after a few seconds.
window.setTimeout(cmd, 5000);

}//end of hideMenuAfterDelay
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// --- Free Code not in a Function ---
//

var menuActive = [];

menuActive[0]=false;
menuActive[1]=false;
menuActive[2]=false;
menuActive[3]=false;
menuActive[4]=false;
menuActive[5]=false;

//end of Free Code
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
// Example code for use in HTML Page 


//end of Example code for use in HTML Page 
//-------------------------------------------------------------------------------------------------
