﻿<!--
/**
 * Script for highlighting the left navigation and the top navigation.
 * 
 * Thomas Nicolosi
 * thomas@reduscorp.com
 * 
 * Rev. 1.00
 * 05/12/2010
 *
 */
function getNav(navSelector){
    /**
     * Selects a set of elements and returns as an array.
     */
    //var theSelector = "div.topnav ul li a";
    var theNav = $(navSelector).map(function(){
        //load selected elements into an array.
                                                    var each = $(this);
                                                    return each;
                                                    });
    return theNav;
    }
function getNavTitle(theAnchor){
    /**
     * Gets the title attribute of the anchor reqested.
     */
    theAnchorTitle = theAnchor.attr("title");
    return theAnchorTitle;
    }
function topNavFirstCheck(navTitle) {
/**
 * Controls hover state of the first item in the top nav list.
 */
if ( navTitle === "About Powerwave"){
    $("div.topnav-inner").removeClass("topnav-inner-hover-off").addClass("topnav-inner-active");
    };
}

function matchNav(theSelector,navKey,navKeyAlt,newClass){
    /**
     * "theSelector" is a jQuery formatted selector that targets the navigation anchor of interest.
     * "navKey" is the anchor title attribute that is being matched.
     * "navKeyAlt" is the alternative anchor title attribute that can also be matched.
     * "newClass" is the CSS class the defines the navigation element highlighting.
     */
    var theLink = "";//Variable to hold each anchor element.
    var theTitle = "";//Variable to hold the anchor element title attribute.
    var theNav = getNav(theSelector);//Array of anchor elements is returned by getNav.
    /**
     * Loop through theNav and test to see if the anchor title "theTitle" matches navKey.
     * "navKey" is set for left nav and the top nav via transfer placeholders in Open Text.
     * These are made available to this script by filling the "thisPage" object in the head script when the page loads.
     * thisPage.leftNav and thisPage.topNav are the values to match for the left and top navs respectively.
     * If a match is made then newClass CSS class is added to the anchor element and the script exits the loop.
     */
    var i = 0;
    for ( i = 0; i < theNav.length; i++){
        theLink = theNav[i];
        theTitle = getNavTitle(theLink);
        if (theTitle === navKey || theTitle === navKeyAlt){
            theLink.addClass(newClass);
            topNavFirstCheck(navKey);
            }           
        }
    }
$(document).ready(function(){
    //match left nav title and highlight.
    matchNav(".wrapper-left-nav ul.left-nav-top li ul li a",thisPage.leftNav,thisPage.leftNavAlt,"left-nav-active");
    //match top nav title and highlight.
    matchNav("div.topnav ul li a",thisPage.topNav,thisPage.topNav,"top-nav-active");
    });
//-->
