/*---------------------------------------------------------
International Rescue Committee

file:			navigation javascript
description:	controls left navigation bar
				
version:		1.1
author:			Travis Forden, Threespot
date created:	2006-08-18
date modified:	2006-08-28

copyright:		2006

---------------------------------------------------------*/

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("mainnav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function angledBottom() {
	if(!document.getElementById) { return false; }
	if(!document.getElementsByTagName) { return false; }
	if(!document.getElementById("nav_help")) { return false; }
	
	var bottom = document.getElementById("navbottom");
	var navHelp = document.getElementById("nav_help");
	var navSubItem = navHelp.getElementsByTagName("div");
	
	for(i=0;i<navSubItem.length; i++) {
		if(navSubItem[i].className == "active") {
			bottom.className = "nav_show";
		}
	}
}

function setPage() {
	var pageURL = document.URL;
	
	var navRoot = document.getElementById("mainnav");
	
	// get all DIVs in #mainnav
	var navDivs = navRoot.getElementsByTagName("div");
	
	for(i=0;i<navDivs.length;i++) {
		// if div[i] has a className of 'inactive'
		if(navDivs[i].className == "inactive") {
			// get all A's inside this div.
			lnks = navDivs[i].getElementsByTagName("a");
			
			for(j=0;j<lnks.length;j++) {
				// compare the a.href value to document.location
				// if the a.herf == document.location
				if(lnks[j].href == pageURL) {
					// set the div classname to 'active'
					navDivs[i].className = 'active';
					
					// set the anchor class to 'on'
					lnks[j].className = 'on';
				}
			}
		}
		
	}
	
}


function navLoadEvents() {
	startList();
	setPage();
	angledBottom();
}

addLoadEvent(navLoadEvents);

