﻿<!-- // hide this script from non-javascript-enabled browsers

// --------------------------------------------------------
// -----  COPYRIGHT NOTICE                            -----
// -----  © Copyright 1995-2009 ZEI.  -----
// -----  All rights reserved.                        -----
// --------------------------------------------------------

// *********************************************
// * Client-Side Tree / Node Menu
// *********************************************

function menuInit(node) {

	if (!document.getElementById) return false;
	if (!document.getElementById('list-product-menu')) return false;
	if (!node) node = document.getElementById('list-product-menu');

	var url = window.location;
	
	
	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			// set current link & expand node path
			if (child.nodeName == 'A' && child.href == url) {
				// current page link found
				child.className = 'active';
				// find related UL paths to link & change styles
				var nodePath = new Array();
				nodePath = menuFindNodePath(child);
				for (var j=1; j<nodePath.length; j++) {
					var nodeActive = document.getElementById(nodePath[j]);
					nodeActive.className = 'menu-list-sub open';
					nodeActive.style.display = 'block';	
				}
			}
			// close any open UL nodes
			if (child.nodeName == 'UL') {
				if (child.className != 'menu-list-sub open') {
					child.style.display = 'none';
				} else {
					child.style.display = 'block';
				}
			}
			// repeat process for any nested UL nodes
			menuInit(child);
		}
	}
}

function menuExpand(node) {
	if (!document.getElementById) return false;
	
	var nodePath = new Array();
	nodePath = menuFindNodePath(node);
	if (nodePath.length == 1) {
		// root node selected - reinitialize menu
		menuInit();
	}
	
	// expand selected node
	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			if (child.nodeName == 'UL' && child.className != 'menu-list-sub open') {
				if (child.style.display == 'none') {
					child.style.display = 'block';
				} else {
					child.style.display = 'none';
				}
 			}
		}
	}
}

function menuFindNodePath(node){
	var node_current = node; 
	var path = new Array();
	while (node_current.parentNode!= null) {
		node_current = node_current.parentNode;
    	if (node_current.nodeName == 'UL') {
    		path.unshift(node_current.id);
    	}
	}
    return path;
}

// end hiding-->
