/* ----SIDE NAV WITH SWAP IMAGE expands and contracts toc, swaps plus and minus gifs  */
var img1 = new Image();
img1.src = "./images/select.gif";
var img2 = new Image();
img2.src = "./images/selected.gif";
var highlightColor = new String();
highlightColor = "#666600";
var fontWeight = "normal";

/** The initialize function checks the url of the current page,
  * if the page is a part of a Section, 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; subMenuItems is an array of Strings that are sub menu names or subjects
	*	siteSection is a String the prefix of the section.
	*	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.
 */
function checkSubMenuSelect(prefix,suffix,fileName) {
	var temp;
	var menuItem;
	// for each of the subMenu items...
	for (i=0;i<suffix.length;i++) {
	  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 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);
	//alert("event="+ document.all[event.srcElement]+" child="+ document.all[event.srcElement.child]);
	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