// JavaScript Document

window.onload=function(){
	changeClass();
}

function changeClass(){
	var path = window.location.pathname;
	//removes the .html from the URL
	path = path.replace('.html','')
	//removes the first /
	path = path.substr(1);
	//splits the rest of the URL into an array
	pathArray = path.split( '/' );
	
	var nav = document.getElementById('globalNav');
	linkList = nav.getElementsByTagName('a');
	
	for(i=0; i<linkList.length; i++) {
		if(linkList[i].className == pathArray[0]) {
			linkList[i].className += " active";
		}
	}
	if(pathArray[0]=="programs") {
		var programsNav = document.getElementById('programsNav');
		programslinkList = programsNav.getElementsByTagName('a');
	
		for(i=0; i<programslinkList.length; i++) {
			if(programslinkList[i].className == pathArray[1]) {
				programslinkList[i].className += " active";
			}
		}
	}
	else if(pathArray[0]=="grants") {
		var grantsNav = document.getElementById('grantsNav');
		grantslinkList = grantsNav.getElementsByTagName('a');
	
		for(i=0; i<grantslinkList.length; i++) {
			if(grantslinkList[i].className == pathArray[1]) {
				grantslinkList[i].className += " active";
			}
		}
	}
}

function closeIframe() {
	var iframe = document.getElementById('GB_frame');	
	
	iframe.parentNode.removeChild(iframe);
	GB_hide();
}

