// left_nav.js
// 12-17-07
// Coded by SGB as collapsable navigation
// Nothing locks, lockIndex is used to determine which
// subnav to open on load, if any

// get all divs
var divArray;
var subNavArray = new Array();
var mouseOutArray = new Array();
var lockIndex = -1; 

// helper function to set the index, ie lock the nav
function setIndex(index)
{
	lockIndex = index;
}

// opens a specific nav item
// called by nav links in page.leftNav.asp
function openSubNav(index)
{
	//subNavArray[index].style.height = "auto";
	//subNavArray[index].style.visibility = "visible";
	subNavArray[index].style.display = "block";
}

function closeSubNavs()
{
	// close all the divs
	var i;
	for (i = 0; i < subNavArray.length; i++)
	{
	//	if (subNavArray[i].style.height != "0")
	//		subNavArray[i].style.height = "0";
		
	//	subNavArray[i].style.visibility = "hidden";
	subNavArray[i].style.display = "none";
	}
}

// gets the subnav divs and stores them globally
// run on load of page
function getDivs()
{
	// get all the divs inside the subNav div
	subNavArray = document.getElementById("subNav").getElementsByTagName("div");

	// set up the mouseOutArray	
	var i;
	for (i = 0; i < subNavArray.length; i++)
	{
		mouseOutArray[i] = 0;
	}
}

// opens the appropriate subnav, if the index isn't locked.
function mouseOver(index)
{
	// set the mouseOutArray spot to 0
	mouseOutArray[index] = 0;
	// sets a slight delay from mouseover to opening
	var t = setTimeout("mouseOverGuts(" + index + ");", 400);
	//mouseOverGuts(index);
}

function mouseOverGuts(index)
{
	// open it, if it's not open already
	// and as long as the mouse hasn't left the parent link
	if ((lockIndex != index) && (mouseOutArray[index] == 0))
	{
		// close all subnavs
		closeSubNavs();
		
		// open the index div
		openSubNav(index);
		
		setIndex(index);
	}
}

// called on mouseOut
function mouseOut(index)
{
	mouseOutArray[index] = 1;
}

