/* expands and contracts toc, swaps plus and minus gifs  */
var img1 = new Image();
img1.src = "../images/icon_max.gif";
var img2 = new Image();
img2.src = "../images/icon_min.gif";
var highlightColor = new String();
highlightColor = "#ff3300";
var fontWeight = "normal";

/** The initialize function checks the url of the current page,
  * if the page is a part of a Section (i.e., prod_), then the corresponding subMenu 
	*	div section is displayed.  Notice that the menuItems array contains the
	*	different possible prefixes that subMenu ids & their corresponding
	*	files may contain.  SubMenuItems likewise contains the different possible
	*	suffixes the sub menu elements and their corresponding files may contain.
	* and siteSection is the preceeding string for all menu elements and corresponding
 	* filenames.
	* The method takes three arguments: menuItems is an array of Strings that are
	*	menu names (e.g., win2kpro for Windows 2000 Professional); subMenuItems is 
	*	an array of Strings that are sub menu names or subjects (e.g., ovw for overview);
	*	siteSection is a String the prefix of the section (e.g., prod_ for products).
	*	It returns nothing.
  */
function initialize(menuItems, subMenuItems, highlight, fw, locale)  {
var fileName = new String();
var subMenuArr = new Array();
var imageNameArr = new Array();
var temp;
var subMenu;
var imageName;
var msg;

// if fileName is passed as an arg, use it for locale, else get the locale from the page name.
if (locale != null && locale != "undefined" && locale != "")
	fileName = locale;
else
	fileName = location.pathname;
// if highlight is passed in as arg, then use it for highlighting color, else take default.	
if (highlight != null)
	highlightColor = highlight;
// if fw is passed in as arg, then use it for the font weight else take the default.
if (fw != null)
	fontWeight = fw;
// if ie process menus.
if (navigator.appName.indexOf("Microsoft") != -1) {
  // now check the file name for specific product names, and expand submenus accordingly		
  for (i=0;i<menuItems.length;i++) {
		// if current locale then set its menu to block, img to -, and select subMenu.
		if (fileName.indexOf(menuItems[i]) != -1)  {
			subMenu = document.all.item("subMenu_" + menuItems[i]);
			imageName = document.all.item(menuItems[i] + "_ExpandTreeImage");
			subMenu.style.display = "block";
			imageName.src = img2.src;
			// set the submenu highlight font color
			checkSubMenuSelect(menuItems[i],subMenuItems,fileName);
		} // end if filename contains one of the menuItem names
	} // end for loop
 }  // end if ie
} // end initializeNew

/**
 *	Check if the current location's fileName contains any of the suffixes. 
 *	If so, then we want to set the subMenu item, which has an id of prefix+suffix,
 *	style color to red.  When there is a subMenu within a SubMenu, then need to watch 
 *	out because it will be in the locale/location for the menu_item, the menu_subItem, 
 *	and the menu_item_subItem.
 */
function checkSubMenuSelect(prefix,suffix,fileName) {
	var temp;
	var menuItem;
	// for each of the subMenu items...
	for (i=0;i<suffix.length;i++) {
  	  // if this is an array of arrays, not a string then open div and send back through.
	  if ((typeof suffix[i] != "string") && (suffix[i].constructor != String)) {
		// loop through each of the items in the subMenu, if it is this locale, then
		// set the highlightColor and the fontWeight. If not then it is the subMenu itself.
		for(j=0;j<suffix[i].length;j++) {
			// if this is an array of arrays, not a string then open div and send back through.
			if ((typeof suffix[i][j] != "string") && (suffix[i][j].constructor != String)) {
				// for each item in the 
				for(k=0;suffix[i][j][k] != null && typeof suffix[i][j][k].constructor != String && k<suffix[i][j].length;k++) {
				temp = prefix + "_" + suffix[i][0] + "_" + suffix[i][j][k];
					// if current locale then set its menu to block, img to -, and select subMenu.
					if (fileName.indexOf(temp) != -1)  {
						// set block display style on division.
						temp = prefix + "_" + suffix[i][0];
						subMenu = document.all.item("subMenu_" + temp);
						imageName = document.all.item(temp + "_ExpandTreeImage");
						subMenu.style.display = "block";
						imageName.src = img2.src;
						temp = temp + "_" + suffix[i][j][k];
						treatSubMenuItem(temp);
					} // end if current locale i.e., if filename contains one of the menuItem names.	
				} // end of for each of items in sub-subMenu.
			// else it is a String, so see if need to set the submenu highlight font color and weight.
			} else {
					temp = prefix + "_" + suffix[i];
					// if locale contains the suffix then set the highlight and fontWeight.
					if (fileName.indexOf(temp) != -1){
						treatSubMenuItem(temp);
					} // end if file name contains the suffix.
			} // end if not a String object but an Array.
		} // end for each item in the subMenu.
	  } else {
		temp = prefix + "_" + suffix[i];
		// if locale contains the suffix then set the highlight and fontWeight.
		if (fileName.indexOf(temp) != -1){
			treatSubMenuItem(temp);
		} // end if file name contains the suffix.
	  } // end if not a String object but an Array.
	} // end for each suffix
} // end checkSubMenuSelectNew

/**
 *	The treatSubMenuItem function just sets the highlight and fontWeight for the given item.
 */
function treatSubMenuItem(itemName) {
	var menuItem;
	menuItem = document.all.item(itemName);
	menuItem.style.color = highlightColor;
	menuItem.style.fontWeight = fontWeight;
} // end treatSubMenuItem function.

/** The expandMenu function checks to see if the event's source element
  * has a child, if it does then it hides or displays the child (toggles),
	* and it toggles the image to either plus or minus.
  */
function expandMenu(imageName) {
	var child = document.all[event.srcElement.child];
	var imageObj = document.all.item(imageName);
	if (child != null) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			child.style.display = child.style.display ==
				"none" ? "" : "none";

			// the imageName passed in as an argument is the name of the image to change
			// the source on.
			if(imageObj.src == img1.src)
				imageObj.src = img2.src;
			else
				imageObj.src = img1.src;
		} // end if microsoft
	} // end if the child was not null
} // end expandMenu function

