/////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2007, 2008, Oracle. All rights reserved.
// Function : breadcrumb
// Comments : Creating a breadcrumb like this:
// <a href="#"><span>Home </span></a> <span class="active"> What We Do</span>
/////////////////////////////////////////////////////////////////////////////

function breadcrumb()
{
	this.m_NavPath    = g_navNode_Path;

	breadcrumb.prototype.Display = breadcrumb_Display;
	breadcrumb.prototype.DisplayNode = breadcrumb_DisplayNode;
}

function breadcrumb_Display (node)
{
	this.DisplayNode(node);
}

function breadcrumb_DisplayNode(node)	
{
	var bExpand = false;
	var lastone = false;
	var ds = new Array();
	var di = 0;
	
	if (this.m_NavPath.length > 0 && node.m_level < this.m_NavPath.length)
	{
		if (this.m_NavPath[node.m_level] == node.m_id)
			bExpand = true;
                if (node.m_level + 1 == this.m_NavPath.length)
			lastone = true;
	}
	
	if (bExpand)
	{
		if (lastone) 
                {
		   ds[di++] = '<span class=active>';
		   ds[di++] = node.m_label;
		   ds[di++] = ' </span>';
		}
		else
		{
 		   ds[di++] = '<a href="' + node.m_href + '"' + '>';
		   ds[di++] = '<span>';
		   ds[di++] = node.m_label;
		   ds[di++] = ' </span>';
		   ds[di++] = '</a>';
		}
		
		document.write(ds.join(' '));	// Write out the "live" path only
	
		// expand sub-levels (if any)
		for (var i = 0; i < node.m_subNodes.length; i++)
		{
			this.DisplayNode(node.m_subNodes[i]);
		}
	}
}
