//this javascript works with both IE versions
var normalColor;

var curMenuArray = new Array(10);
var curMenuIndex = 0;
var curMenu = null;
var disablehide = false;
function Smenu_Hilite(obj, menu)
{
	with (obj)
	{ 
		normalColor = bgColor;
		bgColor  = '#3399CC';
		var myIndex =  Smenu_GetMenuIndex(menu);
		if(curMenuIndex > myIndex && myIndex != -1)
		{
		Smenu_HideMenu(myIndex, true);
		}
		style.cursor = "default";
		window.status = "";
	}
}
function Smenu_Hilite2(obj, menu,href)
{
	Smenu_Hilite(obj, menu);
	with (obj)
	{ 
	    style.cursor = "hand";
	    if(arguments.length == 3) 
	    {
			window.status = href;
	    }
	}
}
function Smenu_Restore(obj)
{
   with (obj)
   {
	  bgColor = normalColor;
     style.cursor = "";
   }
}

function Smenu_ShowMenu(parent,obj,name)
{
	Smenu_HideMenu(0);
	var menu = document.getElementById(name)
	var root = document.getElementById(parent)

	//this code will resize the popup table to be the width of its parent menu
	var table = document.getElementById('table_' + name);
	if(obj.offsetWidth > menu.offsetWidth)
		table.width = obj.offsetWidth + 2;

	with (menu.style)
	{	
		top = Smenu_GetPopupMenuStartTop();
		left = root.offsetLeft + obj.offsetLeft;
		visibility = 'visible';	
		curMenuArray[++curMenuIndex] = menu;
		curMenu = menu;
	}
}
function Smenu_ShowSubMenu(parent,obj,name)
{
	var menu = document.getElementById(name)
	var parentmenu = document.getElementById(parent)
	var nbrTop = 0;
	with (menu.style)
	{	
		var lngAmountMenuTooLow = obj.offsetTop + menu.offsetHeight - (g_Smenu_MAX_ROWS * g_Smenu_ITEM_HEIGHT);
		top = Number(parentmenu.offsetTop + obj.offsetTop) - (lngAmountMenuTooLow > 0 ? lngAmountMenuTooLow : 0) ;
		left = parentmenu.offsetLeft + obj.offsetWidth + obj.offsetLeft;
		visibility = 'visible';	
		curMenuArray[++curMenuIndex] = menu;
		curMenu = menu;
	}
}
var i = 0;
function Smenu_HideMenu(objMenuLevelOn, bForce)
{
	if(arguments.length < 1)
	{
		objMenuLevelOn = 0;
	}
	if(arguments.length < 2)
	{
		bForce = false;
	}
	
	if((disablehide == true)  && (bForce == false)) return;
	var menuobj = null;
	for (curMenuIndex; curMenuIndex>objMenuLevelOn; curMenuIndex--)
	{
		menuobj = curMenuArray[curMenuIndex];
		with (menuobj.style)
		{		
			visibility = 'hidden';
		}
	}
}
function Smenu_URLToken(url)
{
	//placeholder to add additional query string info onto request.
	return url;
}
function Smenu_Navigate(url,menuName)
{
	if(arguments.length > 1 )
	{
		//setCookie(g_Smenu_COOKIE,menuName);
	}
	top.window.location.href = Smenu_URLToken(url);	
}
function Smenu_newWin(theURL,target, features) 	
{	
	window.open(Smenu_URLToken(theURL),target,features);
}
function Smenu_GetMenuIndex(strMenu)
{
	var obj = document.getElementById(strMenu);
	var i = 0;
	for(i = curMenuIndex; i>=0; i--)
	{
		if(curMenuArray[i] == obj) 
			break;
	}
	return i;
}
function Smenu_HandleMenuOut(obj)
{ //look into possibly a more efficient way to handle this
	window.disablehide = false;	
	window.setTimeout("Smenu_HideMenu()", 300);
}
function Smenu_HandleMenuOver(obj)
{
	window.disablehide = true;
}
var g_lngPopupMenuStart = -1;
function Smenu_GetPopupMenuStartTop()
{
	//initialize the starting point of the popup menus.  On-line do this once since it will remain constant for that page session.
	if(g_lngPopupMenuStart == -1)
	{
		var root = document.getElementById(g_ROOT_Smenu_NAME)
		g_lngPopupMenuStart = Number(root.offsetTop) + Number(root.offsetHeight)
	}
	return g_lngPopupMenuStart
}