<%@ control language="C#" autoeventwireup="true" inherits="Admin_UserControl_AddOption, ShopWe" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<script type="text/javascript">
function OptionClear()
{
var div=document.getElementById("OptionGroupDiv");
div.innerHTML="";
}
function AddOptionGroup()
{
   var ObjID=generateMixed(10);
   var newDiv = document.createElement("div");
   newDiv.innerHTML="<div class=\"din_all\" id=\"OptionGroupItem"+ObjID+"\">"+
                      "<div class=\"come_title_hui\"><table width=\"100%\" height=\"26\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"+
                      "<tr><td style=\"width: 330px\"><h1>附加组名</h1><input name=\"GroupName\" style=\"width: 250px\" class=\"input\" value=\"请输入组名\" /></td>"+
                      "<td class=\"bg_1\">多选还是单选：<select name=\"IsRadio\"><option>单选</option><option>多选</option></select></td>"+
                      "<td style=\"width: 100px\">"+
                      "<div class=\"img_button\"><img src=\"../css/images/add_img.gif\" alt=\"添加\" />"+
                      "<a href='javascript:AddOptionItem(\"OptionGroupItem"+ObjID+"\")' class=\"grey\">添加</a></div>"+
                       "<div class=\"img_button\"><img src=\"../css/images/del_imgred.gif\" alt=\"清空\" width=\"14\" height=\"10\" />"+
                      "<a href='javascript:Delete(\"OptionGroupItem"+ObjID+"\")' class=\"grey\">清空</a></div>"+
                      "</td></tr></table></div>"+
                      //用来让附加项知道属于那个组,后台编程使用
                      "<input name=\"HiddenGroupName\" value=\"OptionGroupItem"+ObjID+"\" type=\"hidden\" />"+
                      "</div>";
                      
   document.getElementById("OptionGroupDiv").appendChild(newDiv);
   AddOptionItem("OptionGroupItem"+ObjID);
}
function AddOptionItem(GroupID)
{
 var ObjID=generateMixed(10);
 var newDiv = document.createElement("div");
 newDiv.innerHTML="<div id=\"OptionItem"+ObjID+"\" class=\"din_all_body\"><div class=\"din_all_title\"><h1>项目名称</h1>"+
                      "<input name=\"OptionName\" style=\"width: 180px\" class=\"input\" value=\"请输入项名称\"/>"+
                      "<h1>价格</h1>"+
                      "<input name=\"OptionPrice\" style=\"width: 80px\" class=\"input\" value=\"0\"/>"+
                      "<div class=\"img_button\"><img src=\"../css/images/add_img.gif\" alt=\"展开\" /><a href='javascript:show(\"Div"+ObjID+"\")' class=\"grey\">展开</a></div>"+
                      "<div class=\"img_button\"><img src=\"../css/images/del_imgred.gif\" alt=\"删除\" width=\"14\" height=\"10\" /><a href='javascript:Delete(\"OptionItem"+ObjID+"\")' class=\"grey\">删除</a></div>"+
                      "</div>"+
                      "<div id=\"Div"+ObjID+"\" style=\"display:none\" class=\"din_all_remark\">"+
                      "<textarea id=\"OptionRemark"+ObjID+"\" onclick=\"showFCK(this.id)\"  name=\"OptionRemark\" style=\"width:100% ;height:180px\"></textarea>"+
                      "</div>"+
                      //用来让附加项知道属于那个组,后台编程使用
                      "<input name=\"ParentGroupName\" value=\""+GroupID+"\" type=\"hidden\" />"+
                      "</div>";
                      
 document.getElementById(GroupID).appendChild(newDiv);
}

function showFCK(id){
var oFCKeditor = new FCKeditor(id) ;
oFCKeditor.BasePath = '../Fckeditor/' ;
oFCKeditor.ToolbarSet = 'Basic' ;
oFCKeditor.Width = '100%' ;
oFCKeditor.Height = '200' ;
oFCKeditor.ReplaceTextarea() ;
}

</script>

<asp:UpdatePanel ID="UpdatePanelOption" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <!--快速选择组结束-->
        <div class="come_title_3">
            <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <h2>
                            商品附加：</h2>
                        <input type="button" value="添加一个附加组" class="butt_tle" onclick="AddOptionGroup();HideDiv('OptionTip');"
                            style="height: 20px; width: 110px" />
                        <input type="button" value="全部清空" class="butt_tle" onclick="OptionClear()" style="height: 20px;
                            width: 70px" />
                    </td>
                    <td>
                        <asp:TextBox ID="SelectGroupName" runat="server" CssClass="input" Width="150" Height="18"
                            Text="添加快速选择组" MaxLength="7"></asp:TextBox>
                        <asp:Button ID="AddGroup" runat="server" CssClass="butt_tle" Height="20px" Width="120px"
                            CausesValidation="false" Text="添加到快速选择组" OnClick="AddGroup_Click" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="k_all1">
            <asp:Repeater ID="RepeaterOptionSelectGroup" runat="server" OnItemCommand="RepeaterOptionSelectGroup_ItemCommand">
                <ItemTemplate>
                    <div class="Template2_button">
                        <asp:ImageButton ID="DeleteGroup" runat="server" ImageUrl="~/Admin/css/images/del_imgred.gif"
                            CommandName="Delete" CommandArgument='<%# Eval("File") %>' CausesValidation="false"
                            ToolTip="删除" OnClientClick="return confirm('你真的要删除?');" /><asp:LinkButton ID="LinkButtonSelectGroup"
                                runat="server" CssClass="blue" CommandName="Select" CommandArgument='<%# Eval("File") %>'
                                CausesValidation="false"><%# Eval("Name") %></asp:LinkButton>
                    </div>
                    <!--<img src="../css/images/bj.png" alt="导出" />
                <a href='../xml/Attribute/<%# Eval("File")%>' class="grey" target="_blank">导出</a>-->
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanelOptionBody" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="k_all6" id="OptionGroupDiv">
            <asp:Panel ID="PanelTip" runat="server">
                <div class="ys_bf_eeor" id="OptionTip">
                    <table>
                        <tr>
                            <td align="center" style="height: 30px">
                                你还未添加附加组，请<a href="#" onclick="AddOptionGroup();HideDiv('OptionTip');" class="blue">
                                    添加一个附加组 </a>或者快速导入。</td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
            <asp:Literal ID="LiteralBody" runat="server"></asp:Literal>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
