/////////////////////////////////////////////////////////////////////////////
// Function : Q_Tariffs_BreadCrumb
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function Q_Tariffs_BreadCrumb(strTextColor, strFocusColor, strHoverColor, strSeparator, strClassName, strShowHome)
{
	this.m_TextColor  = '';
	this.m_HoverColor = '';
	this.m_FocusColor = '';
	this.m_Separator  = '|';
	this.m_ClassName  = 'Q_Tariffs_BreadCrumb';
	
	this.m_ShowHome   = false;
	this.m_NavPath    = g_navNode_Path;
			
	Q_Tariffs_BreadCrumb.prototype.Display = Q_Tariffs_BreadCrumb_Display;
		
	if (strTextColor != '')
		this.m_TextColor = strTextColor;
		
	if (strHoverColor != '')
		this.m_HoverColor = strHoverColor;

	if (strFocusColor != '')
		this.m_FocusColor = strFocusColor;

	if (strSeparator != '')
		this.m_Separator = strSeparator;

	if (strClassName != '')
		this.m_ClassName = strClassName;

	if (strShowHome == 'true')
		this.m_ShowHome = true;
}

function Q_Tariffs_BreadCrumb_Display (node)	
{
	var bSelected = false;
	var nodeColor = this.m_TextColor;
	var nodeClass = this.m_ClassName;
		
	var ds = new Array();
	var di = 0;
	var count =  this.m_ShowHome ? -1 : 0;

	var href = '';
	var label = '';
	
	ds[di++] = '<span';
	
	if ( this.m_ClassName != '')
		ds[di++] = ' class="' + this.m_ClassName + '"';

	if (this.m_TextColor != '')
		ds[di++] = ' style="color: ' + this.m_TextColor + ';"';
		
	ds[di++] = '>'; 
	
//	ds[di++] = '&nbsp;';
		
	for ( ; count < node.m_subNodes.length; count++)
	{
		bSelected = false;
		
		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;
			}
			
			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;
				}
			}
			
			label = node.m_subNodes[count].m_label;
			href = node.m_subNodes[count].m_href;
		}
		
		if (bSelected)
		{
			nodeColor = this.m_FocusColor;
			nodeClass = this.m_ClassName + '-focus';
		}
		else
		{
			nodeColor = this.m_TextColor;
			nodeClass = this.m_ClassName;
		}
				
		ds[di++] = '<a href="' + href + '"';
		ds[di++] = ' class="' + nodeClass + '"';
		
		if (nodeColor != '')	
		{
			ds[di++] = ' style="color:' + nodeColor + ';"';

			if (!bSelected && this.m_HoverColor != '')
			{
				ds[di++] = ' onmouseover="this.style.color=\'' + this.m_HoverColor + '\'"';
				ds[di++] = ' onmouseout="this.style.color=\'' + nodeColor + '\'"';
			}
		}
		
		ds[di++] = '>';
		ds[di++] = label;
		ds[di++] = '</a>';

		if (count < node.m_subNodes.length - 1)
		{
			ds[di++] = '&nbsp;';
			ds[di++] = this.m_Separator;
			ds[di++] = '&nbsp;';
		}
		else
		{
			ds[di++] = '&nbsp;';
		}
	} 

	ds[di++] = '</span>';
	
	document.write(ds.join(''));
}
