// Navigation JavaScript
// BY: Cameron McGregor
// CREATED: ???
// LAST UPDATE: JAN-09-2008
// ABSTRACT: Contains javascript functions used to 
//			highlight Insulin Journal navigation items
/*
function findNav(strURL,nLevel)
{
	//Change /\ and <space> to .. and _
	var idName = "path.Insulin-Journal-Production.Home" + strURL.replace(/\\/g, ".").replace(/\//g, ".").replace(/ /g, "_");
	var ilNav = document.getElementById(idName);
		
//	debugScript("Name: " + idName + " , URL: " + strURL);
	
	//No object call function with next URL, prevent infinite recursion
	if ((!ilNav) && (nLevel < 100))
	{
		
		//Search for last /slash
		var nSlashPos = strURL.lastIndexOf("/");
		if (nSlashPos != -1)
		{
			
			//debugScript(strURL);
			
			if ((nSlashPos != -1) && (strURL != ""))
				ilNav = findNav(strURL.substring(0, nSlashPos), nLevel + 1);
		}
	}
	
	return ilNav;
}

function doNavContext()
{
	//Make sure the path file name is removed from the end
	var pathName = location.pathname;
	
	var nSlashPos = pathName.lastIndexOf("/");
	
	if (nSlashPos != -1)
		pathName = pathName.substring(0, nSlashPos);
	
	//Check for an navigation menu node
	var theNav = document.getElementById("pnav");
	var foundNav = findNav(pathName, 0);
	if ((theNav) && (foundNav))
		foundNav.className = "active";

}

function debugScript(outln)
{
	alert(outln);
	/*
	var out = document.getElementById("page");
	if (out)
		out.innerHTML = out.innerHTML + outln + "<br />";
	*/
}