/*
	pureDOM navigator
	written by Christian Heilmann http://www.onlinetools.org/
	Version 1.0
	05.11.2003
*/
// Presets, should they not be defined
var blankpic='http://www.nikhef.nl/pub/experiments/bfys/lhcb/outerTracker/images/bbdoteen.gif';
var onpic='http://www.nikhef.nl/pub/experiments/bfys/lhcb/outerTracker/images/plus.gif';
var offpic='http://www.nikhef.nl/pub/experiments/bfys/lhcb/outerTracker/images/minus.gif';
var picmargin=5;
var picx=15;
var picy=15;
var picalt='Collapsed or Expanded indicator';
var pictitle='Click to expand or collapse';
var parentID='';
// Checking for DOM compatibility	
if (document.getElementById && document.createTextNode && document.createElement){canDOM=true}

function expinit(){
	if (canDOM){
		if(parentID && document.getElementById(parentID)){
			allas=document.getElementById(parentID).getElementsByTagName('A');
			alluls=document.getElementById(parentID).getElementsByTagName('UL');
			alllis=document.getElementById(parentID).getElementsByTagName('LI');
		}else{
			alluls=document.getElementsByTagName('UL');
			alllis=document.getElementsByTagName('LI');
		}
		for(i=0;i<alllis.length;i++){
			islink=alllis[i].getElementsByTagName('A')[0];
			if(islink){
				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.parentNode.getElementsByTagName('strong').length==0?true:false;
				disp=highlight?'none':'block';
				pic=highlight?onpic:offpic;
				// End  highlight change
				childs=subul.getElementsByTagName('li').length
				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;					
		}
	}			
}
window.onload=expinit;

