
var ID = 0;
function LeftNavMouseEvent(x,ArrowColor)
{
	var obj;
	eval("obj = LeftNavLinkImage"+x);
	obj.className = ArrowColor;
}
function LeftNavReturnArray(SiteName, SiteUrl,status, SubList)
{
	var subArray = new Array(3);
	subArray[0] = SiteName;
	subArray[1] = SiteUrl;
	subArray[2] = status;
	subArray[3] = SubList;
	return(subArray);
}
function BuildSubNav(sarrName,NavLevel,AboveDottedLine)
{
	var SideArrowImage, DownArrowImage,SideArrowImageDark,DownArrowImageDark;
	document.write("<div class=\"SubLevel\"><table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
	var LeftNavSubLevelLinks;
	var LeftNavCurrentCommunity;
	var i;
	if (AboveDottedLine)
	{
		SideArrowImage = "primary_dashAD";
		DownArrowImage = "primary_dashAD";
		SideArrowImageDark = "secondary_dashAD";
		DownArrowImageDark = "secondary_dashAD";
		LeftNavSubLevelLinks = "LeftNavSubLevelLinksAD";
		LeftNavCurrentCommunity = "LeftNavSubLevelCurrentCommunityAD";
	}
	else
	{
		SideArrowImage = "primary_dashBD";
		DownArrowImage = "primary_dashBD";
		SideArrowImageDark = "secondary_dashBD";
		DownArrowImageDark = "secondary_dashBD";
		LeftNavSubLevelLinks = "LeftNavSubLevelLinksBD";
		LeftNavCurrentCommunity = "LeftNavSubLevelCurrentCommunityBD";
	}
	for (i=0; i < sarrName.length;i++)
	{
	    // If active community is not displayed in left nav, then parent community should be active
	    
		if (activeCommunityPath.length > 0)
			if (sarrName[i][1] == activeCommunityPath)
			{
				sarrName[i][2] = "C";
			}
		
		if (sarrName[i][2] == "") // just display plain nav
		{
		
			document.write("<tr>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + SideArrowImage + "'></td>");
			document.write("<td valign=top>");
			document.write("<div class='" + LeftNavSubLevelLinks + "'><a onmouseover=\"LeftNavMouseEvent('" + ID + "','" + SideArrowImageDark + "')\" onmouseout=\"LeftNavMouseEvent('" + ID + "','" +SideArrowImage + "')\" href='" + sarrName[i][1] + "'>" + sarrName[i][0] + "</a></div>");
			document.write("</td>");			
			document.write("</tr>");
		}
		if (sarrName[i][2] == "C") // current community
		{
			document.write("<tr>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + DownArrowImageDark + "'></td>");
			document.write("<td valign=top >");
			document.write("<div class='" + LeftNavCurrentCommunity + "'><a href='" + sarrName[i][1] + "'>" + sarrName[i][0] + "</a></div>");
			if (sarrName[i][3].length > 0) // sub community exists
			{
				ID++;
				//document.write("<br>");
				BuildSubNav(sarrName[i][3],1,AboveDottedLine);
			}
			document.write("</td>");	
			document.write("</tr>");			
		}
		if (sarrName[i][2] == "S")
		{
			document.write("<tr class='LeftNavSubRow'>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + DownArrowImage + "'></td>");
			document.write("<td valign=top >");
			document.write("<div class='" + LeftNavSubLevelLinks + "'><a onmouseover=\"LeftNavMouseEvent('" + ID + "','" + DownArrowImageDark + "')\" onmouseout=\"LeftNavMouseEvent('" + ID + "','" + DownArrowImage + "')\" href='" + sarrName[i][1] + "'>" + sarrName[i][0] + "</a></div>");
			if (sarrName[i][3].length > 0) // sub community exists
			{
				ID++;
				//document.write("<br>");
				BuildSubNav(sarrName[i][3],1,AboveDottedLine);
			}
			document.write("</td>");	
			document.write("</tr>");			
		}
		ID++;
	}
	document.write("</table></div>");
}
function BuildNav(arrName,NavLevel,AboveDottedLine)
{
	var SideArrowImage, DownArrowImage,SideArrowImageDark,DownArrowImageDark;	
	document.write("<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">");
	var i;
	var LeftNavTopLevelLinks;
	var LeftNavCurrentCommunity;
	if (AboveDottedLine)
	{
		SideArrowImage = "sidearrow_for_leftnavAD";
		DownArrowImage = "downarrow_for_leftnavAD";
		SideArrowImageDark = "sidearrow_for_leftnav_darkAD";
		DownArrowImageDark = "downarrow_for_leftnav_darkAD";
		LeftNavTopLevelLinks = "LeftNavTopLevelLinksAD";
		LeftNavCurrentCommunity = "LeftNavCurrentCommunityAD";
	}
	else
	{
		SideArrowImage = "sidearrow_for_leftnavBD";
		DownArrowImage = "downarrow_for_leftnavBD";
		SideArrowImageDark = "sidearrow_for_leftnav_darkBD";
		DownArrowImageDark = "downarrow_for_leftnav_darkBD";
		LeftNavTopLevelLinks = "LeftNavTopLevelLinksBD";
		LeftNavCurrentCommunity = "LeftNavCurrentCommunityBD";
	}

	for (i=0; i < arrName.length;i++)
	{
		// If active community is not displayed in left nav, then parent community should be active
		
		if (activeCommunityPath.length > 0)
			if (arrName[i][1] == activeCommunityPath)
			{
				arrName[i][2] = "C";
			}
			
		if (arrName[i][2] == "") // just display plain nav
		{
			document.write("<tr  class='LeftNavTopRow'>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + SideArrowImage + "'></td>");
			document.write("<td  valign=top>");
			document.write("<div class='"+LeftNavTopLevelLinks+"'><a onmouseover=\"LeftNavMouseEvent('" + ID + "','" + SideArrowImageDark + "')\" onmouseout=\"LeftNavMouseEvent('" + ID + "','" +SideArrowImage + "')\" href='" + arrName[i][1] + "'>" + arrName[i][0] + "</a></div>");
			document.write("</td>");			
			document.write("</tr>");
		}
		if (arrName[i][2] == "C") // current community
		{
			document.write("<tr class='LeftNavTopRow'>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + DownArrowImageDark + "'></td>");
			document.write("<td valign=top >");
			document.write("<div class='"+LeftNavCurrentCommunity+"'><a href='" + arrName[i][1] + "'>" + arrName[i][0] + "</a></div>");

			if (arrName[i][3].length > 0) // sub community exists
			{
				ID++;
				//document.write("<br>");
				BuildSubNav(arrName[i][3],1,AboveDottedLine);
			}
			document.write("</td>");	
			document.write("</tr>");
		}
		if (arrName[i][2] == "S")
		{
			document.write("<tr class='LeftNavTopRow'>");
			document.write("<td id='LeftNavLinkImage" + ID + "' class='"  + DownArrowImage + "'></td>");
			document.write("<td valign=top >");
			document.write("<div class='"+LeftNavTopLevelLinks+"'><a onmouseover=\"LeftNavMouseEvent('" + ID + "','" + DownArrowImageDark + "')\" onmouseout=\"LeftNavMouseEvent('" + ID + "','" + DownArrowImage + "')\" href='" + arrName[i][1] + "'>" + arrName[i][0] + "</a></div>");
			if (arrName[i][3].length > 0) // sub community exists
			{
				ID++;
				//document.write("<br>");
				BuildSubNav(arrName[i][3],1,AboveDottedLine);
			}
			document.write("</td>");	
			document.write("</tr>");			
		}
		ID++;
	}
	document.write("</table>");
}
function GenerateLeftNavigation()
{
	document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0' >");
	document.write("<tr height='1px'>");
	document.write("<td class='LeftNavigationHeaderBorder'></td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td class='LeftNavHeader'>" + LeftNavigationHeader );
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr height='1px'>");
	document.write("<td class='LeftNavigationHeaderBorder'></td>");
	document.write("</tr>");

	document.write("<tr><td><div id='LeftNavLinksAboveDottedLine'>");
	BuildNav(LeftTopNav,0,true);
	document.write("</div></td></tr>");
	if (LeftBottomNav.length > 0)
	{
		document.write("<tr><td width=100%><table border=0 cellspacing=0 cellpadding=0><tr><td width=155px class='LeftNavigationSeparator'></td><td width=10px></td></table></td></tr>");
		document.write("<tr><td><div id='LeftNavLinksBelowDottedLine'>");
		BuildNav(LeftBottomNav,0,false);
		document.write("</div></td></tr>");	
	}
	document.write("</table>");
}
