function setEvent(){
//remove first set of empty #textnodes in firefox
 Element.cleanWhitespace('nav');
 Element.cleanWhitespace('dropMenu');
// hide all div's within the drop menu section of the nav
nodesToHide = document.getElementById('dropMenu').getElementsByTagName('div'); 
	for(var i=0;i<nodesToHide.length;i++){
		nodesToHide[i].className='hidden';		
	}
// force all a href's to open in content frame
nodesToShow = document.getElementById('nav').getElementsByTagName('a'); 
	for(var i=0;i<nodesToShow.length;i++){
		nodesToShow[i].onmouseover=function() {
		this.parentNode.id='hover';
		}
		nodesToShow[i].onmouseout=function() {
		this.parentNode.id='';
		}
		nodesToShow[i].onclick=function() {
			if (window['currentNode'] != undefined){
			//hide the children function
			hideChildren=function(){
				childDivs=masterNode.nextSibling.getElementsByTagName('div');
				for(var i=0;i<childDivs.length;i++){
				childDivs[i].style.display="";}
				childPs=masterNode.nextSibling.getElementsByTagName('p');
				for(var i=0;i<childPs.length;i++){
				childPs[i].className="";}
			}
				lastNode = currentNode;
				//see if most recently clicked node is a master node
				if (lastNode.parentNode.id == 'dropMenu' || lastNode.parentNode.id =='nav'){
					// if so set master node 
					masterNode = lastNode;	
					if (nextNode !=undefined && nextNode.firstChild.nodeName =='P'){
					nextNode.firstChild.style.backgroundImage='';}
				}
						//apply background to currently selected item 
						//unless it's a top level node 
						if(this.parentNode.parentNode.id == 'dropMenu'){
						lastNode.style.backgroundImage='';
						}
						else{
						this.parentNode.style.backgroundImage='url(images/toc_nav/currentitm.gif)';
						this.parentNode.style.backgroundRepeat='no-repeat';
						this.parentNode.style.backgroundPosition='6px';
						// if your're selecting the same node, keep the arrow there
						if (lastNode != this.parentNode){
						lastNode.style.backgroundImage='';}
						}
						// hack to close all subsections but the current one
						if (masterNode.nextSibling !=undefined){
						if(this.parentNode.parentNode.previousSibling == masterNode){				
							// if a child of this subsection was clicked prior to this subsection being clicked
							// assign lastNode back to this subsection so it will close properly
							testitem01 = this.parentNode.nextSibling.getElementsByTagName('p');
							for(var i=0;i<testitem01.length;i++){
							if (lastNode == testitem01[i]){
							lastNode = this.parentNode;
							childDivs=lastNode.nextSibling.getElementsByTagName('div');
							for(var i=0;i<childDivs.length;i++){
							childDivs[i].style.display="";}
							childPs=lastNode.nextSibling.getElementsByTagName('p');
							for(var i=0;i<childPs.length;i++){
							childPs[i].className="";}}
							}
							if (this.parentNode.className!='active default'){
							//now close them
							if (lastNode!=this.parentNode){
							hideChildren();
							}
							}
						}
						}
						//and the last node isnt the current node
						if(this.parentNode.parentNode.id == 'dropMenu' || this.parentNode.parentNode.id == 'nav'){
							//if the current node is not the masternode
						if(this.parentNode != masterNode){
							// hide the last master node
							masterNode.className ="";
							if(masterNode.nextSibling != undefined){
							masterNode.nextSibling.style.display="";}
						}
						// and it's children
						if (masterNode.nextSibling !=undefined){
							hideChildren();
						}}
			}
			currentNode = this.parentNode;
			nextNode = currentNode.nextSibling;
			if(currentNode.parentNode.id=='nav'){
			this.parentNode.style.backgroundImage='url(images/toc_nav/currentitm.gif)';
			this.parentNode.style.backgroundRepeat='no-repeat';
			this.parentNode.style.backgroundPosition='6px';
			}
			if (nextNode != undefined){
				//remove rest of empty #textnodes in firefox
				Element.cleanWhitespace(nextNode);
				if(currentNode.parentNode.id!='nav' && nextNode.nodeName=='DIV'){
				currentNode.className = currentNode.className? "":"active";
				nextNode.style.display = nextNode.style.display? "":"block";
				//hack to open the first section within this top level section
				if(currentNode.parentNode.id=='dropMenu'){
					Element.cleanWhitespace(nextNode.firstChild.nextSibling);
					nextNode.firstChild.className ='active default';
					nextNode.firstChild.nextSibling.style.display ='block';
					nextNode.firstChild.style.backgroundImage='url(images/toc_nav/currentitm.gif)';
					nextNode.firstChild.style.backgroundRepeat='no-repeat';
					nextNode.firstChild.style.backgroundPosition='6px';
					}
				}
			}
			else return;
			}
	}
}
if(window.addEventListener){ // Mozilla, Netscape, Firefox
	window.addEventListener('load', setEvent, false);
} else { // IE
	window.attachEvent('onload', setEvent);
}
function matchElm(arry, node){
	var nodeString = new Array(arry);
	var isMatch = new RegExp(nodeString).test(node); 
	return isMatch;
}
function doFire(getObj) {
	var flag='false';
	var selectedLink='';
	nodesToTest = document.getElementsByTagName('a'); 
	for(var i=0;i<nodesToTest.length;i++){
		if(matchElm(nodesToTest[i].href, getObj)){var flag = 'true'; 
		selectedLink=nodesToTest[i]};
	}
	// if the selectedLink is a top-level subsection (1.1)
	// change the selected link to it's parent item (1)
	if(flag!='false' && selectedLink.parentNode.parentNode.id!='nav'){
	Element.cleanWhitespace(selectedLink.parentNode.parentNode);
	if(selectedLink.parentNode.parentNode.previousSibling.parentNode.id=='dropMenu'){
		if(selectedLink.parentNode.previousSibling==null){
		selectedLink=selectedLink.parentNode.parentNode.previousSibling.firstChild;
		};
	};};
	//if the link to this page had an incorrect anchor
	//or anchor was improperly placed in TOC
	//strip the anchor and load proper page
	if(flag!='true'){
		var arrs = [];
		nodesToTest = document.getElementsByTagName('a'); 
			for(var i=0;i<nodesToTest.length;i++){
			path = nodesToTest[i].href;
			var path_array = path.split('#');
			path = path_array[0];
				if(matchElm(path, getObj)){var flag = 'true'; 
				arrs[arrs.length] = nodesToTest[i];
				selectedLink = arrs[0];
				};
			}
	}
	if(flag!='false'){
	if(selectedLink.parentNode.parentNode.id!='nav'){
	getAncestorsUntilID(selectedLink, "dropMenu");}
		if(selectedLink.parentNode.parentNode.id=='dropMenu'){
	 	if(selectedLink.parentNode.nextSibling.style.display=='block'){selectedLink.parentNode.nextSibling.style.display=''; selectedLink.parentNode.className='';};}
	/*@cc_on
	@if (@_jscript_version >= 5)
	selectedLink.fireEvent("onclick");
	@else @*/
	var clickevent=document.createEvent("MouseEvents");
 	clickevent.initEvent("click", true, true);
 	selectedLink.dispatchEvent(clickevent);
	/*@end
	@*/
   	 // don't let button clicks bubble
   	//event.cancelBubble = true
	return;
}
}
function getAncestorsUntilID(node, id)  {
 var stack = new Array();
 var parent = node;
 while(parent.id != id) {
  parent = parent.parentNode;
  //clear empty #text nodes in FF
  Element.cleanWhitespace(parent.parentNode);
  if (parent.id != 'dropMenu' && parent.nodeName != 'P'){
  if (parent.style.display=='block'){parent.style.display=''; parent.previousSibling.className='';}	
  // check to see if the item open is within the first set of sub categories
  if(parent.previousSibling.parentNode.previousSibling.parentNode.id=='dropMenu'){
  	if(parent.previousSibling.previousSibling==null){
		var topLevelSub = parent.previousSibling;
	}
  }
  // if so, don't fire the click on it
  if(parent.previousSibling!=topLevelSub){
  stack.push(parent.previousSibling.firstChild);
  }
 }
  }
 while(stack.length != 0) {
 /*@cc_on
 @if (@_jscript_version >= 5)
 stack.pop().fireEvent("onclick");
 @else @*/
 var clickevent=document.createEvent("MouseEvents");
 clickevent.initEvent("click", true, true);
 stack.pop().dispatchEvent(clickevent);
 /*@end
 @*/
 }
}
