/********************************************************************************** * Author: David Millar (www.rTraction.com) * * Date: December. 18, 2006 * * Purpose: To find the correct active page(s) and ensure they highlight properly * * * * Revision 1.2: the script now only opens child elements, we have a clause in * * the header called noscript where it protects people without * * javascript * ********************************************************************************** * Revision 1.1: adjust script to always default to open, thus ensuring if * * someone has no javascript or its disabled they still can * * navigate the site properly, and will only miss visual effects * ********************************************************************************** * Revision 1.0: create a script that detects left nav, and current url * **********************************************************************************/ // Save the current url var url = window.document.location.toString(); // Get our left navigation div var leftNav = document.getElementById('leftNav'); // Flag for elements set to active var activeSet = false; // Get all anchors within our DIV var rows = leftNav.getElementsByTagName("A"); for( var i = rows.length - 1, row; row = rows[i]; i-- ) { // If we find a match, set the className to active // (note: photogallery is an exception because 4 pages use the same navigation item as a reference) if( url.indexOf( row.pathname ) != -1 || ( url.indexOf( "about-us/photo-gallery-" ) != -1 && row.pathname.indexOf( "about-us/photo-gallery" ) != -1 ) ) { // Flag our link as active - Only do so if we haven't already activated a child element if( ( row.name == null || row.name != "nohighlight" ) && !activeSet ) { row.className = "active"; activeSet = true; if( row.parentNode.childNodes.length > 2 && row.parentNode.childNodes[2].nodeName == "UL" ) { row.parentNode.childNodes[2].className = "open"; } else if( row.parentNode.parentNode.nodeName == "UL" ) { // Ensure any UL's above our object remain visible row.parentNode.parentNode.className = "open"; } } } if( i == 0 ) { break; } // Break to escape loop }