/////////////////////////////////////////////////////////////////////////////
// Function : NewNavTabsTop
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function NewNavTabsTop(strTextColor, strHoverColor, strFocusColor, strClassName, strShowHome, strShowNext)
{
	this.m_TextColor  = '';
	this.m_HoverColor = '';
	this.m_FocusColor = '';
	this.m_ClassName  = 'NewNavTabsTop';
	this.m_ShowHome   = false;
	this.m_ShowNext   = false;

	this.m_NavPath    = g_navNode_Path;
	
	NewNavTabsTop.prototype.Display = NewNavTabsTop_Display;
	NewNavTabsTop.prototype.DisplayNextLevel = NewNavTabsTop_DisplayNextLevel;			
	
	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 (strShowHome == 'true')
		this.m_ShowHome = true;

	if (strShowNext == 'true')
		this.m_ShowNext = true;

	this.strFrontFirstImageOFF = ssAssetsPath + "unselected_tab_front_first.gif";
	this.strFrontImageOFF      = ssAssetsPath + "unselected_tab_front.gif";
	this.strMiddleImageOFF     = ssAssetsPath + "unselected_tab_middle.gif";
	this.strBackLastImageOFF   = ssAssetsPath + "unselected_tab_back_last.gif";
	this.strBackImageOFF       = ssAssetsPath + "unselected_tab_back.gif";
	this.strFrontFirstImageON  = ssAssetsPath + "selected_tab_front_first.gif";
	this.strFrontImageON       = ssAssetsPath + "selected_tab_front.gif";
	this.strMiddleImageON      = ssAssetsPath + "selected_tab_middle.gif";
	this.strBackLastImageON    = ssAssetsPath + "selected_tab_back_last.gif";
	this.strBackImageON        = ssAssetsPath + "selected_tab_back.gif";
	
	this.m_ds = new Array();
	this.m_di = 0;
}

function NewNavTabsTop_Display (node)	
{
	var bSelected = false;
	var nodeColor = this.m_TextColor;
	var nodeClass = this.m_ClassName;
		
	var count =  this.m_ShowHome ? -1 : 0;
	
	var href = '';
	var label = '';
	
//	this.m_ds[this.m_di++] = '<table cellspacing="0" cellpadding="0" border="0">'
//	this.m_ds[this.m_di++] = '<tr>';
	this.m_ds[this.m_di++] = '<ul>';
	
	var selectedNode = null;

	// do the genuine top level nodes
		
	for (; count < node.m_subNodes.length; count++)
	{
		bSelected = false;
		nodeColor = this.m_TextColor;
		nodeClass = this.m_ClassName;
		
		if (count == -1)	// Root link
		{
			if ( (this.m_NavPath.length == node.m_level+1) &&
				 (this.m_NavPath[node.m_level] == node.m_id) )
			{
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '-focus';
			}
			
			label = node.m_label;
			href  = node.m_href;
		}		
		else
		{
			if (this.m_NavPath.length >= node.m_subNodes[count].m_level)
			{
				if (this.m_NavPath[node.m_subNodes[count].m_level] == node.m_subNodes[count].m_id)
				{
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '-focus';					
					selectedNode = node.m_subNodes[count];
				}
			}
			label = node.m_subNodes[count].m_label;
			href = node.m_subNodes[count].m_href;
		}
		 
		// Start the tab with an image...

//		this.m_ds[this.m_di++] = '<td><img src="';
		this.m_ds[this.m_di++] = '<li';
		
		if (bSelected)
		{
			this.m_ds[this.m_di++] = ' style="background: url(../../groups/public/documents/web_asset/000052.gif) no-repeat right top;"';
		}
		
		this.m_ds[this.m_di++] = '>';

//		if (count == 0)		
//			this.m_ds[this.m_di++] = bSelected ? this.strFrontFirstImageON : this.strFrontFirstImageOFF;
//		else		
//			this.m_ds[this.m_di++] = bSelected ? this.strFrontImageON : this.strFrontImageOFF;
//			
//		this.m_ds[this.m_di++] = '"></img></td>';
//
//		// Draw/render the middle/body of the tab
//		
//		this.m_ds[this.m_di++] = '<td nowrap style="background:url(';
//		this.m_ds[this.m_di++] = bSelected ? this.strMiddleImageON : this.strMiddleImageOFF;
//		this.m_ds[this.m_di++] = ')">';

		this.m_ds[this.m_di++] = '<a href="' + href + '"';
		
		if (bSelected)
		{
			this.m_ds[this.m_di++] = ' style="background: url(../../groups/public/documents/web_asset/000053.gif) no-repeat left top; padding-bottom: 3px; color: #039;"';
		}
		
		if (nodeColor != '')
		{
			this.m_ds[this.m_di++] = ' style="color: ' + nodeColor + ';"';
			
			if (!bSelected && this.m_HoverColor != '')
			{
				this.m_ds[this.m_di++] = ' onmouseover="this.style.color=\'' + this.m_HoverColor + '\'"';
				this.m_ds[this.m_di++] = ' onmouseout="this.style.color=\'' + nodeColor + '\'"';
			}
		}
		this.m_ds[this.m_di++] = '>';
		this.m_ds[this.m_di++] = label;
		this.m_ds[this.m_di++] = '</a>';

//		this.m_ds[this.m_di++] = '</td>';
		this.m_ds[this.m_di++] = '</li>';

		// Close the tab with an image...

//		this.m_ds[this.m_di++] = '<td><img src="';
//
//		if (count == node.m_subNodes.length - 1)
//			this.m_ds[this.m_di++] = bSelected ? this.strBackLastImageON : this.strBackLastImageOFF;
//		else		
//			this.m_ds[this.m_di++] = bSelected ? this.strBackImageON : this.strBackImageOFF;
//			
//		this.m_ds[this.m_di++] = '"></img></td>';
	}

	this.m_ds[this.m_di++] = '</ul>';
	
	if (this.m_ShowNext)
	{	
		this.m_ds[this.m_di++] = '<tr><td nowrap';
		this.m_ds[this.m_di++] = ' style="background:url(';
		
		if (selectedNode != null)		
			this.m_ds[this.m_di++] = this.strMiddleImageON;
		else
			this.m_ds[this.m_di++] = this.strMiddleImageOFF;		
		
		this.m_ds[this.m_di++] = ')"';
		this.m_ds[this.m_di++] = ' colspan="';
		
		var tabs = node.m_subNodes.length + (this.m_ShowHome ? 1 : 0);
			
		this.m_ds[this.m_di++] = 3 * tabs;	// span three cells per tab...
		this.m_ds[this.m_di++] = '">';
	
		if (selectedNode != null)
			this.DisplayNextLevel (selectedNode);

		this.m_ds[this.m_di++] = '&nbsp;';
		this.m_ds[this.m_di++] = '</td></tr>';
	}
	
	this.m_ds[this.m_di++] = '</table>';
	
	document.write(this.m_ds.join(''));		
}

function NewNavTabsTop_DisplayNextLevel (node)	
{
	// if we have a selected top level node, then display the children of that node

	var bSelected = false;
	var nodeColor = this.m_TextColor;
	var nodeClass = this.m_ClassName;
		
	var count = 0;
	for (count=0; count < node.m_subNodes.length; count++)
	{
		bSelected = false;
		nodeColor = this.m_TextColor;
		nodeClass = this.m_ClassName;		
		
		if (this.m_NavPath.length >= node.m_subNodes[count].m_level)
		{
			if (this.m_NavPath[node.m_subNodes[count].m_level] == node.m_subNodes[count].m_id)
			{
				bSelected = true;
				nodeColor = this.m_FocusColor;
				nodeClass += '-focus';
			}
		}

		if (node.m_level > 0)
			nodeClass += '-' + node.m_level;

		if (count == 0)
		{
			this.m_ds[this.m_di++] = "&nbsp;";
		}

		this.m_ds[this.m_di++] = '<a href="' + node.m_subNodes[count].m_href + '"';
		this.m_ds[this.m_di++] = ' class="' + nodeClass + '"';
		
		if (nodeColor != '')
		{
			this.m_ds[this.m_di++] = ' style="color: ' + nodeColor + ';"';
			
			if (!bSelected && this.m_HoverColor != '')
			{
				this.m_ds[this.m_di++] = ' onmouseover="this.style.color=\'' + this.m_HoverColor + '\'"';
				this.m_ds[this.m_di++] = ' onmouseout="this.style.color=\'' + nodeColor + '\'"';
			}
		}
		
		this.m_ds[this.m_di++] = '>';
		this.m_ds[this.m_di++] = node.m_subNodes[count].m_label;
		this.m_ds[this.m_di++] = '</a>';

		if (count < node.m_subNodes.length - 1)
		{
			this.m_ds[this.m_di++] = '&nbsp;';
			this.m_ds[this.m_di++] = this.separator;
			this.m_ds[this.m_di++] = '&nbsp;';
		}
		else
		{
			this.m_ds[this.m_di++] = '&nbsp;';
		}
	}
}



