function class_assign_mouseover() {
	if (this.nodeName!="LI") return;
		if (this.className=="arrow_down") {
			this.className="arrow_down_rollover";
		} else if (this.className=="arrow_clicked") {
			this.className="arrow_clicked_rollover";
		} else if (this.className=="highlighted") {
			this.className="highlighted_rollover";
		} else if (this.className=="highlighted_arrow_down") {
			this.className="highlighted_arrow_down_rollover";
		} else {
			this.className="rollover";
		}
		var nodes = this.childNodes;
		for (var i = 0; i< nodes.length; i++) {
			if (nodes[i].nodeName=="A") nodes[i].className="rollover";
		}
}
function class_assign_mouseout() {
	if (this.nodeName!="LI") return;
		if (this.className=="arrow_down_rollover") {
			this.className="arrow_down";
		} else if (this.className=="arrow_clicked_rollover") {
			this.className="arrow_clicked";
		} else if (this.className=="highlighted_rollover") {
			this.className="highlighted";
		} else if (this.className=="highlighted_arrow_down_rollover") {
			this.className="highlighted_arrow_down";
		} else {
			this.className="";
		}
		var nodes = this.childNodes;
		for (var i = 0; i< nodes.length; i++) {
			if (nodes[i].nodeName=="A") nodes[i].className="";
		}
}
function class_assign(e) {
	if (this.nodeName!="A" && this.nodeName!="input") {
		
		//NEW CODE TO FIX MIGHTY-MENU - SHOW NEW CLASS ON OPEN
		if (this.className == "arrow_down") {
			this.className = "arrow_clicked";
		} else if (this.className == "arrow_down_rollover") {
			this.className = "arrow_clicked_rollover";
		} else if (this.className == "arrow_clicked_rollover") {
			this.className = "arrow_down_rollover";
		} else if (this.className == "arrow_clicked") {
			this.className = "arrow_down";
		} 		
		var nodes = this.childNodes;
		if (nodes.length <3) return;
		manageMenuArray(this.id);
		for (var i = 0; i< nodes.length; i++) {
			if (nodes[i].nodeName=="UL") {
			
				if (nodes[i].className!="show_class") { 
					nodes[i].className="show_class";
				} else  {
					nodes[i].className = '';
				}
			} else continue;
		}
	} else {
		if (this.target=="_self" || this.target=="_top") {
			targ = this.target.substring(1,this.target.length);
		} else {
			targ = this.target;	
		}
		if(targ) {
			eval(targ).location.href= this.href;
		}
		//document.location.href=this.href;
	}
	if (document.all&&document.getElementById) {
		window.event.cancelBubble = true;
	} else {
		e.stopPropagation(); 
	}
}
displayNodes =  function() {
	if (document.getElementById('MightyMenu')) {
		navRoot = document.getElementById('MightyMenu').getElementsByTagName("LI");
		navRootHref = document.getElementById('MightyMenu').getElementsByTagName("A");
		for(i=0; i<navRoot.length; i++) { 
			navRoot[i].onmouseover = class_assign_mouseover;
			navRoot[i].onmouseout = class_assign_mouseout;
			navRoot[i].onclick = class_assign;
		}
		for(i=0; i<navRootHref.length; i++) navRootHref[i].onclick = class_assign;
	
		//HARD CODED OPEN PAGES - ONLY ON HOME PAGES / OPEN PAGES
		//MCCALLS - PATTERNS BY TYPE (97) AND MISSES (100)
		//alert(window.location.href);
		if (window.location.href == "http://mccallpattern.mccall.com/" || window.location.href == "http://mccallpattern.mccall.com/shop-all-patterns-pages-87.php" || window.location.href=="http://mccallpattern.mccall.com/patterns-by-type-pages-97.php") {
			if (document.getElementById('ul_97') && document.getElementById('li_97')) {
				document.getElementById('ul_97').className="show_class";
				document.getElementById('li_97').className="arrow_clicked";
			}
			if (document.getElementById('ul_100') && document.getElementById('li_100')) {
				document.getElementById('ul_100').className="show_class";
				document.getElementById('li_100').className="arrow_clicked";
			}		
		}
		
		//WALLIES - SHOP BY TYPE (12) AND SHOP BY BRAND (14)
		if (document.getElementById('ul_22') && document.getElementById('li_22') && document.getElementById('ul_22').className=="show_class") {
			document.getElementById('li_22').className="arrow_clicked";
		}
		if (document.getElementById('ul_12') && document.getElementById('li_12')) {
			document.getElementById('ul_12').className="show_class";
			document.getElementById('li_12').className="arrow_clicked";
		}
		if (document.getElementById('ul_14') && document.getElementById('li_14')) {
			document.getElementById('ul_14').className="show_class";
			document.getElementById('li_14').className="arrow_clicked";
		}
		
		//BUTTERICK - PATTERNS BY TYPE (148) AND MISSES (151)
		if (window.location.href == "http://butterick.mccall.com/" || window.location.href == "http://butterick.mccall.com/shop-all-patterns-pages-139.php" || window.location.href=="http://butterick.mccall.com/patterns-by-type-pages-148.php") {
			if (document.getElementById('ul_148') && document.getElementById('li_148')) {
				document.getElementById('ul_148').className="show_class";
				document.getElementById('li_148').className="arrow_clicked";
			}			
			if (document.getElementById('ul_151') && document.getElementById('li_151')) {
				document.getElementById('ul_151').className="show_class";
				document.getElementById('li_151').className="arrow_clicked";
			}
		}
		
		//VOGUE - PATTERNS BY TYPE (175) AND MISSES (178)
		if (window.location.href == "http://voguepatterns.mccall.com/" || window.location.href == "http://voguepatterns.mccall.com/shop-all-patterns-pages-167.php" || window.location.href=="http://voguepatterns.mccall.com/patterns-by-type-pages-175.php") {
			if (document.getElementById('ul_175') && document.getElementById('li_175')) {
				document.getElementById('ul_175').className="show_class";
				document.getElementById('li_175').className="arrow_clicked";
			}			
			if (document.getElementById('ul_178') && document.getElementById('li_178')) {
				document.getElementById('ul_178').className="show_class";
				document.getElementById('li_178').className="arrow_clicked";
			}		
		}		
	}
}
function addOnloadEvent(fnc){
 if ( typeof window.addEventListener != "undefined" )
   window.addEventListener( "load", fnc, false );
 else if ( typeof window.attachEvent != "undefined" ) {
   window.attachEvent( "onload", fnc );
 }
 else {
   if ( window.onload != null ) {
     var oldOnload = window.onload;
     window.onload = function ( e ) {
       oldOnload( e );
       window[fnc]();
     };
   }
   else
     window.onload = fnc;
 }
}



openMenuArray = Array();
addOnloadEvent(displayNodes);
//window.onload=displayNodes;