// Method to show a layer
function showLayer( layers ) {
	if ( typeof( layers ) == "string" )
		layers = layers.split( "," );
	
	if ( document.layers ) {
		layerString = "document";
		for ( i = 0; i < layers.length; i++ )
			layerString += ".layers[\'"+layers[i]+"\']";
		
		layerObj = eval( layerString );
		layerObj.visibility = "show";
	}
	if ( document.all ) {
		layerName = layers[ layers.length-1 ];
		document.all[ layerName ].style.visibility = "visible";
	}
}

// Method to hide a layer
function hideLayer( layers ) {
	if ( typeof( layers ) == "string" )
		layers = layers.split( "," );
	
	if ( document.layers ) { 
		// Replacement code
		layerString = "document";
		layerString += ".layers[\'"+layers+"\']";
		layerObj = eval( layerString );
		layerObj.visibility = "hide";

		// Standard layers.js code
		/*layerString = "document";
		for ( i = 0; i < layers.length; i++ )
			layerString += ".layers[\'"+layers[i]+"\']";
		
		layerObj = eval( layerString );
		layerObj.visibility = "hide";*/
	}

	if ( document.all ) {
		layerName = layers[ layers.length-1 ];
		document.all[ layerName ].style.visibility = "hidden";
	}
}
	// popupMenu.js				Manages showing and hideing a DHTML layer sub menu along with image rollover on main menu

// Requires:
//    layers.js
//    useragent.js
//    images.js


// NOTE: YOU MUST DEFINE AN ARRAY OF MENU ITEMS ON YOUR PAGE
// Example:    var menuItems = ['company','healthPlans','services','employment','providers'];

var closingPopup = false; // Can't just close popup because netscape needs to wait 
							// for delayed events that may come through to keep popup open

function showPopup ( imageName )
{
	//alert ('showPopup( )');
	resetPopups();
	
	var popupMenuName = imageName + 'Popup';
	showLayer ( popupMenuName );  // Show popup layer
	
	// Show Image
	Images[ imageName ].on();
}

function resetPopups()
{
	closeAllPopups();
	closingPopup = false;
	clearTimeout();
}

function startPopupShutdown ()
{
	//alert ('startPopupShutdown()');
	closingPopup = true;
	setTimeout ( "closePopup()", 1000 ); // after the delay, if closingPopup is still true, will close all, otherwise, will keep alive
}

function stopPopupShutdown ()
{
	//alert ('cancelPopupShutdown()');
	closingPopup = false;
}

function closeAllPopups ()
{
	//alert ('closeAllPopups( )');
	for ( i = 0; i < menuItems.length; i++ )
	{
		hideLayer ( menuItems[i] + 'Popup' );
		Images[ menuItems[i] ].off();
	}
}

function closePopup ()
{
	//alert ('closePopup()');
	if ( closingPopup ) 	
	{
		//alert ( 'I should close the popup' );
		closeAllPopups();
	}
}
