//Global Variable to indicate that a node that requires a link to be written out
//has been found in the NavPath.
backToSectionFound = false;

/////////////////////////////////////////////////////////////////////////////
// Function : DisplayNav
// Comments : 
/////////////////////////////////////////////////////////////////////////////
 function backToSection(node)
{
	//DEBUG CODE
	/*document.write ('Current node.m_level=' + node.m_level + '<br>');
	document.write ('Current node.m_id=' + node.m_id + '<br>');
	document.write ('Current node.m_label=' + node.m_label + '<br>');
	document.write ('Current node.m_Subnode Count=' + node.m_subNodes.length + '<br>');
	document.write ('Current g_navNode_Path[node.m_level]= ' + g_navNode_Path[node.m_level] + '<br>');
	document.write ('Current node.m_id= ' + node.m_id + '<br>');	
	document.write ('g_navNode_Path[node.m_level] == node.m_id= ' + (g_navNode_Path[node.m_level] == node.m_id) + '<br><br>');	
	*/
	
		
	//This if statement checks to see if the current node is in the navPath of the page that
	//is being displayed.  Without this if statement the entire javascript navigation tree will
	//be traversed.  node.m_level corresponds to the array index for g_navNode.
	if (g_navNode_Path[node.m_level] == node.m_id)
	{
		//Check if current node matches a node that requires a link to be written out.
		if (node.m_label == "All Medical Services" )
		{
		   document.write ('<A href="javascript:nodelink(' + node.m_id + ')">All Medical Services</A>');		   
		   backToSectionFound = true;
		   return true;
		}

		else if (node.m_label.substr(0,21) == "Todos los servicios m")
		{
		   document.write ('<A href="javascript:nodelink(' + node.m_id + ')">Todos los Servicios Médicos</A>');
		   backToSectionFound = true;
		   return true;
		}

		else if (node.m_label == "Community Programs")
		{
		   document.write ('<A href="javascript:nodelink(' + node.m_id + ')">All Community Programs</A>');
		   backToSectionFound = true;
		   return true;
		}

		else if (node.m_label == "Programas comunitarios")
		{
		   document.write ('<A href="javascript:nodelink(' + node.m_id + ')">Todos los Programas Comunitarios</A>');
		   backToSectionFound = true;
		   return true;
		}

		//Current node did not match, check all subnodes of the current node.
		else
		{
			for(var i = 0; i < node.m_subNodes.length; i++)
			{
				if(backToSectionFound == true)
				{
					break;
				}
				
				//Recursive call to this function passing in a subnode to walk down the
				//navigation tree.				
				backToSection(node.m_subNodes[i]);
			}
		}
		
	}

}


