<metal:block define-macro="portlet">
<tal:block define="skin_files_path python:here.getLayoutTool().getSkinFilesPath();
                   site_id python:here.getSite().getId();
				   maintopics_settings python: getattr(here.getSite(), 'maintopics_settings', {});
				   maintopics_settings_json python: here.rstk['json_dumps'](maintopics_settings);">
<metal:block define-slot="scripts">
	<script tal:attributes="src string:/misc_/Naaya/jquery.cookie.js"></script>
	<script tal:attributes="src string:/misc_/Naaya/mainsections.js"></script>
</metal:block>
<script type="text/javascript" tal:content="string:
	var img_collapse = '++resource++Products.Naaya/ep_collapse.gif';
	var img_expand = '++resource++Products.Naaya/ep_expand.gif';
	var mainsections_cookie = '${site_id}-mainsections';
	var maintopics_settings = ${maintopics_settings_json};"></script>

<tal:block tal:repeat="fold folders|here/getMainTopics">
        <tal:block metal:use-macro="options/macro">
		<tal:block metal:fill-slot="portlet_title">
			<div tal:define="additional_classes python:
			(here.rstk['is_descendant_of'](here, fold) and ' active ' or '') +
			(len(fold.getPublishedFolders()) and ' expandable ' or '') +
			(maintopics_settings['expanded'] and ' expanded' or '')"
			tal:attributes="class string:mainsection_title ${additional_classes};
			id string:${fold/id}-${repeat/fold/index}">
				<a tal:attributes="href fold/absolute_url;
				   class string:mainsection_link${additional_classes}"
				   tal:content="fold/title_or_id" />
			</div>
		</tal:block>
		<tal:block metal:fill-slot="portlet_content" tal:define="level python:1;">
			<metal:block define-macro="recurse">
				<ul class="mainsection_content"
					tal:condition="fold/getPublishedFolders"
					tal:attributes="id string:ul${fold/id};">
					<tal:block repeat="sub_fold fold/getPublishedFolders">
						<li tal:define="additional_classes python: (here.rstk['is_descendant_of'](here, sub_fold) and 'active' or '') +
							(len(sub_fold.getPublishedFolders()) and ' expandable ' or '') +
							(maintopics_settings['expand_levels'] >= level+1 and ' expanded' or '')"
							tal:attributes="class string:mainsection_item ${additional_classes};
							id string:${sub_fold/id}-${repeat/fold/index}-${repeat/sub_fold/index}">
							<a tal:attributes="href sub_fold/absolute_url;
							   class string:mainsection_item mainsection_nav_link ${additional_classes}"
							   tal:content="sub_fold/title_or_id" />
							<tal:block define="fold sub_fold; level python: level+1">
								<tal:block condition="python: maintopics_settings['max_levels'] >= level">
									<metal:block use-macro="python: here.getSite().getPortletsTool().getPortletMacro('portlet_maincategories', 'recurse')"></metal:block>
								</tal:block>
							</tal:block>
						</li>
					</tal:block>
				</ul>
			</metal:block>
		</tal:block>
	</tal:block>
</tal:block>
</tal:block>
</metal:block>
