/* JavaScript to highlight a page's table of contents entry onLoad, then
** darken it on onUnLoad.  Must check that the element can be found, because
** the ToC may not be finished loading yet.
**
** Before doing anything else, check that we are properly framed and redirect
** to the index page if we are not.
*/


// For top level entries with no children, highlight self.
function bright0(page) {
   if (top.location == self.location) 
     top.location.replace("index.html?" + window.location.href);
   else {
      var me = parent.toc.document.getElementById(page);
      if (me) me.style.color='red';
   }
}
function dim0(page) {
   var me = parent.toc.document.getElementById(page);
   if (me) me.style.color='black';
}

// For top level entries, highlight self and expand children.
function bright1(page) {
   if (top.location == self.location) 
     top.location.replace("../index.html?" + window.location.href);
   else {
      var me = parent.toc.document.getElementById(page);
      if (me) {
         var next = me.parentNode.parentNode.nextSibling;
         me.style.color='red';
         me.parentNode.parentNode.firstChild.innerHTML = '<small>&#9660;<\/small>';
         while (next.nodeName == '#text') next = next.nextSibling;  /* Skip whitespace nodes */
         next.style.display='';
      }
   }
}
function dim1(page) {
   var me = parent.toc.document.getElementById(page);
   if (me) me.style.color='black'
}

// For sub-entries, highlight self and expand self.
function bright2(page) {
   if (top.location == self.location) {
     //var dir = self.location.href.substring(0,self.location.href.lastIndexOf('/'));
     //var par = dir.substring(0,dir.lastIndexOf('/'));
     //alert(par);
     top.location.replace("../index.html?" +  self.location.href);
   } else {
      var me = parent.toc.document.getElementById(page);
      if (me) {
         var prev = me.parentNode.parentNode.parentNode.previousSibling;
         me.style.color='red';
         me.parentNode.parentNode.parentNode.style.display='';
         while (prev.nodeName == '#text') prev = prev.previousSibling;  /* Skip whitespace nodes */
         prev.firstChild.innerHTML = '<small>&#9660;<\/small>';
      }
   }
}
function dim2(page) {
   var me = parent.toc.document.getElementById(page);
   if (me) me.style.color='black'
}
