{* Calculate title from path *}
{capture name="title"}
   {if count($path) > 1} - {/if}
   {foreach from=$path item=ctg name=path}
      {if $smarty.foreach.path.iteration gt 2}
         &gt;
      {/if}
      {if not $smarty.foreach.path.first}
         {$ctg.TITLE}
      {/if}
   {/foreach}
{/capture}

{strip}
{if $title_prefix}
   {assign var="in_page_title" value=$title_prefix|cat:$category.TITLE}
{else}
   {assign var="in_page_title" value=$category.TITLE}
{/if}
{assign var="description" value=$category.DESCRIPTION}
{assign var="tdescription" value=$category.TDESCRIPTION}
{assign var="catcontent" value=$category.CATCONTENT}
{include file="header.tpl" article=$article}

{*include file="top_bar.tpl"*}

{if !empty($category.ID) && (!empty($category.DESCRIPTION) || !empty($category.TITLE))}
  <li><a href="{$smarty.const.DOC_ROOT}/submit.php?id={$category.ID}" target="_self"> {l}Add A Link{/l}</a></li>
  <li><a href="{$smarty.const.DOC_ROOT}/submit_article.php?id={$category.ID}" target="_self"> {l}Add An Article{/l}</a></li>
  <li>{* UPPER INFO LI OPEN *}
  <div style="float:right">
 {if $rights.delCat eq 1}
 <a href="{$smarty.const.DOC_ROOT}/admin/dir_categs_edit.php?action=E:{$category.ID}" target="blank" title="Edit Category">Edit Category</a>&nbsp;
 <a href="{$smarty.const.DOC_ROOT}/admin/dir_links.php?r=1" target="blank" title="View Links">View Links</a>&nbsp;
 <a href="{$smarty.const.DOC_ROOT}/inplace_editcat.php?ID={$category.ID}&mode=del&detail=1&TB_iframe=true&height=100&width=250" class="thickbox" onclick="{literal}question = confirm('Are you sure you want to delete this category?');if (question !='0'){return showThickbox(this);} else return false;{/literal}">
 <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/delete.gif" width="14" height="14" style="border: none;" alt="delete link"/> 
 </a>
 {if ($category.STATUS<2) && $rights.editCat eq 1}
  <a href="{$smarty.const.DOC_ROOT}/inplace_editcat.php?ID={$category.ID}&mode=active&detail=1&TB_iframe=true&height=100&width=250" class="thickbox" onclick="{literal}question = confirm('Are you sure you want to make this category active?');if (question !='0'){return showThickbox(this);} else return false;{/literal}">
  <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/active.gif" width="14" height="14" style="border: none;" alt="category is inactive" class="float_tiny"/>
  </a>
 {/if}
 {/if}
 	</div>
  {if $category.DESCRIPTION}
  <div align="center" id="main_desc">{$category.DESCRIPTION}</div>
  <br/><br/>
  {/if}
  </li> {* UPPER INFO LI CLOSE *}

{/if}

{* Calculate the number of categories per row *}
   {php}
      $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / CATS_PER_ROW));
   {/php}

{if $cats_per_col > 15}
   {php}
      $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / (CATS_PER_ROW + 1)));
   {/php}
{/if}

{* Show category search results *}
{if $search_category}
   {$search_category}
   <br />
{/if}


{if isset($have_search_results) and $have_search_results == 0}
   <div class="noResults">
      <p>{l}Sorry, no records found that match your keyword(s){/l}: "{$search|escape|wordwrap:200:"\n":true}"</p>
      <p>{l}Suggestions{/l}:</p>
      <p>
         <ul>
            <li>{l}Make sure all words are spelled correctly{/l}.</li>
            <li>{l}Try different keywords{/l}.</li>
            <li>{l}Try more general keywords{/l}.</li>
         </ul>
      </p>
   </div>
{/if}

{if !$uid & !$search & empty($category.ID) & !$list & $scriptname == "index"}
	{*$maincontent*}
    {elseif !empty($category.ID) && !empty($catcontent) }
    {$catcontent}

{/if}

{* Categories *}
{if !empty($categs)}
	<li class="group">Categories</li>        
	{foreach from=$categs item=cat name=categs}
    	<li><a href="{$smarty.const.DOC_ROOT}/{$cat.CACHE_URL|escape}" target="_self">{$cat.TITLE|escape} ({$cat.COUNT})</a></li>
    {/foreach}
{/if}

{if !empty($feat_links)}
   <li class="group">Featured Links</li>
   {foreach from=$feat_links item=link name=links}
 	<li>{include file="link.tpl" link=$link}</li>
   {/foreach}
{/if}

{* Links heading and sorting*}
{if ($uid or $search or !empty($category.ID) or $list) and !empty($links)}
	<li class="group">Links</li>
   {foreach from=$links item=link name=links}
 	<li>{include file="link.tpl" link=$link}</li>		 
   {/foreach}
{/if}

{*no links in category*}
<br />
{if !empty($feeds)}
<h3>{$category.TITLE} news</h3>
{/if}
<div id="links">
{foreach from=$feeds item=feed}
	{include file="feed.tpl" feed=$feed item=$smarty.foreach.feeds.index}
{/foreach}
</div>

<li style="font-size:12px;"> {* other info LI OPEN *}
{if empty($feeds) and $category.ID gt 0}<div align="center" style="padding-bottom:10px;">{l}No News In This Category{/l}</div>{/if}

{if empty($links) and $category.ID gt 0 and empty($feat_links) and $MainPaging.page_total <= 1} <div align="center"> {l} No Links In This Category{/l}<a href="{$smarty.const.DOC_ROOT}/submit.php?id={$category.ID}" target="_self"> {l}Add A Link Today{/l}.</a></div>{/if}
<br />
{*no articles in category*}
{if empty($articles)  and $category.ID gt 0 and $MainPaging.page_total <= 1} <div align="center"> <span style="color:blue;">{l} No Articles In This Category {/l}</span><a href="{$smarty.const.DOC_ROOT}/submit_article.php?id={$category.ID}" target="_self"> {l}Add An Article Today{/l}.</a></div><br />{/if}
{if $search_news}
	{$search_news}
{/if}

{* Show article search results *}
{if $search_article}
   {$search_article}
{/if}
{* Articles heading *}
{if !empty($articles) and !$search}
   <h3>{l}Articles{/l}</h3>
   {if $uLevel == '1'}
   <div id="edit_container">
   {/if}
   <div id="articles">
      <table>
      {foreach from=$articles item=article name=name}
         {include file="articlelink.tpl" link=$article item=$smarty.foreach.name.index}
      {/foreach}
      </table>
   </div>
   {if $uLevel == '1'}
   </div>
   {/if}
{/if}

</li> {* other info LI CLOSE *}


{* Javascript for tracking link clicks *}
{if $StopLinkHits eq 0}
   <script type="text/javascript">
   /* <![CDATA[ */
      var root = '{$smarty.const.DOC_ROOT}';
      {literal}
      var a = document.getElementsByTagName("a");
      for(i = 0; i< a.length; i++)
         if(a[i].id != '')
            a[i].onclick = count_link;
      function count_link() {
         i = new Image();
         i.src= root+'/cl.php?id='+this.id;
         return true;
      }
      {/literal}
   /* ]]> */
   </script>
{/if}

{include file="footer.tpl"}
{/strip}