${scripts.add('<script type="text/javascript" src="${urls.base}/themes/iph/js/collapsible_elements.js"></script>')}
${scripts.add('<script async type="text/javascript" src="${urls.base}/themes/iph/js/print.js"></script>')}

<#list rubrics as rubric>
  <#if !rubric.parentUri??>
    <#assign childs = rubric.childs?number>
    <button type="button" style="border:none;padding: 15px;text-align:left; width:100%;" class="collapsible">
      <@openButton childs=childs/><a style="padding-left:15px;">${rubric.name}</a>
      <div id="rubricFollow">
      	<a href="individual?uri=${rubric.uri?url}">перейти в рубрику</a>
      </div>
     </button>
    <div class="rubricContents" style="display:none;">
    <#if (childs &gt; 0) >
      <@nestedRubrics allrubrics=rubrics parentUri=rubric.uri deep=10 level=1 /> 
    </#if>
    </div>
	
  </#if>
</#list>


<#macro openButton childs>
  <#if childs &gt; 0>
    <div class="collapsibleSign" style="display:inline-block;width:10px;">+</div>
  <#else> 
    <div style="display:inline-block;width:10px;"></div>
  </#if>
</#macro>

<#macro nestedRubrics allrubrics parentUri deep level>
  <#assign count = 0>
  <#list allrubrics as innerRubric>
	<#if innerRubric.parentUri?? && innerRubric.parentUri == parentUri>
      <#assign childs = innerRubric.childs?number>
      <#assign count = count + 1 >
      <button type="button" style="border:none;padding: 15px 0px 15px ${15+15*level}px;width: 100%; text-align:left;" class="collapsible"><@openButton childs=childs /><a style="padding-left:15px;">${innerRubric.name}</a>
      <div id="rubricFollow">
      <a href="individual?uri=${innerRubric.uri?url}">перейти в рубрику</a>
      </div>
       </button>
      <div class="rubricContents" style="display:none;">
       <#if (deep &gt; 1) && (childs &gt; 0)>
	     <@nestedRubrics allrubrics=rubrics parentUri=innerRubric.uri deep=deep-1 level=level+1 /> 
       </#if>
      </div>
    </#if>
    <#if count = childs >
      <#break>
    </#if>
  </#list>
</#macro>
