<{includeq file="db:tad_web_header.html"}>

<{if $op=="tad_web_link_form"}>
<script type="text/javascript">
  $(document).ready(function(){
    $('#LinkUrl').change(function() {
      $('#LinkTitle').val($('#LinkUrl').val());
      $.post("link_ajax.php", { url: $('#LinkUrl').val()},
       function(data) {
        var obj = $.parseJSON(data);
         $('#LinkTitle').val(obj.title);
         $('#LinkDesc').val(obj.description);
       });
    });
    

    $('#LinkGet').click(function() {
      $.post("link_ajax.php", { url: $('#LinkUrl').val()},
       function(data) {
        var obj = $.parseJSON(data);
         $('#LinkTitle').val(obj.title);
         $('#LinkDesc').val(obj.description);
       });
    });
  });
  

</script>


	<{$formValidator_code}>
  <div class="row-fluid">
	<form action="link.php" method="post" id="myForm" enctype="multipart/form-data">

  	<!--網站連結-->
  	<div class="controls controls-row">
      <div class="span2"><{$smarty.const._MD_TCW_LINKURL}></div>
      <input type="text" name="LinkUrl" value="<{$LinkUrl}>" id="LinkUrl" class="span8 validate[required]" placeholder="<{$smarty.const._MD_TCW_LINKURL}>">

    	<button type="button" class="btn" id="LinkGet"><{$smarty.const._MD_TCW_LINK_AUTO_GET}></button>
    </div>
    
  	<!--網站名稱-->
  	<div class="controls controls-row">
      <div class="span2"><{$smarty.const._MD_TCW_LINKTITLE}></div>
      <input type="text" name="LinkTitle" value="<{$LinkTitle}>" id="LinkTitle" class="validate[required] span10" placeholder="<{$smarty.const._MD_TCW_LINKTITLE}>">
    </div>

  	<!--說明-->
  	<div class="controls controls-row">
      <div class="span2"><{$smarty.const._MD_TCW_LINKDESC}></div>
      <textarea name="LinkDesc" class="span10" rows=3 id="LinkDesc" placehold="<{$smarty.const._MD_TCW_LINKDESC}>"><{$LinkDesc}></textarea>
    </div>

  	<div class="controls controls-row" style="text-align:right;">
    	<!--排序-->
    	<input type="hidden" name="LinkSort" value="<{$LinkSort}>">
    	<!--所屬團隊-->
    	<input type="hidden" name="WebID" value="<{$WebID}>">

    	<!--編號-->
    	<input type="hidden" name="LinkID" value="<{$LinkID}>">

    	<input type="hidden" name="op" value="<{$next_op}>">
    	<button type="submit" class="btn btn-primary"><{$smarty.const._TAD_SAVE}></button>
    </div>

  </form>
  </div>
<{else}>
  <{$FooTableJS}>
  <{includeq file="db:tad_web_common_link.html"}>

<{/if}>