// leave single space before first tag for cache
if(window.addEventListener){
   window.addEventListener('load', sitemap, false); 
//   window.addEventListener('load', readPrefs, false); 
   } else {
   window.attachEvent('onload', function(){
      sitemap();
//      readPrefs();
      })
}

// START MAKE SITEMAP INTERACTIVE
function sitemap(){
/* grab all h2 elements
var h = document.getElementById('content').getElementsByTagName('h2');
grab all unordered lists */
var u = document.getElementById('content').getElementsByTagName('ul');

for(i=0;i < u.length;i++){
/*  hide all unordered lists with sitemap class
 if(u[i].className == 'sitemap'){
 u[i].style.display = 'none';
 } */
      // get all links
      var a = u[i].getElementsByTagName('a');
      for(z=0;z < a.length;z++){
         // checks if link has a class of parent
         if(a[z].className == 'parent'){
            var li = a[z].parentNode;
            // creates maximise.gif element if it does not already exist
            var imgChk = li.getElementsByTagName('img');
            if(imgChk.length == 0){
            var img = document.createElement('img');
               img.className = 'icon';
               img.src = '/images/plus.gif';
               img.style.verticalAlign = 'middle';
               li.insertBefore(img, a[z]);
            }
				// set style
				li.className = 'parent';
				//hide child unordered list
				ul = a[z].nextSibling;
				while (ul.nodeType != 1){
					ul = ul.nextSibling;
				}
				ul.style.display = 'none';
				// make clicking new image hide/show child unordered list
				img.onclick = function(){
					li = this.parentNode;					
					ul = li.getElementsByTagName('ul')[0];
					var ulStatus = (ul.style.display == 'none') ? 'block' : 'none';
					ul.style.display = ulStatus;
					// toggle between maximise.gif and minimise.gif
					imgStatus = (ulStatus == 'block') ? 'minus' : 'plus';
					this.src = '/images/' + imgStatus + '.gif';
				}
			}
		}
		
	}
/* 	for(x=0;x < h.length;x++){
 assign unique IDS to each h2 element
		h[x].id = 'h2' + x;
		h[x].className = 'maximise';
// make h2 element show/hide unordered list when clicked
		h[x].onclick = function(){
			var ul = this.nextSibling;
			while (ul.nodeType != 1){
				ul = ul.nextSibling;
			}
			var ulStatus = (ul.style.display == 'none') ? 'block' : 'none';
			ul.style.display = ulStatus;
			var hStatus = (ulStatus == 'block') ? 'minimise' : 'maximise';
			this.className = hStatus;
// set cookie
			return writePrefs(this.id,ulStatus);
		}
	} */
}