{function sectionsRespTree}
   {foreach $sectionList as $item}
      {if $item.flags['HL']}{continue}{/if}
      {if !$hide_virtual or $item.virtual != "Y"}
         <li class="nav-item nav-item-{$item.id}" data-level="{$item.level}">
            {if $item.submenu}
               <span class="toggle-sub">{$item.title_short}</span>
               <ul class="sub-nav">
                  <li class="sub-heading toggle-back">{t}Zpět{/t}</li>

                  <li class="sub-heading nav-item nav-item-{$item.id}">
                     <a href="{url s=category IDcat=$item.id}">
                        {t}Vše v kategorii{/t} {$item.title_short}
                     </a>
                  </li>

                  {sectionsRespTree sectionList=$item.submenu}
               </ul>
            {else}
               <a href="{url s=category IDcat=$item.id}">
                  {$item.title_short}
               </a>
            {/if}
         </li>
      {/if}
      {* TODO: FORLOOP_INCLUDE *}{$tmp=$item@last}
      {block "respsections-navitem-append"}
      {/block}
   {/foreach}
{/function}

{if not $fromCache}
   {block "tpl_vars"}{/block}
   {sectionsRespTree sectionList=$categories}
{else}
   {if $selection}
      <script>
         wpj.onReady.push(function() {
            var hasChildSelection = false;
            {foreach $selection as $item}
            {if $item@last}
            var $currentItem = $("[data-sections-responsive] .nav-item-{$item}");

            if ($currentItem.closest('.sub-nav').length) {
               hasChildSelection = true;
            }

            $currentItem.addClass('active');

            if (!$currentItem.children('ul').length) {
               $currentItem.closest(".active-parent").removeClass("active-parent").addClass("active");
            }
            {else}
            $("[data-sections-responsive] .nav-item-{$item}").addClass("active-parent");
            {/if}
            {/foreach}

            if (hasChildSelection) {
               $("[data-sections-responsive]").addClass("has-child-selection");
            } else {
               $("[data-sections-responsive]").removeClass("has-child-selection");
            }
         });
      </script>
   {/if}
{/if}
