/***********************************************************************
*  3M.com redesign JS for redesigned header code
*  Copyright (c) 3M 2006. All rights reserved
************************************************************************/
  // when submenu is collapsed
  var actuatorOff = "../../../../../../../ewcdTheme/lsnInd3.html";
   
  // when submenu is expanded
  var actuatorOn = "../../../../../../../ewcdTheme/lsnInd2.html";
  
  // when submenu is locked
  var actuatorLock = "../../../../../../../ewcdTheme/lsnInd0.html";
  
  // var for nav div
  var nav;

	function initMenu() {
		// quit if this function has already been called
       if (arguments.callee.done) return;

       // flag this function so we don't do the same thing twice
       arguments.callee.done = true;

		if(document.getElementById && document.createElement) {      // W3C DOM compliant
			nav = document.getElementById('lsnwrap');                    // get nav div
			if(nav) {                                                // nav exists
				setActuators();                                      // create actuators to expand and collapse menus
			}
		}
		return;
	}

	function setActuators() {
		var lis, li, childMenu, a, actuator, selected;
		lis = nav.getElementsByTagName('li');
		for(var i=0;i<lis.length;i++) {
			li = lis[i];
			childMenu = li.getElementsByTagName('ul')[0];
			selected = (li.className.indexOf('selected') != -1) ? true : false;
			if(selected)
			{
				parentMenu = li.parentNode;
				while(parentMenu.nodeName == 'UL' || parentMenu.nodeName == 'LI') {
					if(parentMenu.nodeName == 'UL') { parentMenu.style.display = 'block'; }
					if(parentMenu.nodeName == 'LI') {
							parentMenu.getElementsByTagName('img')[0].src = actuatorLock;
							parentMenu.getElementsByTagName('img')[0].style.cursor = 'default';
							parentMenu.className += ' locked';}
					parentMenu = parentMenu.parentNode;
				}
			}
			if(childMenu) {
				actuator = document.createElement('a');
				actuator.style.position = 'absolute';
				actuator.style.left = '-13px';
				actuator.style.top = '3px';
				actuator.style.zIndex = '5';
				actuator.style.backgroundColor = 'transparent';
				actuator.style.cursor = 'pointer';
				img = document.createElement('img');
				(selected) ? img.setAttribute('src',actuatorOn) : img.setAttribute('src',actuatorOff);
				actuator.appendChild(img);
				li.insertBefore(actuator,li.getElementsByTagName('a')[0]);
				li.getElementsByTagName('a')[0].style.backgroundImage = 'none';
				li.getElementsByTagName('a')[1].style.backgroundImage = 'none';
				li.style.position = 'relative';
				if(selected)
				{
					childMenu.style.display = 'block';
				} else {childMenu.style.display = 'none'};
				actuator.onclick = function() {
					var li = this.parentNode;
					if (li.className.indexOf('locked') != -1)
							{return;} else {
							childMenu = li.getElementsByTagName('ul')[0];
							if(childMenu.style.display == 'block') {
								childMenu.style.display = 'none';
								this.getElementsByTagName('img')[0].src = actuatorOff;
							} else {
								childMenu.style.display = 'block';
								this.getElementsByTagName('img')[0].src = actuatorOn;
							}
						}
				};
			}
		}
	}

	// Initialize Menu as soon as DOM is loaded :: http://dean.edwards.name/weblog/2005/09/busted/
	// for w3c browsers

	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", initMenu, null);
	}

	/* for Internet Explorer */
   /*@cc_on @*/
   /*@if (@_win32)
       document.write("<script defer src=/ewcdTheme/ie_domload.js><"+"/script>");
   /*@end @*/

	// trap for browsers that don't support either method above
	window.onload = function() { initMenu(); }   // parse the menu


