// bfaLoad3.js

var gSelected = 0;

function LoadBFAMENUS(linkCount,callingMenuID,callingMenuItem,itemSelect,buttonSelect,textChange,textColorDefault,textColorHighlight)
{
	var theButton;
	var theMenu;
	var theItem;
	var theInners = new Array(15);
	var itemIndex;
	var itemCount;
	
	
	if(linkCount > 0)
	{
		SetMenuCount(linkCount,false);
		itemIndex = 1;
		theInners[0] = "H<FONT SIZE = -1>OME</FONT> P<FONT SIZE = -1>AGE</FONT>";
		theInners[1] = "C<FONT SIZE = -1>OMPANY</FONT> P<FONT SIZE = -1>ROFILE</FONT>";
		theInners[2] = "S<FONT SIZE = -1>TAFF</FONT> D<FONT SIZE = -1>IRECTORY</FONT>";
		itemCount = 3;

		BuildMenu(0,itemCount,"MENU1","LEFT","1px solid #006060","1px",theInners);
		theButton = document.getElementById("MBAR_ITEM1");
		
		InitMenu("BUTTON1","MENU1",itemCount);
		theInners[0] = "Click to go to this page";
		
		while(itemIndex < linkCount)
		{
			theMenu = "MENU" +(itemIndex + 1);
			theButton = "MBAR_ITEM" +(itemIndex + 1);
			BuildMenu(itemIndex,1,theMenu,"LEFT","1px solid #006060","1px",theInners);
			InitMenu(theButton,theMenu,0);
			itemIndex++;
		}
		
		if(callingMenuID != null)
		{
			theItem = document.getElementById("ITEM" +callingMenuItem +"_" +callingMenuID);
			SetMenuSelection(callingMenuID,theItem.id);
		}			
	}
	
	SetMenuButtonBackgrounds("MBAR_ITEM","none","btn_bak01xxx.jpg",textColorDefault,textColorHighlight);	
	window.document.body.onfocus  = "MenusActivate(true);"
	window.document.body.onblur = "MenusActivate(false);"
			
	delete(theInners);	
}
		


function PageSetup(linkSelected)
{
	var box = document.getElementById("STAFFOPTIONS");
	var topBox = document.getElementById("TOPBOX");
	var line = document.getElementById("TOPLINE");
	var menuForm = document.getElementById("MENU_FORM");
	var staffLinks = document.getElementById("STAFFLINKS");
	var theEvent = window.event;
	var topBack = document.getElementById("TOPBACKGROUND");
	var boxleft;
	var minimumleft = 410;
	var topWidth = 730;
	
	if(linkSelected > 500)topWidth = linkSelected;
	
	if(topBack != null)
	{
		if(document.body.offsetWidth < topWidth)
		{
			topBack.width = topWidth;
		}
		else
		{
			topBack.width = "100%";
		}
	}
					
	if(box != null)
	{
		box.style.top = topBox.offsetTop + line.offsetTop - 10;
		
		if(menuForm != null)
		{
			if(linkSelected > 0)staffLinks.options.selectedIndex = linkSelected;
			else if(linkSelected == -1)minimumleft = 470;
			
			if(topBox != null)
			{
				if(line != null)
				{
					
					boxleft = 108 + topBox.offsetLeft + line.offsetLeft + line.offsetWidth - staffLinks.offsetWidth - 4;
					if(boxleft < minimumleft)boxleft = minimumleft;
					box.style.left = boxleft;
					box.style.visibility = "visible";
				}
			}					
		}
	}
	if(linkSelected > 0)gSelected = linkSelected;
}


function change_page()
{
	var menuForm = document.getElementById("STAFFLINKS");
	if(menuForm != null)
	{
			var linkNum = menuForm.options.selectedIndex;
			if(linkNum > 0)
			{
				if(menuForm.options[linkNum].value != 0)
				{
					var theLink = menuForm.options[linkNum].value;
					if(theLink)window.document.location.href = theLink;
				}
			}
	}
	
	return(true);
}

// ------------------------------------- MenuClick --------------------------------
function MenuClick(theItem,itemIndex)
{
	var menuItem;
	var infoText;
	var mbarItem;
	
	
	if(theItem)menuItem = theItem;
	else
	{
		menuItem = GetTheEventObject(GetTheEvent(null));
	}
	
	if(menuItem)
	{
		if(menuItem.offsetParent.currentSelection)
		{
			menuItem.offsetParent.currentSelection.style.background = kMenuItemDefaultColor;
		}
		
		theItem.style.background = kMenuItemClickedColor;
		menuItem.offsetParent.currentSelection = theItem;
		DisableLinks();
		
		if(menuItem.id)
		{
			var menuObject = theItem.offsetParent;
			if(menuObject.id)
			{
				var nextLocation = null;
				
				
				if(menuObject.id == "MENU1")
				{
					switch(itemIndex)
					{
						case 1:
						nextLocation = "index.html";
						break;
						case 2:
						nextLocation = "profile.htm";
						break;
						case 3:
						nextLocation = "staff.htm";
						break;
						default:
						break;
					}
				}
				else if(menuObject.id == "MENU2")
				{
					nextLocation = "benefits.htm";
				}
				else if(menuObject.id == "MENU3")
				{
					nextLocation = "insure.htm";
				}
				else if(menuObject.id == "MENU4")
				{
					nextLocation = "products.htm";
			    }
			    else if(menuObject.id == "MENU5")
			    {
				    nextLocation = "companies.htm";
			    }

			    if(nextLocation != null)
				{
					//HideMenus();
					window.document.location.href = nextLocation;
				}
				return(true);
					    
			}
		}
	}
	HideMenus();					
	return(false);
}

