{*<!--

+---------------------------------------------------------------------------+
| Revive Adserver                                                           |
| http://www.revive-adserver.com                                            |
|                                                                           |
| Copyright: See the COPYRIGHT.txt file.                                    |
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+

-->*}

{if $headerModel && $headerModel->getTitle() != ''}
    {assign var=breadcrumbs value=$headerModel->getEntityBreadcrumbs()}
    {assign var=breadcrumbCount value=$breadcrumbs|@count}

    <div class="breadcrumb {if $headerModel->getIconClass()}hasIcon {$headerModel->getIconClass()}{/if}">
        <h3 {if $breadcrumbCount == 0}class="noBreadcrumb"{/if}>
            <span class='label'>{$headerModel->getTitle()}</span>{if $headerModel->getPageType() == "edit"}:{/if}
            {$headerModel->getEntityName()|escape}
            {if $headerModel->getNewTargetName()}
                <span class='target'>
                    {$headerModel->getNewTargetTitle()}
                    {if $headerModel->getNewTargetLink()}<a href="{$headerModel->getNewTargetLink()}" title="{$headerModel->getNewTargetName()|escape}">{/if}
                    {$headerModel->getNewTargetName()|escape}
                    {if $headerModel->getNewTargetLink()}</a>{/if}
                </span>
            {/if}
        </h3>

        {if !$hideNavigator && $headerModel->hasEntityList()}
        <div class='dropDown entityList'>
            <span>
                <span>
                    <ul>
                    {section name=breadcrumbIndex loop=$breadcrumbs}
                        <li class="ent inlineIcon {$breadcrumbs[breadcrumbIndex]->getCssClass()}">{$breadcrumbs[breadcrumbIndex]->getEntityLabel()}: {$breadcrumbs[breadcrumbIndex]->getEntityName()|escape}</li>
                        {if $smarty.section.breadcrumbIndex.index lt $breadcrumbCount - 1}
                        <li class='sep'>&gt;</li>
                        {/if}
                    {/section}
                    </ul>
                </span>
            </span>
            <div class='panel'><div></div></div>
            <div class='mask'></div>
        </div>

        <script type='text/javascript'>{literal}
        <!--

          var entityList = [
            {/literal}{section name=breadcrumbIndex loop=$breadcrumbs}{literal}
              {
                'label': '{/literal}{$breadcrumbs[breadcrumbIndex]->getEntityLabel()}{literal}',
                'name': '{/literal}{$breadcrumbs[breadcrumbIndex]->getHtmlName()}{literal}',
                'className': '{/literal}{$breadcrumbs[breadcrumbIndex]->getCssClass()}{literal}',
                'id': '{/literal}{$breadcrumbs[breadcrumbIndex]->getEntityId()}{literal}'
              }{/literal}{if $smarty.section.breadcrumbIndex.index lt $breadcrumbCount - 1},{/if}{literal}
            {/literal}{/section}{literal}
          ];


          var itemTree = {};

          {/literal}
              {section name=breadcrumbIndex loop=$breadcrumbs}
              {assign var=idx value=0}
          {literal}

          itemTree{/literal}{$smarty.capture.ids}{literal} = {
                  {/literal}{foreach name=items from=$breadcrumbs[breadcrumbIndex]->getEntityMap() key=itemId item=aEntity}{literal}
              			{/literal}{$itemId}{literal}:     {
                      'name': '{/literal}{$aEntity.name|escape:javascript}{literal}', 'idx': '{/literal}{$idx++}{literal}'
                    }{/literal}{if $smarty.foreach.items.last eq false},{/if}{literal}
                  {/literal}{/foreach}{literal}
          };

          {/literal}
              {capture name=ids}{if $smarty.capture.ids}{$smarty.capture.ids}{/if}[{$breadcrumbs[breadcrumbIndex]->getEntityId()}]['items']{/capture}
              {/section}
          {literal}


          $('.entityList').activateNavigator(entityList, itemTree);


        //-->
        {/literal}</script>
        {else}
            {if $breadcrumbs|@count > 0}
            <span class="entityLinks">
            {section name=breadcrumbIndex loop=$breadcrumbs}
                {if $breadcrumbs[breadcrumbIndex]->getUrl()}
                    <a href="{$breadcrumbs[breadcrumbIndex]->getUrl()}" class="ent inlineIcon {$breadcrumbs[breadcrumbIndex]->getCssClass()}">{$breadcrumbs[breadcrumbIndex]->getEntityLabel()}: {$breadcrumbs[breadcrumbIndex]->getEntityName()|escape}</a>
                {else}
                    <span class="ent inlineIcon {$breadcrumbs[breadcrumbIndex]->getCssClass()}">{$breadcrumbs[breadcrumbIndex]->getEntityLabel()}: {$breadcrumbs[breadcrumbIndex]->getEntityName()|escape}</span>
                {/if}

                {if $smarty.section.breadcrumbIndex.index lt $breadcrumbCount - 1}
                    <span class='sep'>&gt;</span>
                {/if}
            {/section}
            </span>
            {/if}
        {/if}
    </div>
{/if}

