function toggleHTMLTree(topic) {
	var informationDiv=document.getElementById('treeInformation');
	if (informationDiv==null){
		return;
	}

	var id = topic +informationDiv.getAttribute('child');

	    var obj=document.getElementById(topic +informationDiv.getAttribute('child'));
    if (obj != null) {
        visible=(obj.style.display!='none');
        var key=document.getElementById(topic + informationDiv.getAttribute('icon'));
        var currentTitle = key.getElementsByTagName('img')[0].title;
    
	    if (visible) {
	        obj.style.display='none';
	        var image=key.getElementsByTagName('img')[0];
	        image.src=informationDiv.getAttribute('plusSrc');	        
	        image.title = changePreTitle(currentTitle,informationDiv.getAttribute('expand'));
	        image.alt = changePreTitle(currentTitle,informationDiv.getAttribute('expand'));
	        if (window.removeFromOpenSetup){
	        	removeFromOpenSetup (topic);
	        }
	    }
	    else {
	        obj.style.display='block';
	       	var image=key.getElementsByTagName('img')[0];
	        image.src=informationDiv.getAttribute('minusSrc');	   
	        image.title = changePreTitle(currentTitle,informationDiv.getAttribute('collapse'));
	        image.alt = changePreTitle(currentTitle,informationDiv.getAttribute('collapse'));
	        if (window.addToOpenSetup){
	         	addToOpenSetup(topic);
	         }
	    }
    }
}

function changePreTitle(currentTitle, preTitle){
	return preTitle+" "+currentTitle.substr(currentTitle.indexOf('-'));
}

// if section is null or invalid there is a fall-back mechanism that will attempt to open up needed section by the topic given
function openHTMLTree(sectionEsc,topicEsc) {
	var section = unescapeJsInHtml(sectionEsc);
	var topic = unescapeJsInHtml(topicEsc);
	var informationDiv = document.getElementById('treeInformation');
	if (informationDiv==null){
		return;
	}
	// highlight the needed topic
	if (topic!=null){
	 	unHighlightAll();
	 	
	 	var leaf = document.getElementById(topic +informationDiv.getAttribute('leaf'));
	 	if (leaf && leaf.className){
	 		leaf.className="setupHighlightLeaf"	;
	 		informationDiv.setAttribute('lastHighlight',topic +informationDiv.getAttribute('leaf'));
	 	}
 	}
 	// get the secton to expand
 	var obj=document.getElementById(section +informationDiv.getAttribute('child'));
 	if (obj==null && topic!=null){
 	
	 	/**
	 	* Try to open up a secton by going to the parent
	 	*/
	 	var leaf = document.getElementById(topic +informationDiv.getAttribute('leaf'));
	 	if (leaf!=null){
	 		var divParent = leaf.parentNode;
        	if (divParent!=null && divParent.id.indexOf(informationDiv.getAttribute('child')) >0){
        		section = divParent.id.substr(0,divParent.id.indexOf(informationDiv.getAttribute('child')));
        		obj=divParent;
        	}
	 	}
 	}
    if (obj != null) {
        var key=document.getElementById(section +informationDiv.getAttribute('icon'));
        var currentTitle = key.getElementsByTagName('img')[0].title;
        obj.style.display='block';
        var image=key.getElementsByTagName('img')[0];      
	    image.src=informationDiv.getAttribute('minusSrc');	   
	    image.title = changePreTitle(currentTitle,informationDiv.getAttribute('collapse'));
	    image.alt = changePreTitle(currentTitle,informationDiv.getAttribute('collapse'));
        var divParent = obj.parentNode;
        if (divParent!=null){
        	divParent = divParent.parentNode;
        	if (divParent!=null && divParent.id.indexOf(informationDiv.getAttribute('child')) >0){
        		var section = divParent.id.substr(0,divParent.id.indexOf(informationDiv.getAttribute('child')));
        		openHTMLTree(section,null);        	
        	}
      }
      if (topic!=null){
        	window.scrollTo(0,key.offsetTop)
        }  	   
    }else if (topic!=null){    
    	// if this topic section was not part of any section
    	var leaf = document.getElementById(topic + informationDiv.getAttribute('leaf'));
    	if (leaf!=null){
    		window.scrollTo(0,leaf.offsetTop)
    	}
    }
}


    
 function unHighlightAll(){
	 	var informationDiv = document.getElementById('treeInformation');
	 	if (informationDiv==null){
			return;
 	    }
    	var lastHighlight = informationDiv.getAttribute('lastHighlight');
    	if (lastHighlight==null){
    		return;
    	}
    	var elementH =  document.getElementById(lastHighlight);
    	if (elementH!=null && elementH.className==informationDiv.getAttribute('highlightClass')){
    		elementH.className =informationDiv.getAttribute('leafClass');
    	}
}


function populateTheTreeInformation(font,child,icon,leaf,expand,collapse,plusSrc,minusSrc,highlightClass,leafClass){
	
	var informationDiv = document.getElementById('treeInformation');
	if (informationDiv==null){
		return;
	}
	informationDiv.setAttribute('font',font);
	informationDiv.setAttribute('child',child);
	informationDiv.setAttribute('icon',icon);
	informationDiv.setAttribute('leaf',leaf);
	informationDiv.setAttribute('expand',expand);
	informationDiv.setAttribute('collapse',collapse);
	informationDiv.setAttribute('plusSrc',plusSrc);
	informationDiv.setAttribute('minusSrc',minusSrc);
	informationDiv.setAttribute('highlightClass',highlightClass);
	informationDiv.setAttribute('leafClass',leafClass);
	informationDiv.setAttribute('lastHighlight','none');
}