navTimer = false;
pageCurrentItem = 0;
	/* pageCurrentItem is the global variable equivalent to class="currentItem" */


function init(){
	/* set pageCurrentItem by checking class */
		getDivs();
if(newsNav == true){
		for (i=0; i<(mainNavIds.length); i++){
			var mainNavClass =mainNavIds[i].className;
			if (mainNavClass == "currentItem"){
				pageCurrentItem = i;
			}
		}
	highlightTemp = pageCurrentItem;

	highlight(highlightTemp);
}	
}

function getDivs(){
if(!document.getElementById("subNav1")){
newsNav = false;
}
else{
newsNav = true;
	/* generic function for getting all the relevant divs */
	mainNavId = document.getElementById("subNav1");
	mainNavIds = mainNavId.getElementsByTagName('td') ;

	subNavId = document.getElementById("subNav2");
	subNavIds = subNavId.getElementsByTagName('div') ;
}	
}

function reset (){
	/* onmousover, will set div back to their display on load after timer expires */
highlightTemp = pageCurrentItem;
}
function reset2(){
	if(document.getElementById){
	/* called by timer, sets divs to current value of highlightTemp. calls non-recursive highlight */
		clearTimeout(navTimer);
		navTimer = false;
		getDivs();
		highlight2(highlightTemp);
	

	}
}
function highlight(subSection){
/* highlight moused-over section */
highlightTemp = subSection;
if(!navTimer){
highlightCore(highlightTemp);
}
/* set timer */
navTimer = setTimeout("reset2()",600);

}

function highlight2(subSection){
highlightTemp = subSection;

highlightCore(highlightTemp);

}

function highlightCore(subSection){
	if(document.getElementById){
		getDivs();
		for (i=0; i<(subNavIds.length); i++){
			subNavIds[i].style.visibility = "hidden";
		}

		for (i=0; i<(mainNavIds.length); i++){
			mainNavIds[i].style.backgroundColor = "black";
			mainNavIds[i].style.textTransform = "none";
		}

		subNavIds[subSection].style.visibility = "visible";
		mainNavIds[subSection].style.backgroundColor = "#00309C";
		mainNavIds[subSection].style.textTransform = "uppercase";
	}

}

if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}
else {
window.onload =  init; 
}
