﻿function topMenuHighlight(){

    var obj = document.getElementById("topMenu");
    var oChildren = obj.getElementsByTagName("a");
    var oPathArr = window.location.pathname.split('/');
    var strPageName = oPathArr[1].toLowerCase();
    var booFound = false;
    
    //loop round all 'a' elements in the topMenu div element
    for (var i = 0; i < oChildren.length; i++) {

        var strChild = oChildren[i].id.toLowerCase();
        var oF = document.getElementById(strChild);
      
        //look for the link in the top menu that matches the page we are on
        if (strPageName.match(strChild) != null && strChild != "") {//if we find one then set its class as 'selected' so that it is highlighted

            oChildren[i].className = 'selected';
            booFound = true;
        } else {//else set it to empty
            oChildren[i].className = '';
        }
    }
    
    //if we don't find any that match then set the home to selected
    if (booFound == false) {
        var oF = document.getElementById("home");
        oF.className = 'selected';
    }
    


}
