
// function activateMenus()
// ************************
// This function looks for the variables "activeChapter", "activeItem", "activeSubItem" 
// set on top of each page by the webmaster and highlights the correspondent menus
// It works with the following HTML:
// <div id="mainmenu">
// 		<div class="chapter" id="chapter1"><img src="Images/MainMenuIcon.gif" alt="-" width="4" height="12" />&nbsp;<a href="Ch1/Welcome.html">Chapter1</a></div>
//   	<div class="chapter" id="chapter2"><img src="Images/MainMenuIcon.gif" alt="-" width="4" height="12" />&nbsp;<a href="Ch2/Welcome.html">Chapter2</a></div>
//    	<div class="chapter" id="chapter3"><img src="Images/MainMenuIcon.gif" alt="-" width="4" height="12" />&nbsp;<a href="Ch3/Welcome.html">Chapter3</a></div>
// </div>

// to do: limit the search for IDs in the menus, not on the whole page

// This function is activated with  body onload="javascript:activateMenus();"  in the html page
function activateMenus()
{
	// fetch browser name (IE does not behave as the others...)
	var nomnav = navigator.appName; 
	//alert(nomnav);
	
	// set variables (activeChapter, activeItem and activeSubItem are set on top of the html page)
	var chapterToBeActivated = document.getElementById(activeChapter);
	var itemToBeActivated = document.getElementById(activeItem);
	var subItemToBeActivated = document.getElementById(activeSubItem);
	
	// If browser IE, the attribute to be set is "className"
	if (nomnav == 'Microsoft Internet Explorer') 
	{
		var attribute = "className";
	}
	// for all the other browsers, we set the attribute "class"
	else
	{
		var attribute = "class";
	}
	
	// activate chapter in top menu (set class="active")
	if (chapterToBeActivated)
	{
		chapterToBeActivated.setAttribute(attribute, "activechapter");
	} 

	// activate item in left menu (set class="activeItem")
	if (itemToBeActivated)
	{
		itemToBeActivated.setAttribute(attribute, "activeItem");
	} 

	// activate subitem in left menu (set class="activeSubItem")
	if (subItemToBeActivated)
	{
		subItemToBeActivated.setAttribute(attribute, "activeSubItem");
	} 
	
}
