<%@ Page Language="C#" CodeBehind="Vote_Add.aspx.cs" Inherits="TopWinCMS.WebUI.Admin.Vote.Vote_Add" %>

<%@ Register Assembly="TopWinCMS.WebControls" Namespace="TopWinCMS.WebControls" TagPrefix="cc1" %>
<%@ Register Src="../UC_AjaxLoading.ascx" TagName="UC_AjaxLoading" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>添加投票</title>
    <meta http-equiv="Pragma" content="No-cach" />
    <link href="../Style.css" type="text/css" rel="stylesheet" />

    <script language="javascript" type="text/javascript" src="../TopWin.js"></script>

    <script language="javascript" type="text/javascript" src="../../Images/skysoft.js"></script>
    <script language="javascript" type="text/javascript" src="../../JS/AJAX/AJAX.js"></script>
    <style type="text/css">
        .style1
        {
            width: 110px;
        }
    </style>

    <script language="javascript" type="text/javascript">
     function AddChoice()
     {
        var ChoiceList = document.getElementById("ChoiceList");

        var newline=ChoiceList.insertRow();
        newline.insertCell().innerHTML='<INPUT id=HF_ID type=hidden value=0 name=HF_ID><input id="TB_ChoiceTitle" name="TB_ChoiceTitle" style="width: 70%" type="text" onblur="CheckChoceTitle(this);" onkeyup="CheckChoceTitle(this);" onkeypress="CheckChoceTitle(this);">';
        newline.insertCell().innerHTML='<input name="NTB_VoteNum" type="text" id="NTB_VoteNum" onblur="extractNumber(this,0,false);" onkeyup="extractNumber(this,0,false);" onkeypress="return blockNonNumbers(this, event,false,false);" style="width: 80px" value=0 />';
  
        newline.insertCell().innerHTML='<input onclick="return DeleteChoice(0,this)" type="image" src="../img/del.gif" />';
     }
     function LoadChoice(ID,ChoiceTitle,VoteNum)
     {
        var ChoiceList = document.getElementById("ChoiceList");
 
        var newline=ChoiceList.insertRow();
        newline.insertCell().innerHTML='<INPUT id=HF_ID type=hidden value="'+ ID +'" name=HF_ID><input id="TB_ChoiceTitle" name="TB_ChoiceTitle" style="width: 70%" type="text" onblur="CheckChoceTitle(this);" onkeyup="CheckChoceTitle(this);" onkeypress="CheckChoceTitle(this);" value="'+ ChoiceTitle +'">';
        newline.insertCell().innerHTML='<input name="NTB_VoteNum" type="text" id="NTB_VoteNum" onblur="extractNumber(this,0,false);" onkeyup="extractNumber(this,0,false);" onkeypress="return blockNonNumbers(this, event,false,false);" style="width: 80px" value="'+ VoteNum +'" />';
        
        newline.insertCell().innerHTML='<input onclick="return DeleteChoice('+ ID +',this);" type="image" src="../img/del.gif" />';
     }
     var Ajax;
     function DeleteChoice(ID,obj)
     {
        if(confirm('您确定要删除？')==false)
        {
            return false;
        }
 
        if(obj.parentNode.parentNode.tagName=="TR")
        {
            if(ID>0)
            {           
                Ajax = new AjaxClass();
                Ajax.RequestUrl = "AjaxPostBack.ashx?Action=DeleteChoice&ID="+ID;
                Ajax.Method = "get";
                Ajax.IsAsyn = true;
                Ajax.StateChangeEvent = function()
                {
                    if (Ajax.XmlHttp.readyState == 4 && Ajax.XmlHttp.status == 200)
                    {
                        var TR =obj.parentNode.parentNode;
                        TR.parentNode.removeChild(TR);
                	   
                    }
                };
                Ajax.SendRequest(); 
            }          
        }
        return true;
     }


//     function CheckChoice()
//     {
//        var ChoiceTitleList = document.getElementById("TB_ChoiceTitle");
//        var VoteNumList = document.getElementById("NTB_VoteNum");
//        
//        for(i=0;i<ChoiceTitleList.length;i++)
//        {
//            if()
//        }
//     }
       function CheckChoceTitle(obj)
       {
        var str = obj.value;
         obj.value = str.replace(",","，");
       }
 
    </script>

</head>
<body>
    <form id="Form1" method="post" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <uc1:UC_AjaxLoading ID="UC_AjaxLoading1" runat="server" />
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="tabs">
                <ul>
                    <li><a href="Vote.aspx"><span>投票主题管理</span></a></li>
                    <li id="current"><a href="Vote_Add.aspx"><span>添加投票主题</span></a></li>
                </ul>
            </div>
            <table style="margin-right: auto; margin-left: auto; width: 786px; text-align: center"
                border="1" cellspacing="0" cellpadding="0" bordercolordark="white" bordercolorlight="#cccccc">
                <tr>
                    <td class="HeaderStyle" align="center" colspan="2" runat="server" id="UiTitle">
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        投票主题：
                    </td>
                    <td height="25" align="left">
                        <asp:TextBox ID="TB_Title" runat="server" Width="335px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TB_Title"
                            ErrorMessage="该项必须填写"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        投票选项：
                    </td>
                    <td height="25" align="left">
                        <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolordark="white"
                            bordercolorlight="#cccccc" style="text-align: center" id="ChoiceList">
                            <tr class="HeaderStyle">
                                <td>
                                    &nbsp;投票选项
                                </td>
                                <td width="80">
                                    &nbsp;得票数
                                </td>
                                 <td width="40" align="center">
                                 </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:HiddenField ID="HF_ID" runat="server" Value="0" />
                                    <asp:TextBox ID="TB_ChoiceTitle" runat="server" Style="width: 70%" EnableViewState="true"
                                        onblur="CheckChoceTitle(this);" onkeyup="CheckChoceTitle(this);" onkeypress="CheckChoceTitle(this);"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TB_ChoiceTitle"
                                        ErrorMessage="至少要填写一项" Display="Dynamic" EnableTheming="False" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                </td>
                                <td width="80" align="center">
                                    <cc1:NumericTextBox ID="NTB_VoteNum" runat="server" Width="80" EnableViewState="true">0</cc1:NumericTextBox>
                                </td>
                                <td width="40" align="center">
                                    <input onclick="return confirm('您确定要删除？');DeleteChoice(-1)" type="image" src="../img/del.gif" />
                                </td>
                            </tr>
                        </table>
                        <input id="BT_AddChoice" class="btn" type="button" value="新添选项" onclick="AddChoice();" />
                        <div id="newChoiceLists">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        是否通过审核：
                    </td>
                    <td height="25" align="left">
                        <asp:CheckBox ID="CB_Pass" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        选取方式：
                    </td>
                    <td height="25" align="left">
                         
                        <asp:RadioButtonList
                            ID="RBL_SingleSelect" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="1">单选</asp:ListItem>
                            <asp:ListItem Value="0">多选</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        过期：
                    </td>
                    <td height="25" align="left">
                        <cc1:Calendar ID="CD_EndData" runat="server" CalendarResource="../../Images/CalendarResource/" />
                        如果不需要过期，请选择一个很大的日期
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        限制IP：
                    </td>
                    <td height="25" align="left">
                        <asp:CheckBox ID="CB_LimitIP" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        选用模板：
                    </td>
                    <td height="25" align="left">
                        <asp:DropDownList ID="DDL_Template" runat="server">
                            <asp:ListItem Value="">&lt;默认&gt;</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td height="25" align="right" class="style1">
                        &nbsp;
                    </td>
                    <td height="25" align="left">
                        <asp:Button ID="BT_OK" runat="server" CssClass="btn" EnableTheming="False" EnableViewState="False"
                            Text="确定" OnClick="BT_AddChoice_Click" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
