/*=============================================================================
TITLE:			Simple Dropdown Menu Controller
VERSION:		2005.08.01
AUTHOR: 		Graham Wheeler / NetMediaOne - www.netmediaone.com
=============================================================================*/

var menuClassName = "PullDownMenu"; 			// Sets the name used to identify pull down menus
var activeMenus = "NULL";  								// Holds the index of the active menu
var menuCollection = new Array(); 				// Holds references to each menu element
var menuPrefix = "menu";									// Sets the prefix used to identify menu elements
var menuHeaderPrefix = "nav";							// Sets the string prefix used to identify navigational elements bound to menus
var menuTimer = null;
var layoutWidth = 760;

function initMenus()
{
	tags = document.getElementsByTagName("DIV");
	for ( t = 0; t < tags.length; t++ )
	{
		if ( tags[t].className == menuClassName )
		{
		  menuElement = tags[t];
			menuCollection[menuCollection.length] = menuElement;
		}
	}
	adjustMenus();
}

function showMenus( menuList )
{
	activeMenus = new Array();
	hideMenus();
	for ( i = 0; i < menuList.length; i++ )
	{
		menu = xGetElementById( menuList[i] );
		menu.style.visibility = "visible";
		activeMenus[i] = menu.id;
	}
}

function blurMenus()
{
	activeMenus = new Array();
	clearTimeout(menuTimer);	
 	menuTimer = setTimeout( "hideMenus()", 500 );
}

function hideMenus()
{
	for ( i = 0; i < menuCollection.length; i++ )
	{
		menu = menuCollection[i];
		vis = "hidden";
		for ( a = 0; a < menuCollection.length; a++ )
		{
			if ( activeMenus[a] == menu.id )
			{
				vis = "visible";
			}
		}
		menu.style.visibility = vis;
	}
	
}

function adjustMenus()
{
	for ( menuIndex = 0; menuIndex < menuCollection.length; menuIndex++ )
	{
		menu = menuCollection[menuIndex];
		menu.style.marginLeft = ( (document.body.clientWidth - layoutWidth ) / 2 ) + "px";
	}	
}

xAddEventListener(window, "load", initMenus, false);
xAddEventListener(window, "resize", adjustMenus, false);

