//Preload ButtonOn Images to improve initial swap response
var aMainMenuImages = new Array();

//Set up preload image array items
aMainMenuImages[0] = new Image();
aMainMenuImages[1] = new Image();
aMainMenuImages[2] = new Image();
aMainMenuImages[3] = new Image();
aMainMenuImages[4] = new Image();
aMainMenuImages[5] = new Image();

//Set the preload images to the selected variants of the menu images (all of which end "_f2")
aMainMenuImages[0].src = "images/menuGroup_f2.gif";
aMainMenuImages[1].src = "images/menuOurBusiness_f2.gif";
aMainMenuImages[2].src = "images/menuTradeLogin_f2.gif";
aMainMenuImages[3].src = "images/menuInvestorRelations_f2.gif";
aMainMenuImages[4].src = "images/menuContactUs_f2.gif";
aMainMenuImages[5].src = "images/portals_f2.gif";

//Each page sets this variable to identify which menu group it belongs to
var pageSectionId = "";

//-------------------------------------------------------------------------------
// Procedure     : SwapButton
// Description   : Called from the WebMenu OnShow and OnHide events, this function
//                 changes the image of a menu group's header as the user selects
//                 or deselects it.
// Notes         : Selected images are assumed to end with the suffix "_f2.gif".
// Parameters IN : id    - WM.Group ID property identifying group to swap image
//                 state - indicates state of the group:
//                         true = selected / false = unselected
//           OUT : None
//        IN/OUT : None
// Return Value  : None
//-------------------------------------------------------------------------------
function SwapButton(id, state)
{
	//Only perform the swap if the page is not a member of the selected group
	if (id != pageSectionId) {
		if (state)
			eval("document." + id + "Button.src='images/" + id + "_f2.gif'");
		else
			eval("document." + id + "Button.src='images/" + id + ".gif'"); 
	}
}

//-------------------------------------------------------------------------------
// Procedure     : SwapClass
// Description   : Called from the Menu Item OnMouseOver and OnMouseOut events.
//                 Changes the CssClass of the item as the user rolls over it;
// Parameters IN : id    - Table row containing the Item to be adjusted
//           OUT : None
//        IN/OUT : None
// Return Value  : None
//-------------------------------------------------------------------------------
function SwapClass(id)
{
	//Get the element which has the Css Class associated with it (not nice code!)
	var el = id.children(0).children(1)
	
	//Swap the Css Class of the menu item between selected and unselected
	if (el.className == "menutext")
		el.className = "menutextselected";
	else
		el.className = "menutext";
}
