<%@ Reference VirtualPath="~/bitrix/components/bitrix/system.PublicMenu/component.ascx" %>
<%@ Control Language="C#" ClassName="template" Inherits="Bitrix.Main.Components.SystemPublicMenuTemplate" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Bitrix" %>
<script runat="server">
	IEnumerable<BXPublicMenuItem> EnumerateItems(BXPublicMenuItemCollection items)
	{
		foreach (BXPublicMenuItem item in items)
		{
			yield return item;
			if (item.Children != null && item.Children.Count != 0)
				foreach (BXPublicMenuItem child in item.Children)
					yield return child;
		}
	}
	
	public override string Title
	{
		get
		{
			return "Portal template (secondary menu)";
		}
	}
</script>

<%
	if (Component.Menu == null || Component.Menu.Count == 0)
		return;
%>
<div class="left-menu">
	<% bool first = true; %>
	<% foreach(BXPublicMenuItem item in EnumerateItems(Component.Menu)) { %>
		<% if (item.IsAccessible && item.Parent == null) { %>
			<% if (!first) { %><div class="separator"></div><% } else { first = false; } %>
			<div<% if (item.Children != null && item.Children.Count != 0) { %> class="directory"<% } %>>
			<a href="<%= Encode(item.Href) %>"<% if (item.IsSelected) { %> class="selected"<% } %>><%= Encode(item.Title) %></a>
			</div>
		<% } %>
	<% } %>
</div>