{* 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))}
  <h3>{l}Parent Category{/l}: <span id="main_title">{$category.TITLE}</span>
  </h3>
  
  

  <div style="float: right">
 {if $rights.editCat eq 1}

 <a href="{$smarty.const.DOC_ROOT}/inplace_editcat.php?ID={$category.ID}&detail=1&TB_iframe=true&height=400&width=600" class="thickbox" onclick="return showThickbox(this);">
 <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/edit.gif" width="14" height="14" style="border: none;" alt="edit category"/>
 </a>
 {/if}
 {if $rights.delCat eq 1}
 <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>
  
  <div align="center" id="main_desc">{$category.DESCRIPTION}</div>
{/if}
{* Calculate the number of categories per row *}
   {php}
      $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / CATS_PER_ROW - 3));
   {/php}

{if $cats_per_col > 25}
   {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>&nbsp;{l}Sorry, no records found that match your keyword(s){/l}: "{$search|escape|wordwrap:200:"\n":true}"</p>
      <p>&nbsp;{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}
<div>
{if !$uid & !$search & empty($category.ID) & !$list & $scriptname == "index"}
		<div class="price">{$maincontent}</div>
                {elseif !empty($category.ID) && !empty($catcontent) }
                   {$catcontent}
		   {/if}
		   </div>
{* Categories *}
{if !empty($categs)}
   {if !empty($category.ID)}
      <h3>{l}Categories{/l}</h3>
   {/if}

<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
<tr>
{foreach from=$categs item=cat name=categs}
   {if ($smarty.foreach.categs.iteration mod $cats_per_col eq 1 and $cats_per_col gt 1) or $smarty.foreach.categs.first}<td valign="top">{/if}

{* Start Categories Modifications By Maxlinks *}
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
{if empty($category.ID)}<td  width="20"><img src="{$smarty.const.DOC_ROOT}/images/cat/{$cat.ID}.png" 
{* src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/folder.gif"*} border="0" alt="{$cat.TITLE}">
</td><td valign="top">
<div class="cat2"><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE}</a>{if $smarty.const.CATS_COUNT} <span class="catHomeCount">({$cat.COUNT})</span>{/if}</div>
{else}
<td>
<div class="cat"><a href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL}/{else}index.php?c={$cat.ID}{/if}">{$cat.TITLE}</a>{if $smarty.const.CATS_COUNT} <span class="catHomeCount">({$cat.COUNT})</span>{/if}</div>
{/if}
{* Display subcategories *}

{if !empty($cat.SUBCATS)}

         {foreach from=$cat.SUBCATS item=scat name=scategs}
            <a class="subcat" href="{if $smarty.const.ENABLE_REWRITE}{$cat.TITLE_URL|escape}/{$scat.TITLE_URL|escape}/{else}index.php?c={$scat.ID}{/if}">
            {$scat.TITLE|escape}</a><br>{/foreach}

{/if}</td></tr>
</table>
{* End Categories Modifications By  Maxlinks*}

{if ($smarty.foreach.categs.iteration mod $cats_per_col eq 0 and $cats_per_col gt 1) or $smarty.foreach.categs.last}</td>{/if}
{/foreach}
</tr></table><div class="break"></div>
{if $category.ID==0}<br />{/if}
{/if}

{if $smarty.const.FTR_ENABLE == 1 and !empty($feat_links)}
<div id="bar">{l}Featured links{/l}</div>
{foreach from=$feat_links item=link name=links}
<div class="table_link">{include file="link.tpl" link=$link}</div>
{/foreach}
{/if}

{* Links heading and sorting*}
{if ($uid || $search || !empty($category.ID) || $list) && !empty($links)}
 	<div style="clear: both"></div>  
<div id="bar">
<p class="shorting">&nbsp;
   {if not $list}{l}Sort by{/l}:
   {if $smarty.const.ENABLE_PAGERANK and $smarty.const.SHOW_PAGERANK}{if $sort eq 'P'}<span class="sort"> {l}PageRank{/l}</span>{else}<a href="{if $smarty.const.ENABLE_REWRITE}{$smarty.const.DOC_ROOT}/{$category.CACHE_URL|escape}{/if}{if $smarty.const.ENABLE_REWRITE && !empty($p)}page-{$lp}.html{/if}?s=P{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}{if !empty($p) && !$smarty.const.ENABLE_REWRITE}&amp;p={$p}{/if}"> {l}PageRank{/l}</a>{/if} |{/if}
   {if $sort eq 'H'} <span class="sort">{l}Hits{/l}</span>{else} <a href="{if $smarty.const.ENABLE_REWRITE}{$smarty.const.DOC_ROOT}/{$category.CACHE_URL|escape}{/if}{if $smarty.const.ENABLE_REWRITE && !empty($p)}page-{$lp}.html{/if}?s=H{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}{if !empty($p) && !$smarty.const.ENABLE_REWRITE}&amp;p={$p}{/if}">{l}Hits{/l}</a>{/if}
   {if $sort eq 'A'} | <span class="sort">{l}Alphabetical{/l}</span>{else} | <a href="{if $smarty.const.ENABLE_REWRITE}{$smarty.const.DOC_ROOT}/{$category.CACHE_URL|escape}{/if}{if $smarty.const.ENABLE_REWRITE && !empty($p)}page-{$lp}.html{/if}?s=A{if not $smarty.const.ENABLE_REWRITE}&amp;c={$category.ID}{/if}{if $search}&amp;search={$search}{/if}{if $uid}&amp;uid={$uid}{/if}{if !empty($p) && !$smarty.const.ENABLE_REWRITE}&amp;p={$p}{/if}">{l}Alphabetical{/l}</a>{/if}
   {/if}
</p>
<div id="bar">{l}Regular Links{/l}</div></div>
{foreach from=$links item=link name=links}
<div class="table_link">{include file="link.tpl" link=$link}</div>
{/foreach}
{/if}

<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>

{if empty($feeds) and $category.ID gt 0}<div align="center">{l}{/l}</div>{/if}


{if count($links) eq 0 and $category.ID gt 0 and empty($feat_links)}
<center><br />
You may submit your link to: <h2>{$in_page_title}</h2><br><a class="catHomeCount" href="{$smarty.const.DOC_ROOT}/submit.php?c={if !empty ($category.ID) and $category.ID > 0}{$category.ID}">Submit Url</a><br /><br /></center>{/if}


{if count($articles) eq 0 and $category.ID gt 0}
<center><br />
No Articles In This Category: <h2>{$in_page_title}</h2><br><a class="catHomeCount" href="{$smarty.const.DOC_ROOT}/submit_article.php?id={$category.ID}">Add An Article Today</a></center><br /><br />{/if}	
{/if}

{* Show article search results *}
{if $search_article}
   {$search_article}
{/if}

{* Articles heading *}
{if !empty($articles) and !$search}
<h3>{l}Articles{/l}</h3>

      {foreach from=$articles item=article name=name}
   <div class="table_link">{include file="articlelink.tpl" link=$article item=$smarty.foreach.name.index}</div>
      {/foreach}
   
{/if}

{* 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}
