<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<link href="styles/general.css" rel="stylesheet" type="text/css" />
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<script src="js/utils.js"></script>
<script src="js/colorselector.js"></script>
<script type="text/javascript" src="js/validator.js"></script>
<script type="text/javascript" src="js/transport.js"></script>
<body>
<h1>
<span class="action-span"><a href="?ctl=content&act=image_list"><tpl>$image_list</tpl><!--图片列表--></a></span>
<span class="action-span1"><a href="?ctl=index&act=admin_main"><tpl>$common_admin_index</tpl><!--管理首页--></a> >> <tpl>if $article_info['article_id']!=''</tpl><tpl>$image_edit</tpl><tpl>else</tpl><tpl>$image_add</tpl><!--图片添加--><tpl>/if</tpl></span>
<div style="clear:both"></div>
</h1>
<div class="tab-div">
    <div id="tabbar-div">
      <p>
        <span class="tab-front" id="general-tab"><tpl>$image_add_base</tpl><!--基本信息--></span><span
		 class="tab-back" id="detail-tab"><tpl>$image_add_content</tpl><!--相册图片--></span><span
		 class="tab-back" id="mix-tab"><tpl>$image_add_other</tpl><!--其他信息--></span>
      </p>
    </div>

    <!-- tab body -->
    <div id="tabbody-div">
      <form action="?ctl=content&act=image_save" method="post" enctype="multipart/form-data" name="theForm" onSubmit="return validate();">
	  <input type="hidden" name="article_id" value="<tpl>$article_info['article_id']</tpl>" />
        <!-- 基本信息 -->
        <table width="90%" id="general-table" align="center">
          <tr>
            <td width="18%" class="label"><tpl>$image_add_title</tpl><!--图片标题-->：</td>
            <td colspan="2"><input type="text" name="article_title" value="<tpl>$article_info['article_title']</tpl>" style="float:left;color:<tpl>$article_info['article_title_color']</tpl>;" size="30" /><div style="background-color:<tpl>$article_info['article_title_color']</tpl>;float:left;margin-left:2px;" id="font_color" onClick="ColorSelecter.Show(this);"><img src="images/color_selecter.gif" style="margin-top:-1px;" /></div><input type="hidden" id="article_title_color" name="article_title_color" value="<tpl>$article_info['article_title_color']</tpl>" />           
            &nbsp;<input type="checkbox" name="article_class_show" value="1" <tpl>if $article_info['article_class_show']==1</tpl>checked="checked"<tpl>/if</tpl>>
            <tpl>$article_add_class_commend</tpl><!--频道推荐-->
			&nbsp;<input type="checkbox" name="article_commend" value="1" <tpl>if $article_info['article_commend']==1</tpl>checked="checked"<tpl>/if</tpl>>
            <tpl>$article_add_all_commend</tpl><!--整站推荐-->
			</td>
          </tr>
          <tr>
            <td class="label"><tpl>$article_add_jump</tpl><!--跳转网址-->：</td>
            <td colspan="2"><input type="text" name="article_url_jump" value="<tpl>$article_info['article_url_jump']</tpl>" /></td>
          </tr>
          <tr>
            <td class="label"><tpl>$image_add_author</tpl><!--图片作者-->：</td>
            <td colspan="2"><input type="text" name="article_author" value="<tpl>$article_info['article_author']</tpl>" /></td></tr>
          <tr>
            <td class="label"><tpl>$image_add_source</tpl><!--图片来源-->：</td>
            <td colspan="2"><input type="text" name="article_source" value="<tpl>$article_info['article_source']</tpl>" />			</td>
		  </tr>
          <tr>
            <td class="label"><tpl>$image_add_class</tpl><!--图片频道-->：</td>
            <td colspan="2"><tpl>$class_select</tpl></td>
          </tr>
          <tr>
            <td class="label"><tpl>$article_add_index_type</tpl><!--首页类型-->：</td>
            <td width="33%"><tpl>$index_type</tpl></td>
            <td width="49%" rowspan="3"><tpl>if $article_info['article_img']!=''</tpl><img src="<tpl>WEB_HOST</tpl><tpl>$article_info['article_img']</tpl>" width="100" height="100" border="0"><tpl>/if</tpl></td>
          </tr>
          <tr>
            <td class="label"><tpl>$image_add_sort</tpl><!--图片排序-->：</td>
            <td><input name="article_sort" type="text" size="6" value="<tpl>$article_info['article_sort']</tpl>" ></td>
          </tr>
          <tr>
            <td class="label"><tpl>$image_add_image</tpl><!--图片缩微图-->：</td>
            <td><label>
              <input type="file" name="article_img"><input type="hidden" name="old_article_img" value="<tpl>$article_info['article_img']</tpl>" >
            </label></td>
	      </tr>
          <tr>
            <td class="label"><tpl>$image_add_state</tpl><!--图片状态-->：</td>
            <td colspan="2"><tpl>$article_state</tpl></td>
          </tr>
          <tr>
            <td class="label"><tpl>$image_add_keywords</tpl><!--图片关键字-->：</td>
            <td colspan="2"><label>
              <textarea name="article_keywords" cols="50" rows="3"><tpl>$article_info['article_keywords']</tpl></textarea>
            </label></td>
          </tr>
          <tr>
            <td class="label"><tpl>$image_add_description</tpl><!--图片描述-->：</td>
            <td colspan="2"><label>
              <textarea name="article_description" cols="50" rows="5"><tpl>$article_info['article_description']</tpl></textarea>
            </label></td>
          </tr> 
        </table>

        <!-- 详细信息 -->
        <!-- 商品相册 -->
        <table width="90%" id="detail-table" style="display:none">
          <!-- 图片列表 -->
          <tr>
            <td>
              <tpl>if is_array($image_more) and count($image_more)>0</tpl>
			  	<tpl>foreach $image_more as $val</tpl>
              <div id="gallery_<tpl>$val['image_id']</tpl>" style="float:left; text-align:center; border: 1px solid #DADADA; margin: 4px; padding:2px;">
                <a href="javascript:;" onClick="if (confirm('您确实要删除该图片吗？')) dropImg('<tpl>$val['image_id']</tpl>')">[<tpl>$image_del</tpl>]</a><br />
                <img src="<tpl>WEB_HOST</tpl><tpl>$val['image_thumb']</tpl>" border="0" />
                <br />
                <input type="text" value="<tpl>$val['image_info']</tpl>" size="15" name="old_img_desc[<tpl>$val['image_id']</tpl>]" />
              </div>
              <tpl>/foreach</tpl>
			  <tpl>/if</tpl>
            </td>
          </tr>
          <tr><td>&nbsp;</td></tr>
          <!-- 上传图片 -->
          <tr>
            <td>
              <a href="javascript:;" onClick="addImg(this)">[+]</a>
              <tpl>$image_add_upload_image</tpl> <input type="file" name="img_url[]" />
			  <tpl>$image_add_image_info</tpl> <input type="text" name="img_desc[]" size="40" />
              
            </td>
          </tr>
        </table>
        <!-- 其他信息 -->
        <table width="90%" id="mix-table" style="display:none" align="center">
          <tr>
            <td class="label">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>

        <div class="button-div">
          <input type="submit" value="<tpl>$image_add_save</tpl>" class="button" />
          <input type="reset" value="<tpl>$image_add_reset</tpl>" class="button" />
        </div>
      </form>
    </div>
</div>
<div id="footer">
<tpl>$common_copyright</tpl>
</div>
<script language="JavaScript">
<!--
  /**
   * 检查表单输入的内容
   */
  function validate()
  {
    var validator = new Validator('theForm');
    validator.required('article_title','<tpl>$image_add_title_error</tpl>');
	validator.required('class_id','<tpl>$image_add_class_error</tpl>');
    return validator.passed();
  }
  /**
   * 新增一个图片
   */
  function addImg(obj)
  {
      var src  = obj.parentNode.parentNode;
      var idx  = rowindex(src);
      var tbl  = document.getElementById('detail-table');
      var row  = tbl.insertRow(idx + 1);
      var cell = row.insertCell(-1);
      cell.innerHTML = src.cells[0].innerHTML.replace(/(.*)(addImg)(.*)(\[)(\+)/i, "$1removeImg$3$4-");
  }
  /**
   * 删除图片上传
   */
  function removeImg(obj)
  {
      var row = rowindex(obj.parentNode.parentNode);
      var tbl = document.getElementById('detail-table');

      tbl.deleteRow(row);
  }
  /**
   * 删除图片
   */
  function dropImg(imgId)
  {
    Ajax.call('index.php?ctl=content&act=ajax_drop_image', 'img_id='+imgId, dropImgResponse, "GET", "JSON");
  }
 
  function dropImgResponse(result)
  {
      if (result.error == 0)
      {
          document.getElementById('gallery_' + result.content).style.display = 'none';
      }
  }

//-->
</script>
<script src="js/tab.js"></script>
</body>
