@require(root, doc_tree)

@def format_level(page, parent_name, level):
@(
name = parent_name + '-' + str(level)
actual_level = name.count('-')
if actual_level % 2 == 0:
	sidenav_panel_extra_class = "sidenav-panel-even"
else:
	sidenav_panel_extra_class = "sidenav-panel-odd"
)

<div class="sidenav-panel-body @sidenav_panel_extra_class">
	<div class="panel-heading">  
		<h4 class="panel-title">
			<a class="sidenav-ref" href="@page.link.get_link()" data-extension="@str(page.extension_name)">@page.get_title()</a>
			@if page.subpages:
			<a class="sidenav-toggle" data-toggle="collapse" data-parent="#@parent_name" href="#@name-children" aria-expanded="false">
				<i class="glyphicon glyphicon-chevron-right pull-right"></i>
				<i class="glyphicon glyphicon-chevron-down pull-right"></i>
			</a>
			@end
		</h4> 
	</div>
	<div id="@name-children" class="panel-collapse collapse" data-nav-ref="@page.link.get_link()">
		@(
		level = 0
		)
		@for cpage in page.subpages:
		@format_level(doc_tree.pages[cpage], name, level)
		@(level += 1)
		@end
	</div>
</div>
@end

@format_level(root, "main", 0)
