<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TopicAdd.aspx.cs" Inherits="LMN.Web.Admin.Shop.TopicAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>添加修改专题</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<link href="../Scripts/wbox/wbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
<script src="../Scripts/wbox.js" type="text/javascript"></script>
<script src="../Scripts/common.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server" target="iframe" onsubmit="return chkForm()">
<div style="padding: 20px;">
  <h4 class="title">基本信息：</h4>
  <div class="division">
    <table>
      <tr>
        <th class="right w120">所属频道:</th>
        <td>
          <asp:DropDownList ID="model_id" runat="server">
          </asp:DropDownList>
          <span>*</span></td>
      </tr>
      <tr>
        <th class="right">专题标签:</th>
        <td><input runat="server" type="text" size="10" maxlength="10" id="tag" name="tag" /> <span>* 2个汉字以内</span></td>
      </tr>
      <tr>
        <th class="right">专题名称:</th>
        <td><input runat="server" type="text" id="name" maxlength="50" size="50" style="" name="name" /> <span>* 10个汉字以内</span></td>
      </tr>
      <tr>
        <th class="right">专题封面:</th>
        <td><input runat="server" type="text" id="cover" name="cover" readonly="readonly" /> <a href="javascript:;" onclick="imageSel(this)">选择图片</a> <span>*</span></td>
      </tr>
      <tr>
        <th class="right">专题简介:</th>
        <td><input runat="server" type="text" id="intro" style="width: 90%;" maxlength="255" name="intro" /> <span>*</span></td>
      </tr>
      <tr>
        <th class="right">显示排序:</th>
        <td><input type="text" name="sort" id="sort" size="5" value="9" title="越小越靠前显示" runat="server" /></td>
      </tr>
      <tr>
        <th class="right">推荐专题:</th>
        <td><input runat="server" type="checkbox" id="recom" name="recom" value="1" /></td>
      </tr>
    </table>
  </div>
  <h4 class="title">专题产品：</h4>
  <div class="division">
    <table>
      <tr class="left">
        <th class="chk">ID</th>
        <th class="w120">Gid</th>
        <th class="w200">显示标题</th>
        <th class="w200">显示图片</th>
        <th>介绍/点评</th>
        <th class="w20">排序</th>
        <th class="w20">刪除</th>
      </tr>
      <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
          <tr id="<%#Eval("id")%>">
            <td><input type="hidden" id="itemId_<%#Eval("id")%>" name="itemid" value="<%#Eval("id")%>" /><%#Eval("id")%></td>
            <td><input type="text" id="itemGid_<%#Eval("id")%>" name="itemGid" style="width: 80px;" value="<%#Eval("goods_id")%>" /></td>
            <td><input type="text" id="itemTitle_<%#Eval("id")%>" name="itemTitle" maxlength="50" style="width: 150px;" value="<%#Eval("title")%>" /></td>
            <td><input type="text" id="itemCover_<%#Eval("id")%>" name="itemCover" maxlength="50" style="width: 150px;" value="<%#Eval("cover")%>" /> <a href="javascript:;" onclick="imageSel(this)">选择</a></td>
            <td><input type="text" id="itemIntro_<%#Eval("id")%>" name="itemIntro" maxlength="255" style="width: 90%;" value="<%#Eval("intro")%>" /></td>
            <td><input type="text" id="itemSort_<%#Eval("id")%>" name="itemSort" style="width: 20px;" value="<%#Eval("sort")%>" /></td>
            <td><a href="javascript:;" onclick="prodDele(this)">删除</a></td>
          </tr>
        </ItemTemplate>
      </asp:Repeater>
      <tbody id="prodBox">
      </tbody>
      <tr>
        <td colspan="7"><span id="prodAdd" class="sysiconBtn">添加产品到专题</span><span class="notice-inline"></span></td>
      </tr>
    </table>
  </div>
  <h4 class="title">保存修改：</h4>
  <div class="division">
    <table>
      <tr>
        <th class="right w120"></th>
        <td><b class="submitBtn"><input type="submit" value="保存" /></b> <span>1 个汉字长度 = 2 个英文字母或数字</span></td>
      </tr>
    </table>
  </div>
</div>
</form>
<iframe id="iframe" name="iframe" src="about:blank" style="display: block;"></iframe>
<script type="text/javascript">
//  var wBox;
//  wBox = $("#filemanager").wBox({
//    requestType: "iframe",
//    iframeWH: { width: 800, height: 400, resize: false },
//    target: "../FileManager/Default.aspx?target=logo"
//  });
//  function imageSel(obj) {
//    var id = $(obj).parent().children("input").attr("id");
//    wBox = $("hoho").wBox({
//      show: true,
//      requestType: "iframe",
//      iframeWH: { width: 800, height: 400, resize: false },
//      target: "../FileManager/Default.aspx?target=" + id
//    });
//  }
  function chkField(id) {
    var obj = $("#" + id);
    if (obj.val() == 0 || obj.val() == "") {
      obj.focus().css("background", "#ff0000");
      return false;
    } else {
      obj.css("background", "");
      return true;
    }
  }
  function chkForm() {
    if (chkField("model_id") && chkField("tag") && chkField("name") && chkField("logo") && chkField("intro")) {
      return true;
    }
    return false;
  }
  var aBox = $("#prodAdd").wBox({
    title: "选择产品",
    requestType: "iframe",
    iframeWH: { width: 400, height: 300, resize: false },
    target: "AjaxGoods.aspx"
  });
  function prodSel(s) {
    $.get("Action.aspx?action=getgoods&id=" + s + "&" + new Date(), function(data) {
      if (data == "0") {
        alert("有错误发生! ");
        return false;
      }
      if (data == "null") {
        alert("没有选择任何产品! ");
        return false;
      }
      var obj = eval(data);
      for (var j = 0; j < obj.length; j++) {
        var count = $("#prodBox").children("tr").length + 1;
        $("#prodBox").append(prodRow(count, obj[j]));
      }
      return true;
    });
  }
  function prodRow(i, obj) {
    var str = '<tr id="0">';
    str += '<td><input type="hidden" id="itemId__' + i + '" name="itemid" value="0" />0</td>';
    str += '<td><input type="text" id="itemGid__' + i + '" name="itemGid" style="width: 80px;" value="' + obj.id + '" /></td>';
    str += '<td><input type="text" id="itemTitle__' + i + '" name="itemTitle" maxlength="50" style="width: 150px;" value="' + obj.name + '" /></td>';
    str += '<td><input type="text" id="itemCover__' + i + '" name="itemCover" maxlength="50" style="width: 150px;" value="' + obj.cover + '" /> <a href="javascript:;" onclick="imageSel(this)">选择</a></td>';
    str += '<td><input type="text" id="itemIntro__' + i + '" name="itemIntro" maxlength="255" style="width: 90%;" value="' + obj.intro + '" /></td>';
    str += '<td><input type="text" id="itemSort__' + i + '" name="itemSort" style="width: 20px;" value="9" /></td>';
    str += '<td><a href="javascript:;" onclick="delete(this)">删除</a></td>';
    str += '</tr>';
    return str;
  }
  function prodDele(obj) {
    var id = $(obj).parent().parent().attr("id");
  }
</script>
</body>
</html>
