{capture name="title"}{$link_data.TITLE|escape|trim} {l}Details{/l} {$CAT_TREE|regex_replace:"/.$/":""}{/capture}
{capture assign="in_page_title"}{$TITLE|escape|trim} {l}Details{/l}{/capture}
{capture assign="description"}{l}Link Details{/l}{/capture}

{include file="header.tpl"}
{*include file="top_bar.tpl"*}
 <li style="font-size:12px;"> {* DETAIL LI OPEN *}

{strip}

{if $error}
   <div class="err">
      <img src="admin/images/no_22.gif" align="baseline" alt="Error" title="Error" />
      <p>{l}Error{/l}: {$error}</p>
   </div>
{else}

{foreach from=$widgets.LINK_DETAIL.TOP item=v}
	{if $v.SETTINGS.DISPLAY_IN_BOX eq 'Yes'}
		{include file="widget_central_top.tpl"}
	{/if}
	{$v.CONTENT}
	{if $v.SETTINGS.DISPLAY_IN_BOX eq 'Yes'}
		{include file="widget_central_bot.tpl"}
	{/if}
{/foreach}

<table style="width:100%; border:0px;">
   <tr>
      <td class="label" style="padding-top: 25px;">{l}ID{/l}:</td>
      <td class="smallDesc" align="left" style="padding-top: 25px;"><b>{$link_data.ID}</b></td>
   </tr>

   {foreach from=$submit_items item=item name=submit_items}
        {if $item.IS_DETAIL eq '1' && (!empty($link_data[$item.FIELD_NAME]) || $item.TYPE == 'BOOL')}
        {if $item.FIELD_NAME eq 'DESCRIPTION'}
        <tr>
	        <td class="label">{l}{$item.NAME}{/l}:</td>
	        <td class="smallDesc" align="left" id="editdescrip_{$link_data.ID}">{$link_data.DESCRIPTION|trim}</td>
        </tr>
        {elseif $item.FIELD_NAME eq 'TITLE'}
        <tr>
          <td class="label">{l}{$item.NAME}{/l}:</td>
          <td class="smallDesc" align="left">
          <span class="link" id="edittitle">
               {if !empty($link_data.URL)}
                <a id="id_{$link_data.ID}" href="{$link_data.URL|escape|trim}" title="{$link_data.TITLE|escape|trim}"
             {if $link_data.NOFOLLOW or ($link_data.RECPR_VALID eq 0 and ($smarty.const.RECPR_NOFOLLOW eq 2 or ($smarty.const.RECPR_NOFOLLOW eq 1 and $link_data.RECPR_REQUIRED eq 1)))} rel="nofollow"{/if}
             {if $smarty.const.ENABLE_BLANK} target="_blank"{/if}>{/if}
             {$link_data.TITLE|escape|trim}
            {if !empty($link_data.URL)}</a>{/if}</span>
          </td>
       </tr>
       {elseif $item.FIELD_NAME eq 'CATEGORY_ID'}
        <tr>
          <td class="label">{if $link_data.ADD_CATEGS}{l}Categories{/l}{else}{l}Category{/l}{/if}:</td>
          <td class="smallDesc" align="left">
          	<a href="{$link_data.CATEGORY_URL|escape|trim}" title="{$link_data.CATEGORY_TITLE|escape|trim}" target="_parent">{$link_data.CACHE_TITLE|escape|trim}</a>
			{if $link_data.ADD_CATEGS}
			    {foreach from=$link_data.ADD_CATEGS item=add_categ name=add_categs}
			    	<br/>
			        <a href="{$add_categ.CATEGORY_URL|escape|trim}" title="{$add_categ.CATEGORY_TITLE|escape|trim}">{$add_categ.CACHE_TITLE|escape|trim}</a>
			    {/foreach}      
			{/if}

          </td>
        </tr>
        {elseif $item.TYPE eq 'IMAGE'}
        <tr>
          <td class="label">{l}{$item.NAME}{/l}:</td>
          <td class="smallDesc" align="left">
              <a href="{$smarty.const.SITE_URL}uploads/{$link_data[$item.FIELD_NAME]}?detail=1&TB_iframe=true&height=400&width=400" onclick="return showThickbox(this);" class="thickbox">
                <img src="{$smarty.const.SITE_URL}uploads/thumb/{$link_data[$item.FIELD_NAME]}"/>
              </a>
            </td>
        </tr>
        {elseif $item.TYPE eq 'FILE'}
        <tr>
          <td class="label">{l}{$item.NAME}{/l}:</td>
          <td class="smallDesc" align="left">
              <a href="{$smarty.const.DOC_ROOT}/uploads/{$link_data[$item.FIELD_NAME]}" target="_blank">{$link_data[$item.FIELD_NAME]}</a>
            </td>
        </tr>
       {else}
        {if $item.FIELD_NAME eq 'ADDRESS'}
        {assign var="map" value=1}
        {/if}
        <tr>
        <td class="label">{l}{$item.NAME}{/l}:</td>
        <td class="smallDesc" align="left">
        	{if $item.TYPE == 'BOOL'}
        		{if $link_data[$item.FIELD_NAME]|escape|trim == 1}{l}yes{/l}{else}{l}no{/l}{/if}
        	{else}
				{$link_data[$item.FIELD_NAME]|escape|trim}
			{/if}
        </td>
        </tr>
 	{/if}
        {/if}
{/foreach}

{if $link_data.ADD_LINKS}
<tr>
      <td class="label">{l}Deep Links{/l}:</td>
      <td class="smallDesc" align="left">
      	{foreach from=$link_data.ADD_LINKS item=add_link name=add_links}
      		<a href="{$add_link.URL}" target="_blank" title="{$add_link.TITLE}">{$add_link.TITLE}</a>{if !$smarty.foreach.add_links.last}, {/if}
      	{/foreach}      
      </td>
</tr>
{/if}
 	
{if $smarty.const.SHOW_PAGERANK}
<tr>
      <td class="label">{l}Pagerank{/l}:</td>
      <td class="smallDesc" align="left">{if $link_data.PAGERANK ge 0}{$link_data.PAGERANK}{else}N/A{/if}</td>
</tr>
{/if}

{if $smarty.const.GMAP_ENABLE && $map eq 1}
<tr><td class="label">{l}Map{/l}:</td>
  <td class="smallDesc" align="left">
  {literal}
 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={/literal}{$link_data.GMAPKEY}{literal}"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
}
geocoder = new GClientGeocoder();
var latitude = '';
var longitude = '';
if (geocoder) {
{/literal}
var address = '{$link_data.ADDRESS|replace:"'":"\\'"},{$link_data.CITY},{$link_data.STATE}';
{literal}
geocoder.getLatLng(address,
function(point) {
if (point) {
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(point, 15);
map.addOverlay(new GMarker(point));
function createMarker(point) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {

{/literal}
marker.openInfoWindowHtml("<b>{$link_data.TITLE} <br>{$link_data.ADDRESS}{if $link_data.CITY != ""}<br> {$link_data.CITY}{/if}{if $link_data.STATE != ""}<br> {$link_data.STATE}{/if}{if $link_data.ZIP != ""}<br> {$link_data.ZIP}{/if}{if $link_data.PHONE_NUMBER != ""}<br> {$link_data.PHONE_NUMBER}{/if}</b>"); });
{literal}

return marker;
}
map.addOverlay(createMarker(point));
}
}
);
}
}
//]]>
</script>
{/literal}
<div id="map" style="margin-left:0px; width: 400px; height: 300px;"></div><br/><br/>
</div>
</td>
</tr>
{/if}

<tr>
    <td colspan="2">
        <div style="float: right;">
        {if $rights.editLink eq 1}
        <a href="{$smarty.const.DOC_ROOT}/inplace_editlink.php?ID={$link_data.ID}&detail=1&TB_iframe=true&height=400&width=600" onclick="return showThickbox(this);" class="thickbox">
        <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/edit.gif" width="14" height="14" style="border: none;" alt="edit link"/>
        </a>
        {/if}
        {if $rights.delLink eq 1}  
        <a href="{$smarty.const.DOC_ROOT}/inplace_editlink.php?ID={$link_data.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 link?');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}
        {if $STATUS<2 && $rights.editLink eq 1}
        <a href="{$smarty.const.DOC_ROOT}/inplace_editlink.php?ID={$link_data.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 link 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="link is inactive" class="float_tiny"/>
        {/if}
        {if $rights.editLink eq 1 || $rights.delLink eq 1}
        {if $has_payment > 0}
        <div class="float_tiny" style="color: green; font-weight: bold">$</div>
        {/if}
        {/if}
        </div>
    </td>
</tr>
{if $tell_friend_on == 1}
<tr>
    <td align="center" colspan="2">
        <a href="{$smarty.const.DOC_ROOT}/tell_friend.php?lid={$link_data.ID}">{l}Tell a friend{/l}</a>
    </td>
</tr>
{/if}
{if $uLevel eq 1}
<tr>
    <td align="center" colspan="2">
            <a href="{$smarty.const.DOC_ROOT}/admin/dir_links_edit.php?action=E:{$link_data.ID}" target="blank" title="Edit as Admin">Edit as Admin</a>
    </td>
</tr>
{/if}


{if $ratings_on == 1}
<tr>
    <td colspan="2">
    <fieldset>
    <legend>{l}Ratings{/l}</legend>
    {if $logged_rating eq 1}
    {if $ratingError}<div class="errForm">{l}Please choose your rating, and after this click Rate{/l}.</div>{/if}
    <label for="RATING">{l}Rate the link{/l}: &nbsp;</a>
    <form name="rating" action="{$smarty.const.DOC_ROOT}/detail.php?action=R:{$link_data.ID}" method="post">
      <select id="RATING" name="RATING" class="text" {$rating_disabled}>
        <option value=""></option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
      </select>
    &nbsp;<input type="submit" value="{l}Rate{/l}" class="btn" {$rating_disabled}>
    </form>
    &nbsp;&nbsp;
    {else}
    <center><a href="{$smarty.const.DOC_ROOT}/login.php" class="error">{l}You must be logged in to leave a rating{/l}.</a><br>
    {/if}
    <b>{l}Average rating{/l}:</b>
    {if $smarty.const.LINK_RATING_DISPLAY == 'image'}
        {if $link_data.RATING >0 }
            {section name=foo loop=$link_data.RATING}
                <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/tiny_star.gif">
            {/section}
            {if intval($link_data.RATING) < $link_data.RATING}
            <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/tiny_star_half.gif">
            {/if}
        {/if}
    {elseif $smarty.const.LINK_RATING_DISPLAY == 'bar'}
        {if $link_data.RATING >0 }
            {section name=foo loop=$link_data.RATING}
            <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/bar_full.png">
            {/section}
            {if intval($link_data.RATING) < $link_data.RATING}
            <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/bar_full_half.png">
            <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/bar_empty_half.png">
        {/if}
        {section name=foo loop=$link_data.LEFT_RATING}
        <img src="{$smarty.const.DOC_ROOT}/templates/{$smarty.const.USE_TEMPLATE}/images/bar_empty.png">
        {/section}
    {/if}
    {else}
        {$link_data.RATING}
    {/if} ({if !$link_data.VOTES}0{else}{$link_data.VOTES}{/if} {l}votes{/l})
    </fieldset>
    </td>
</tr>
{/if}
  
{if $comments_on == 1}
<tr>
   <td colspan="2">
      <fieldset>
         <legend>{l}Reviews{/l}</legend>
         {* Printing Comments *}
         {foreach from=$comments item=comment name=items}
            <table class="comment" cellspacing="0" cellpadding="0" width="100%">
               <tr class="comment">
                  <td>{$comment.USER_NAME}:</td>
                  <td align="right">{$comment.DATE_ADDED}</td>
               </tr>
               <tr height="50" valign="top">
                  <td class="descr" colspan="2">{$comment.COMMENT|nl2br}</td>
               </tr>
            </table>
         {foreachelse}
            <h3>{l}No Reviews Yet{/l}.</h3>
         {/foreach}
         {if $comm_posted eq 1 && $needs_approval_msg eq 1 }
	 <p style="color: green">{l}Comment posted and awaiting admin approval{/l}.</p>
         {elseif $comm_posted eq 1}
	 <p style="color: green">{l}Comment posted{/l}.</p>
         {/if}
         {if $logged_comment eq 1}
            <br>
            <form id="commentForm" action="{$smarty.const.DOC_ROOT}/detail.php?action=C:{$link_data.ID}" method="post">
            <table width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td colspan="2">
                    <label for="comment"><b>{l}Leave your comment{/l}:</b><br>
                    <textarea id="comment" name="comment" rows="4" cols="60" class="text">{$COMMENT}</textarea>
                    {if $commentError}<div class="errForm">{l}You need to enter comment before Submit{/l}.</div>{/if}

                </td>
            </tr>
            <tr>
                <td colspan="2">
                {if $smarty.const.VISUAL_CONFIRM_LINK_COMMENTS eq 1 && $smarty.const.VISUAL_CONFIRM eq 1}
                   {if $rights.editLink neq 1 && $rights.addLink neq 1 && $rights.delLink neq 1}
                   {if $img_verification_error}
                      <span class="error"><font color=red>{l}Verification error, please enter the code again{/l}</font></span><br>
                   {/if}
                   <input id="IMAGEHASH" name="IMAGEHASH" type="hidden" value="{$imagehash}" />
                   <img src="{$smarty.const.DOC_ROOT}/captcha.php?imagehash={$imagehash}" class="captcha" alt="{l}Visual Confirmation Security Code{/l}" title="{l}Visual Confirmation Security Code{/l}" />
                   <br><br><span class='req'>*</span>{l}Enter the code shown{/l}:
                   &nbsp;<input id="CAPTCHA" name="CAPTCHA" type="text" value="" size="{$smarty.const.CAPTCHA_PHRASE_LENGTH}" maxlength="{$smarty.const.CAPTCHA_PHRASE_LENGTH}" class="text" /><br><br>
                   {/if}
                {/if}
   {if $smarty.const.VISUAL_CONFIRM_LINK_COMMENTS eq 1 && $smarty.const.VISUAL_CONFIRM eq 2}
		<span style="color: red;">
				{foreach name=errorList from=$error_list key=errorKey item=errorItem}
					{if $errorKey == 'DO_MATH'}
						{if is_array($errorItem)}
							{$errorItem.remote}<br/>
						{else}
							{$errorItem}<br/>
						{/if}
					{/if}
				{/foreach}
			</span>
		<span class='req'>*</span>{l}Do the Math{/l}:
                   &nbsp;	<font style="font-weight: bold; font-size: 14pt; color: red; margin-right: 10px;">{$DO_MATH_N1} + {$DO_MATH_N2} = </font><input type="text" id="DO_MATH" name="DO_MATH" value='{$DO_MATH}' class="text" style="width: 60px;"/>
		<br/>
		<br/>

{/if}
                <input type="hidden" name="formSubmitted" value="1" />
                <input type="submit" value="{l}Submit{/l}" class="btn">
                </td>
            </tr>
            </table>
            </form>
         {else}
             <br><a href="{$smarty.const.DOC_ROOT}/login.php" class="error" target="_parent">{l}You must be logged in to leave a Comment{/l}.</a><br>
         {/if}
      </fieldset>
   </td>
</tr>
{/if}
   <tr>
      <td colspan="2">&nbsp;</td>
   </tr>
</table>

{* Javascript for tracking link clicks *}
<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>
{foreach from=$widgets.LINK_DETAIL.BOT item=v}
	{if $v.SETTINGS.DISPLAY_IN_BOX eq 'Yes'}
	{include file="widget_central_top.tpl"}
	{/if}
	{$v.CONTENT}
	{if $v.SETTINGS.DISPLAY_IN_BOX eq 'Yes'}
	{include file="widget_central_bot.tpl"}
	{/if}
{/foreach}
{/if}
{/strip}

 </li> {* DETAIL LI CLOSE *}

{include file="footer.tpl"}