<{include file="db:`$mydirname`_header.html"}>

<{include file="db:`$mydirname`_permission.html"}>


<form action="<{my_make_uri option=$uri_options mydirname=$mydirname controller=edit method=post}>" name="postlinkform" method="post" onsubmit='return submitCheck();' >

<table border="1" style="padding:6px;border-collapse:collapse;empty-cells:show; border-color:#999;margin-bottom:16px;">
  <tr>
    <th nowrap="nowrap" colspan="2">
      <{$smarty.const._MD_MODIFY}>
    </th>
  </tr>
  <tr>
    <td class="head" nowrap="nowrap">
      <{$smarty.const._MD_SITETITLE}>
    </td>
    <td class="<{cycle values='odd,even'}>">
      <input type="text" name="title" size="50" maxlength="255" value="<{$link.title}>" />
    </td>
  </tr>
  <tr>
    <td class="head" nowrap="nowrap">
      <{$smarty.const._MD_SITEURL}>
    </td>
    <td class="<{cycle values='odd,even'}>">
      <input type="text" name="url" size="50" maxlength="255" value="<{$link.url}>" />
      <a href="javascript:void(0);" onClick="check_URL(1);"><{$smarty.const._MD_CHECK_URL}></a>
    </td>
  </tr>
  <tr>
    <td class="head" nowrap="nowrap">
      <{$smarty.const._MD_MOBILE_SITEURL}>
    </td>
    <td class="<{cycle values='odd,even'}>">
      <input type="text" name="murl" size="50" maxlength="255" value="<{$link.murl}>" />
      <a href="javascript:void(0);" onClick="check_URL(2);"><{$smarty.const._MD_CHECK_URL}></a>
    </td>
  </tr>
  <tr>
    <td class="head" nowrap="nowrap">
      <{$smarty.const._MD_CATEGORY}>
      <{if $category_selector != 0}>
        <div style="padding-left:12px;font-weight:normal;">
          <a href="javascript:void(0)" onclick="addHTML('categ','categadd');"><{$smarty.const._MD_ADDCATEGORY}></a>
        </div>
      <{/if}>
    </td>
    <td class="<{cycle values='odd,even'}>" id="category">
      <{foreach item=selbox from=$category_selbox key=count}>
        <{if $count==0}>
          <div id="categ"><{$selbox}></div><div id="categadd">
        <{else}>
          <div id="categadd<{$count}>"><{$selbox}><a href='#' onclick='delThis("categadd<{$count}>");'>DELETE</a></div>
        <{/if}>
      <{/foreach}>
      </div>
    </td>
  </tr>
  <tr>
    <td class="head" nowrap="nowrap">
      <{$smarty.const._MD_DESCRIPTIONC}>
      <div style="padding-left:12px;font-weight:normal;">
        <input type="checkbox" onClick="onoff('desc_bbcode_buttons_pre')" id="desc_bbcode_buttons_preONOFF"><{$smarty.const._MD_TOOLS}><br />
        <input type="checkbox" onClick="onoff('desc_bbcode_buttons_post')" id="desc_bbcode_buttons_postONOFF"><{$smarty.const._MD_SMILIES}>
      </div>
    </td>
    <td class="<{cycle values='odd,even'}>" >
      <{xoopsdhtmltarea name="desc" cols="50" rows="7" pre_style="display:none;" post_style="display:none;" value=$link.description}>
    </td>
  </tr>

  <{if $isadmin}>
  <tr>
    <td class="head" valign="top">
      <{$smarty.const._MD_ADULT}>
    </td>
    <td class="<{cycle values='odd,even'}>" >
      <input type="radio" name="adult" value="1" <{if $link.adult==1}>CHECKED="CHECKED"<{/if}> /><{$smarty.const._YES}>
      <input type="radio" name="adult" value="0" <{if $link.adult==0}>CHECKED="CHECKED"<{/if}> /><{$smarty.const._NO}>
    </td>
  </tr>
  <{/if}>

  <tr>
    <td class="head" valign="top">
      <{$smarty.const._MD_SUBMITTER}>
    </td>
    <td class="<{cycle values='odd,even'}>" >
      <{if $link.guestname}>
        <{if $isadmin}>
          <input type="text" name="guestname" size="50" maxlength="30" value="<{$link.guestname}>" />
        <{else}>
          <{$link.guestname}>
        <{/if}>
      <{else}>
        <{$link.submitterName}>
      <{/if}>
    </td>
  </tr>

  <tr>
    <td class="head" valign="top">
      <{$smarty.const._MD_LASTUPDATEC}>
    </td>
    <td class="<{cycle values='odd,even'}>" >
      <{$link.date|formatTimestamp:"m"}>&nbsp;
      <input type="checkbox" name="age" value="1" checked="CHECKED"><{$smarty.const._MD_NEW_DATE}>
      <{if $isadmin}>
        <br />
        <input type="checkbox" name="make_regidate" value="1"><{$smarty.const._MD_MOD_DATE}>&nbsp;
        <{$date_selector}>
      <{/if}>
    </td>
  </tr>

  <{if $isadmin}>
    <tr>
      <td class="head" valign="top">
        <{$smarty.const._MD_NO_CHECK_URI}>
      </td>
      <td class="<{cycle values='odd,even'}>" >
        <input type="checkbox" name="no_check_uri" value="1"></input>
      </td>
    </tr>
  <{/if}>

  <{if $screen_shot && $screenshot_cache_time > 0}>
    <tr>
      <td class="head" valign="top">
        <{$smarty.const._MD_FORCE_COPY}>
        <div style="font-weight:normal;"><{$smarty.const._MD_FORCE_COPY_DESC}></div>
      </td>
      <td class="<{cycle values='odd,even'}>" >
        <input type="radio" name="force_copy" value="1"  /><{$smarty.const._YES}>
        <input type="radio" name="force_copy" value="0" checked="CHECKED" /><{$smarty.const._NO}>
      </td>
    </tr>
  <{/if}>

  <tr class="foot">
    <td></td>
    <td>
      <input type="submit" name="modify" class="button" value="<{$smarty.const._SUBMIT}>" />
      &nbsp;<input type="button" value="<{$smarty.const._CANCEL}>" onclick="javascript:history.go(-1)" />
      <input type="hidden" name="lid" value="<{$link.lid}>" />
      <{$gticket}>
      </form>
    </td>
  </tr>

<{if $del_perm}>
  <tr class="foot" align="right">
    <td></td>
    <td>
      <form action="<{my_make_uri option=$uri_options mydirname=$mydirname controller=edit method=delete}>" method="post" name="deleteform">
        <input type="button" value="<{$smarty.const._DELETE}>" onclick='if(confirm("<{$smarty.const._MD_LINK_DEL_MSG}>")){document.deleteform.dellink.value="1";submit();}else{return false;}' />
        <input type="hidden" name="dellink" value="" />
        <input type="hidden" name="lid" value="<{$link.lid}>" />
        <{$gticket}>
      </form>
    </td>
  </tr>
<{/if}>

</table>

<{if $screen_shot && $link.url}>
  <div style="float:left; padding:6px; width:160px; border:1px solid #F99; text-align:center;">
    <{$smarty.const._MD_SCREEN_SHOT}><br />
    <img src="http://capture.heartrails.com/128x128/shadow?<{$link.url}>" width="128" height="128" />
  </div>
  <div style="padding:6px; width:160px; margin-left:190px; border:1px solid #999; text-align:center;">
    <{$smarty.const._MD_CACHE_FILE}><br />
    <{if $link.capture}>
      <img src="<{$cache_url}>/<{$link.lid}>.jpg" width="128" height="128" />
    <{else}>
      <img src="<{$myurl}>/images/cancel64.gif" width="64" height="64" />
    <{/if}>
  </div>
  <br style="clear:both;" />
<{/if}>

<{include file="db:`$mydirname`_footer.html"}>


<script type="text/javascript">
<!--//
function submitCheck() {
  var myform = window.document.postlinkform;
  //TITLE check
  if( myform.title.value == "" ){
    alert("<{$smarty.const._MD_SITETITLE}><{$smarty.const._MD_SUBMIT_ALERT}>");
    myform.title.focus();
    return false;
  }
  //CATEGRY check
  <{if $category_selector != 0}>
    if( myform.cid.selectedIndex==0 ){
      alert("<{$smarty.const._MD_CATEGORY}><{$smarty.const._MD_SUBMIT_ALERT}>");
      return false;
    }
  <{else}>
    var cidselect = document.getElementById('cid');
    var selectcount = 0 ;
    for(i=0;i<cidselect.length;i++) {
      if(cidselect.options[i].selected) {
        selectcount++;
      }
    }
    if( selectcount==0 ){
      alert("<{$smarty.const._MD_CATEGORY}><{$smarty.const._MD_SUBMIT_ALERT}>");
      return false;
    }
  <{/if}>
  //URL check
  var url = myform.url.value ;
  var murl = myform.murl.value ;
  if( (url=="" || url=="http://" || url.length<=7) && (murl=="" || murl=="http://" || murl.length<=7) ){
    alert("<{$smarty.const._MD_SITEURL}> or <{$smarty.const._MD_MOBILE_SITEURL}> <{$smarty.const._MD_SUBMIT_ALERT}>");
    myform.url.focus();
    return false;
  }
  return true;
}

function check_URL(status)
{
  var myform = window.document.postlinkform;
  if (status == 1) {
    url = myform.url.value;
  } else if (status == 2) {
    url = myform.murl.value;
  }
  if (!(url == '' || url =='http://' || url.length < 7)) {
    jQuery.post('<{$myurl}>/js/check_url.php', {'url':url, 'status':status}, after_check);
  } else {
    alert('<{$smarty.const._MD_INPUT_CHECK_URL}>');
  }
}

function after_check(num)
{
  if (num == 1) {
    alert('<{$smarty.const._MD_CHECK_URL_NG}>');
  } else {
    alert('<{$smarty.const._MD_CHECK_URL_OK}>');
  }
}


//-->
</script>
