/////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2007, 2008, Oracle. All rights reserved.
// Function : bia_agencymap
// Comments : 
/////////////////////////////////////////////////////////////////////////////

// this version is heavily parameterised with "mainColor" and "hotColor" 
// just like the navigation fragments
// it might be better to leave it all to stylesheet edits...
// or - better still, leave it as server side stuff to generate the <style> defs 
// and the display code...
//
//BIA Comments:
//This code has been modified to create dynamic lists for navigation.
//A list can be generated from paramaterized start points and end points.
//The start point is m_ShowNode and the end point is m_HideNode.
//All items and subitems in the site's directory in between these points will be displayed.
//The ability to skip items is also available and is explained below. 

function bia_agencymap(strTextColor, strHoverColor, strFocusColor, strClassName, strShowHome, strShowFocus, strShowNode, strHideNode)
{
	this.m_TextColor  = '';
	this.m_HoverColor = '';
	this.m_FocusColor = '';
	this.m_ClassName  = 'bia_agencymap';
	this.m_HideNode   = '';
	this.m_ShowNode   = '';

	this.m_ShowHome   = false;
	this.m_ShowFocus  = false;	
	this.m_ShowFlag   = false;	
	
	this.m_NavPath    = g_navNode_Path;
		
	bia_agencymap.prototype.Display = bia_agencymap_Display;
	bia_agencymap.prototype.DisplayNode = bia_agencymap_DisplayNode;
	
	if (strTextColor != '')
		this.m_TextColor = strTextColor;
		
	if (strHoverColor != '')
		this.m_HoverColor = strHoverColor;

	if (strFocusColor != '')
		this.m_FocusColor = strFocusColor;

	if (strClassName != '')
		this.m_ClassName = strClassName;

	if (strShowNode != '')
		this.m_ShowNode = strShowNode;

	if (strHideNode != '')
		this.m_HideNode = strHideNode;

	if (strShowHome == 'true')
		this.m_ShowHome = true;
		
	if (strShowFocus == 'true')
		this.m_ShowFocus = true;
}

function bia_agencymap_Display (node)
{
	//document.write ('<div');
	
	//if (this.m_TextColor != '')
	//	document.write (' style="color: ' + this.m_TextColor + ';"');
		
	//Outside of the loop
	document.write ('<ul>');

	//Inside of the loop	
	this.DisplayNode(node);
	
	//Outside of the loop
	document.write ('</ul>');
}

function bia_agencymap_DisplayNode(node)	
{
	var nodeColor = this.m_TextColor;
	var nodeClass = this.m_ClassName;
	var nodeLevel = node.m_level;
	
	if (nodeLevel > 6)
		nodeLevel = 6;

if (node.m_level != this.m_NavPath.length) {
	document.write(" Show Nothing ");
}
else {
		
	if (node.m_level > 0 || this.m_ShowHome)
	{
		var ds = new Array();
		var di = 0;

		if (this.m_ShowFocus)
		{
			if (this.m_NavPath[node.m_level] == node.m_id)
			{
				if (node.m_level > 0 || (node.m_level == 0 && this.m_NavPath.length == 1))
				{
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '-focus';
				}
			}
		}
	
		if (node.m_level > 0)
			nodeClass += '-' + nodeLevel;

		//Start of item in loop
		ds[di++] = '<div';
		ds[di++] = ' class="' + nodeClass + '"';
		ds[di++] = '>';
		
		//Start of list item and link in loop		
		ds[di++] = '<li><a href="' + node.m_href + '"';
		
		//ds[di++] = ' class="' + nodeClass + '"';
		
		//if (nodeColor != '')
		//{
		//	ds[di++] = ' style="color: ' + nodeColor + ';"';
		//	
		//	if (this.m_HoverColor != '')
		//	{
		//		ds[di++] = ' onmouseover="this.style.color=\'' + this.m_HoverColor + '\'"';
		//		ds[di++] = ' onmouseout="this.style.color=\'' + nodeColor + '\'"';
		//	}
		//}
		ds[di++] = '>';

		/*if (node.m_label == 'OTS') {
			ds [di++] = "Office of Trust Services (OTS)";
		} 
			else if (node.m_label == 'OIS') {
			ds [di++] = "Office of Indian Services (OIS)";
			} 
			else if (node.m_label == 'ILCA') {
			ds [di++] = "Indian Land Consolidation Act (ILCA)";
			} 
			else if (node.m_label == 'OJS') {
			ds [di++] = "Office of Justice Services (OJS)";
			}
			else if (node.m_label == 'ASIA') {
			ds [di++] = "Assistant Secretary-Indian Affairs (AS-IA)";
			}
			else if (node.m_label == 'BIA') {
			ds [di++] = "Bureau of Indian Affairs (BIA)";
			}
			else if (node.m_label == 'BIE') {
			ds [di++] = "Bureau of Indian Education (BIE)";
			}
			else if (node.m_label == 'OCIO') {
			ds [di++] = "Office of the Chief Information Officer (OCIO)";
			}
			else if (node.m_label == 'OHCM') {
			ds [di++] = "Office of Human Capital Management (OHCM)";
			}
			else if (node.m_label == 'OFECR') {
			ds [di++] = "Office of Facilities, Environmental and Cultural Resources (OFECR)";
			}
			else if (node.m_label == 'OCFO') {
			ds [di++] = "Office of the Chief Financial Officer (OCFO)";
			}
			else if (node.m_label == 'CLA') {
			ds [di++] = "Office of Congressional and Legislative Affairs (CLA)";
			}
			else if (node.m_label == 'OFA') {
			ds [di++] = "Office of Federal Acknowledgment (OFA)";
			}
			else if (node.m_label == 'OHSEM') {
			ds [di++] = "Office of Homeland Security and Emergency Management (OHSEM)";
			}
			else if (node.m_label == 'IEED') {
			ds [di++] = "Office of Indian Energy and Economic Development (IEED)";
			}
			else if (node.m_label == 'OIG') {
			ds [di++] = "Office of Indian Gaming (OIG)";
			}
			else if (node.m_label == 'IEA') {
			ds [di++] = "Office of Internal Evaluation & Assessment (IEA)";
			}
			else if (node.m_label == 'OPPM') {
			ds [di++] = "Office of Planning & Performance Management (OPPM)";
			}
			else if (node.m_label == 'OPA') {
			ds [di++] = "Office of Public Affairs (OPA)";
			}
			else if (node.m_label == 'ORM') {
			ds [di++] = "Office of Regulatory Management (ORM)";
			}
			else if (node.m_label == 'OSG') {
			ds [di++] = "Office of Self-Governance (OSG)";
			}
		else {*/
		ds[di++] = node.m_label + ' node level is ' + node.m_level + ' m_subNodes.length is ' + node.m_subNodes.length + ' m_NavPath is ' + this.m_NavPath.length;
		//}

		ds[di++] = '</a></li></div>';
		//End of item in Loop
		
		//Uses the start point parameter, ignores everything before this parameter and starts generating the navigation list
		if (node.m_label == this.m_ShowNode)
			this.m_ShowFlag   = true;
	
		//Uses the end point parameter and stops creating the navigation list
		if (node.m_label == this.m_HideNode)
			this.m_ShowFlag   = false;	
		
		//Enter any items that you want excluded by adding the following:  && node.m_label != 'Item Label' 
		if (this.m_ShowFlag && node.m_label != 'Who We Are' && node.m_label != 'What We Do')	
			document.write(ds.join(''));

	}
}
	
	// expand sub-levels (if any)
	for (var i = 0; i < node.m_subNodes.length; i++)
	{	
		document.write(" i equals " + i);
		this.DisplayNode(node.m_subNodes[i]);
	}
}



