/*
   pureDOM navigator
   written by Christian Heilmann http://www.onlinetools.org/
   Version 1.0
   05.11.2003
*/

/*
   Customised and extended by Andrew Green, Article Seven, http://www.article7.co.uk/
   Last updated: Wednesday, 13 April 2005
*/

// Presets, should they not be defined
var blankpic='/res/fastsitemap/DOMblank.gif';
var onpic='/res/fastsitemap/DOMplus.gif';
var offpic='/res/fastsitemap/DOMminus.gif';
var clockpic='/res/fastsitemap/DOMpause.gif';
var picmargin=5;
var picx=10;
var picy=10;
var picalt='Collapsed or Expanded indicator';
var pictitle='Click to expand or collapse';

// Checking for DOM compatibility	
if (document.getElementById && document.createTextNode && document.createElement){canDOM=true}

function expinit(rootID) {
   if (canDOM){
      var rootnode = document.getElementById(rootID);
      for(var i = 0; i < rootnode.childNodes.length; i++){
         var tree = rootnode.childNodes[i];
         if (tree.nodeType == 1 && tree.nodeName == 'UL') { // can we guarantee upper-case?
            for(var j = 0; j < tree.childNodes.length; j++){
               var mynode = tree.childNodes[j];
               if (mynode.nodeType == 1) { // aka document.ELEMENT_NODE
                  addimg = document.createElement('img');
                  addimg.style.border='none';
                  addimg.style.width=picx+'px';
                  addimg.style.height=picy+'px';
                  addimg.style.marginRight=picmargin+'px';
                  if (mynode.getElementsByTagName('ul').length == 0) {
                     addimg.src=blankpic;
                     addimg.alt='';
                     mynode.insertBefore(addimg,mynode.firstChild);
                  } else {
                     addimg.src=onpic;
                     addimg.alt=picalt;
                     addimg.title=pictitle;
                     cola = document.createElement('a');
                     cola.setAttribute('href','#');
                     cola.onclick=function() {gpopen(this);return false;};

                     cola.onkeypress=function() {gpopen(this);return false;};
                     cola.appendChild(addimg);
                     mynode.insertBefore(cola,mynode.firstChild);
                     for(var k = 0; k < mynode.childNodes.length; k++){
                        var mychild = mynode.childNodes[k];
                        if (mychild.nodeType == 1 && mychild.nodeName == 'UL') { // can we guarantee upper-case?
                           mychild.style.display='none';
                           if (mychild.getElementsByTagName('strong').length > 0) {
                              exgp(cola);
                              ex(cola);
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

function gpopen(gp) {
   if (canDOM) {
      gp.getElementsByTagName('img')[0].src = clockpic;
      var timer = setTimeout(function() {
         exgp(gp);
         ex(gp);
      }, 10);
   }
}

function exgp(gp){
   if (canDOM){
      
      gp.onclick=function() {ex(this);return false;};
      gp.onkeypress=function() {ex(this);return false;};
      
      alluls = gp.parentNode.getElementsByTagName('UL');
      alllis = gp.parentNode.getElementsByTagName('LI');
      
      for(i=0;i<alllis.length;i++){
         addimg = document.createElement('img');
         addimg.src=blankpic;
         addimg.style.border='none';
         addimg.style.width=picx+'px';
         addimg.style.height=picy+'px';
         addimg.alt='';
         addimg.style.marginRight=picmargin+'px'
         cola = document.createElement('a');
         cola.setAttribute('href','#');
         cola.onclick=function() {ex(this);return false;};

         cola.onkeypress=function() {ex(this);return false;};
         cola.appendChild(addimg);
         alllis[i].insertBefore(cola,alllis[i].firstChild);
      }

      for(i=0;i<alluls.length;i++){
         subul=alluls[i];
         if(subul.parentNode.tagName=='LI'){
            // Do not collapse when there is a strong element in the list.
            highlight=subul.getElementsByTagName('strong').length==0?true:false;
            disp=highlight?'none':'block';
            pic=highlight?onpic:offpic;
            // End  highlight change
            mom=subul.parentNode.getElementsByTagName('A')[0]
            if(mom){
               momimg=mom.childNodes[0];
               momimg.setAttribute('alt',picalt);
               momimg.setAttribute('title',pictitle);
               momimg.src=pic;
               subul.style.display=disp;
            }
         }
      }
      
   }
}

// Collapse and Expand node.
function ex(n){
   if(canDOM){
      u=n.parentNode.getElementsByTagName("ul")[0];
      if(u){
         u.style.display=u.style.display=='none'||u.style.display==''?'block':'none';
         img=n.getElementsByTagName('img')[0];
         img.src=img.src.indexOf(offpic)!=-1?onpic:offpic;					
      }
   }			
}

// Introductory text for the public sitemap, done as a document.write so it doesn't show if you ain't got JavaScript
function publicintro() {
   if (canDOM) {
      var intro = '<p>Click the triangles (<img src="/res/fastsitemap/DOMplus.gif" width="10" height="10" alt=""/>) in the map below to expand or collapse the different levels of the site.  Some areas require your computer to do some calculations when you first try to expand them.  When this happens, the triangle will become paler (like this: <img src="/res/fastsitemap/DOMpause.gif" width="10" height="10" alt=""/>), and the section will expand after a couple of moments.</p>';
      document.write(intro);
   }
}
