// JavaScript Document
//this script highlights the current page's navigation item
//according to R5 standard navi specs. 
//it looks for the A[nnnnnn] string from the url, 
//if a match is found, it is searched from the link list of current document.
//If that match is inside a node

function FakeSideNaviHighlight (){
  //isolate the Aurl
  var regAurl = /\/A\d{6,10}/;
  var aurl = location.href.match(regAurl);

    if(aurl === null ) {return;}
    for (i=0;i<document.links.length;i++) {
      if ( document.links[i].href.match(aurl) ) {
        addHighLight(document.links[i]); 
      } 
    }
}

function addHighLight(linkObj) {

var hlClass = 'navi_static_pointer'; // highlight class
var naviClass = 'lvl_item'; //class name token
var listElement = linkObj.parentNode;
if (listElement.className.match(naviClass) ){

//higlight the parent list element by giving it the appropriate classname
  var parts = listElement.className.split(' ');
      parts.push(hlClass);
      listElement.className = parts.join(' ');
//remove the anchor object but preserve the text it contains

var text = linkObj.innerHTML;
listElement.removeChild(linkObj);
newText = document.createTextNode(text);
newText.nodeValue = newText.nodeValue.replace(' &amp; ',' & ');
newText.nodeValue = newText.nodeValue.replace(' &#38; ', ' & ');
listElement.insertBefore(newText,listElement.firstChild);
}
}

window.onload = FakeSideNaviHighlight


