// = 0 ) where_you_are = where_you_are.replace( re, "" ); /* end cbader */ if (normalizeURL(where_you_are) == normalizeURL(all_the_anchors[i].href)) { return_anchor = all_the_anchors[i]; } } if (null == return_anchor) return false; return return_anchor; } /* Don't choke if we don't have getElementById*/ if (!document.getElementById) document.getElementById = function() { return null; } /* Initializes (appropriately hides) all of the ul's below the * second level ul. * @param id string the id of * @return void */ function initializeNavTree(tree_id) { var nav_tree = document.getElementById(tree_id); //hide the nav_tree to prevent flash of unstyled content if (nav_tree) { //in case the page doesn't have a nav_tree nav_tree.style.display = 'none'; if (nav_tree) { var anchor = whereAmI(nav_tree); if (anchor) { var children = nodeChildrenByTagName(nav_tree, 'ul'); hideChildUls(children[0]); //show the menu one below this anchor (if it exists) expandChildNavTree(anchor); //show the entire menu above this anchor expandParentsNavTree(anchor, tree_id); } else { alert('This page is not linked to in the sidenav.');} } //show the nav_tree nav_tree.style.display = 'block'; } return; } //End menuExpandable /** * Hides all child ul's from a starting ul, descending into * child nodes * @param Object el node to initialize * @return void */ function hideChildUls(el) { try { var children = el.childNodes; } catch (er) { return; } for (var n=0; n < children.length; n++) { var item = children[n]; if (String(item.tagName).toUpperCase() == "LI") { /* trim any text nodes and descend */ var nodes = item.childNodes; for (var t=0; t < nodes.length; t++) { if (String(nodes[t].tagName).toUpperCase() == "UL") { nodes[t].style.display = 'none'; hideChildUls(nodes[t]); } }// end for loop } } } /* Starting from an anchor nested within a UL, displays the UL it's nested in, * then all of its parents', grandparents', great-grandparents' ULs * stopping only when it gets to a specific id * @param Object node ul * @param string id ID of node to stop at * @return void */ function expandParentsNavTree(a, id) { //show this ul and all of its parents var node = a; if (node != null) { while (node.id != id) { if (String(node.tagName).toUpperCase() == "LI") { var children = nodeChildrenByTagName(node, "A", 1); if (children[0]) { nodeAddClass(children[0], 'activelink'); } } if (String(node.tagName).toUpperCase() == "UL") { node.style.display = 'block'; } node = node.parentNode; } } } /* Starting from an anchor nested within a ul, displays its li, * then all of its parents, grandparents, great-grandparents, etc. * stopping only when it gets to a specific id * @param Object node ul * @param string id ID of node to stop at * @return void */ function expandChildNavTree(a) { var node = a; //get the LI that the anchor is nested in while (String(node.tagName).toUpperCase() != "LI") { node = node.parentNode; } //loop through the children of that li, display the ul if it's in there var node_children = node.childNodes; for (var n=0; n < node_children.length; n++) { var this_node = node_children.item(n); if (String(this_node.tagName).toUpperCase() == "UL" ) { this_node.style.display = 'block'; } } } /* chop index.html, index.php, page anchors, and weblogin cruft, * from the end of URLs*/ function normalizeURL(url_string) { var file_names = Array('index.html', 'index.htm', 'index.php'); for (var i=0; i