/////////////////////////////////////////////////////////////////////////////
// Function : vrsnNavMenuElements
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function vrsnNavMenuElements(strTextColor, strHoverColor, strFocusColor, strClassName, 
							strShowHome, strStartLevel, strNumLevels)
{
	this.m_TextColor  = '';
	this.m_HoverColor = '';
	this.m_FocusColor = '';
	this.m_ClassName  = 'vrsnNavMenuElements';
	
	this.m_ShowHome   = false;
	
	this.m_StartLevel = 2;
	this.m_NumLevels  = 10;
	this.m_EndLevel   = 11;

	this.m_NavPath    = g_navNode_Path;

	vrsnNavMenuElements.prototype.Display = vrsnNavMenuElements_Display;
	vrsnNavMenuElements.prototype.DisplayNode = vrsnNavMenuElements_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 (strShowHome == 'true')
		this.m_ShowHome = true;
		
	if (strStartLevel != '')
	{
		var value = parseInt(strStartLevel);
		if (value != NaN)
			this.m_StartLevel = value;
	}
	
	if (strNumLevels != '')
	{
		var value = parseInt(strNumLevels);
		if (value != NaN)
			this.m_NumLevels = value;
	}

	this.m_EndLevel = this.m_StartLevel + this.m_NumLevels - 1 ;
}

function vrsnNavMenuElements_Display (node)
{
	document.write('<ul style="list-style-type: none;">');
	this.DisplayNode(node);
	document.write('<li class="vrsnNavMenuElements-bottom"></li>');
	document.write('</ul>');
}

function vrsnNavMenuElements_DisplayNode(node)
{
//var str="";
//for(var prop in node)
//{
//	str+=prop + " value :"+ node[prop]+"\n";
//}
//alert(str);
	var bSelected = false;
	var nodeColor = this.m_TextColor;
	var nodeClass = this.m_ClassName

	var nodeLevel = node.m_level;

	if (nodeLevel > 6)
		nodeLevel = 6;
	if (this.m_NavPath.length > 0 && node.m_level < this.m_NavPath.length)
	{
		if (this.m_NavPath[node.m_level] == node.m_id)
		{
			// Added by Steve R.
			// Condition to ensure that only the current node is given a numbered style
			// and not the current plus parent node.
			if (node.m_level == 1){
				bSelected = true;
				nodeColor = this.m_FocusColor;
				nodeClass += '-focus';
			}
			//alert("NAV ARRAY: " + this.m_NavPath + "\n" +
			//	  "NODE ID: " + node.m_id + "\n" +
			//	  "NODE LEVEL: " + node.m_level + "\n" +
			//	  "NAV ARRAY LENGTH: " + this.m_NavPath.length + "\n"
			//	  );
			if (this.m_NavPath.length == 5) {
				if (this.m_NavPath[this.m_NavPath.length-2] == node.m_id) {
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '-focus';
				} else {
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '';					
				}
			} else if (this.m_NavPath.length == 4) {
				if (node.m_level == 2) {
					if (this.m_NavPath[this.m_NavPath.length-1] == node.m_id) {
						bSelected = true;
						nodeColor = this.m_FocusColor;
						nodeClass += '-focus';
					} else {
						bSelected = true;
						nodeColor = this.m_FocusColor;
						nodeClass += '';
					}
				} else if (node.m_level == 3) {
					if (this.m_NavPath[this.m_NavPath.length-1] == node.m_id) {
						bSelected = true;
						nodeColor = this.m_FocusColor;
						nodeClass += '-focus';
					} else {
						bSelected = true;
						nodeColor = this.m_FocusColor;
						nodeClass += '';
					}
				}
			} else if (this.m_NavPath.length == 3) {
				if (this.m_NavPath[this.m_NavPath.length-1] == node.m_id) {
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '-focus';
				} else {
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '';
				}
			} else if (this.m_NavPath.length == 2) {
				if (this.m_NavPath[this.m_NavPath.length-1] == node.m_id) {
					bSelected = true;
					nodeColor = this.m_FocusColor;
					nodeClass += '';
				}
			} else {
				bSelected = true;
				nodeColor = this.m_FocusColor;
				nodeClass += '';
			}
		}
	}

	if (nodeLevel > 0)
		nodeClass += '-' + nodeLevel;
	if ( (node.m_level == 0 && this.m_ShowHome) || (node.m_level >= this.m_StartLevel && node.m_level <= this.m_EndLevel))
	{
		var ds = new Array();
		var di = 0;
	
		ds[di++] = (nodeLevel <= 2) ? '<li' : '<li';
		ds[di++] = ' class="' + nodeClass + '"';
		ds[di++] = '>';

		ds[di++] = '<a href="' + node.m_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++] = node.m_label;
		ds[di++] = '</a>';
		document.write(ds.join(''));
	}
	
	if (bSelected || node.m_level == 0)
	{	// expand sub-levels (if any)
		for (var i = 0; i < node.m_subNodes.length; i++)
		{
			this.DisplayNode(node.m_subNodes[i]);
		}
	}
}
