<%@ page language="C#" masterpagefile="~/MasterPage.master" autoeventwireup="true" inherits="ManualControl_ManualDoorControl, CardAccess.Web.UI_deploy" title="Manual Door Control" theme="Office2007Black" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script id="igClientScript" type="text/javascript">
        function txtUnlockTime_TextChanged(oEdit, newText, oEvent) {
            //Add code to handle your event here.
            var val = newText.get_text();
            var value = parseInt(val);
            var TargetLabel;
            TargetLabel = document.getElementById("<%= ControlUnlockTimeLabel.ClientID%>");
            Target = document.getElementById("<%=HiddenField1.ClientID%>");

            if (parseInt(value) >= 60) {
                if (TargetLabel) {
                    if (TargetLabel.innerText == "") {
                        TargetLabel.innerText = '<%=Seconds %>';
                        Target.value = '<%=Seconds %>';
                    }
                }
            }
            if (TargetLabel) {
                if ((value < 1) && (TargetLabel.innerText == '<%=Minutes %>')) {
                    oEdit.set_value('59');
                    TargetLabel.innerText = '<%=Seconds %>';
                    Target.value = '<%=Seconds %>';
                }
                if ((value >= 1) && (TargetLabel.innerText == '<%=Minutes %>')) {
                    Target.value = '<%=Minutes %>';
                }
                if ((value >= 1) && (TargetLabel.innerText == '<%=Seconds %>')) {
                    Target.value = '<%=Seconds %>';
                }
                if ((value < 1) && (TargetLabel.innerText == '<%=Seconds %>')) {
                    oEdit.set_value('0');
                }
                else if ((value > 59) && (TargetLabel.innerText == '<%=Seconds %>')) {
                    oEdit.set_value('1');
                    TargetLabel.innerText = '<%=Minutes %>';
                    Target.value = '<%=Minutes %>';
                }
            }
        }

        function txtUnlockTime_Spin(oEdit, delta, oEvent) {
            //Add code to handle your event here.
            if (delta.get_delta() == -1) {
                var TargetLabel;
                TargetLabel = document.getElementById("<%= ControlUnlockTimeLabel.ClientID%>");
                if (TargetLabel) {
                    var value = oEdit.get_value();
                    if (value <= 1 && TargetLabel.innerText == '<%=Minutes %>') {
                        oEdit.set_value(60);
                        TargetLabel.innerText = '<%=Seconds %>';
                    }
                }
            }
        }

        function setReadersListPosition() {
            var intY = document.getElementById("divReadersList").scrollTop;
            var h = document.getElementById("hfScrollPosition");
            h.value = intY;
        }

        function setScrollAfterpostback() {
            var h = document.getElementById("hfScrollPosition");
            document.getElementById("divReadersList").scrollTop = h.value;
        }
        // -->
    </script>
    <asp:HiddenField ID="hfScrollPosition" Value="0" />
    <asp:UpdatePanel ID="WebAsyncRefreshPanel1" runat="server">
        <ContentTemplate>
            <igmisc:WebGroupBox ID="grpMain" runat="server" Text="" BackColor="Transparent">
                <Template>
                    <asp:Table ID="tblManualDoor" runat="server" Width="100%" Height="100%">
                        <asp:TableRow>
                            <asp:TableCell Width="50%">
                                <igmisc:WebGroupBox ID="WebGroupBox5" runat="server" Height="85px" BackColor="Transparent">
                                    <Template>
                                        <div style="padding: 8px;">
                                            <igmisc:WebGroupBox ID="WebGroupBox2" runat="server" BackColor="Transparent">
                                                <Template>
                                                    <asp:CheckBox ID="chkDoorAction" AutoPostBack="true" OnCheckedChanged="chkDoorAction_CheckedChanged"
                                                        runat="server" Text="Door Action" Checked="true"></asp:CheckBox>
                                                    <asp:RadioButtonList ID="rdoDoorAction" runat="server" AutoPostBack="true" RepeatDirection="Horizontal"
                                                        RepeatColumns="3" OnSelectedIndexChanged="rdoDoorAction_SelectedIndexChanged">
                                                        <asp:ListItem Value="1" Text="Lock"></asp:ListItem>
                                                        <asp:ListItem Value="2" Text="Unlock" Selected="True"></asp:ListItem>
                                                        <asp:ListItem Value="3" Text="Unlock Hold"></asp:ListItem>
                                                    </asp:RadioButtonList>
                                                </Template>
                                            </igmisc:WebGroupBox>
                                        </div>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                            <asp:TableCell Width="50%">
                                <igmisc:WebGroupBox ID="WebGroupBox4" runat="server" Height="85px" BackColor="Transparent">
                                    <Template>
                                        <table>
                                            <tr>
                                                <td colspan="2">
                                                    <igtxt:WebImageButton ID="btnExecuteDoorAction" runat="server" Text="  Execute Door Action  "
                                                        Height="24px" OnClick="btnExecuteDoorAction_Click">
                                                    </igtxt:WebImageButton>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="width: 200px;">
                                                    <asp:CheckBox ID="chkReaderAction" AutoPostBack="true" OnCheckedChanged="chkReaderAction_CheckedChanged"
                                                        runat="server" Text="Reader Action"></asp:CheckBox>
                                                    <asp:RadioButtonList ID="rdoReaderAction" runat="server" Enabled="false" RepeatDirection="Horizontal"
                                                        RepeatColumns="2">
                                                        <asp:ListItem Value="1" Text="Enable" Selected="True"></asp:ListItem>
                                                        <asp:ListItem Value="2" Text="Disable"></asp:ListItem>
                                                    </asp:RadioButtonList>
                                                </td>
                                                <td>
                                                    <asp:CheckBox ID="chkReaderKeypad" AutoPostBack="true" OnCheckedChanged="chkKeypadAction_CheckedChanged"
                                                        runat="server" Text="Keypad Action"></asp:CheckBox>
                                                    <asp:RadioButtonList ID="rdoKeypadAction" runat="server" Enabled="false" RepeatDirection="Horizontal"
                                                        RepeatColumns="2">
                                                        <asp:ListItem Value="1" Text="Enable" Selected="True"></asp:ListItem>
                                                        <asp:ListItem Value="2" Text="Disable"></asp:ListItem>
                                                    </asp:RadioButtonList>
                                                </td>
                                            </tr>
                                        </table>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell ColumnSpan="2">
                                <igmisc:WebGroupBox ID="pnlUnlockTime" runat="server" BackColor="Transparent">
                                    <Template>
                                        <asp:Table ID="tblUnlockTime" runat="server" Width="100%" CssClass="TabArea">
                                            <asp:TableRow>
                                                <asp:TableCell VerticalAlign="Middle">
                                                    <asp:Label ID="lblDoorEnergizeTimeOverride" runat="server" Text="Door Strike Time Override:"></asp:Label>
                                                </asp:TableCell>
                                                <asp:TableCell VerticalAlign="Middle">
                                                    <table cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td valign="middle" align="left" nowrap="nowrap">
                                                                <ig:WebNumericEditor ID="txtUnlockTime" runat="server" MaxLength="2" DataMode="int"
                                                                    MinValue="0" MaxValue="60" Nullable="false">
                                                                    <ClientEvents TextChanged="txtUnlockTime_TextChanged" Spin="txtUnlockTime_Spin" />
                                                                    <Buttons SpinButtonsDisplay="OnRight">
                                                                    </Buttons>
                                                                </ig:WebNumericEditor>
                                                            </td>
                                                            <td valign="middle">
                                                                <asp:Label runat="server" ID="ControlUnlockTimeLabel"></asp:Label>
                                                                <asp:HiddenField ID="HiddenField1" Value="Seconds" runat="server" />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </asp:TableCell>
                                                <asp:TableCell>
                                                    <asp:Label ID="lblWarn" runat="server" Font-Bold="true"></asp:Label>
                                                </asp:TableCell>
                                            </asp:TableRow>
                                        </asp:Table>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell ColumnSpan="2">
                                <igmisc:WebGroupBox ID="WebGroupBox1" runat="server" BackColor="Transparent">
                                    <Template>
                                        <table id="Table1" runat="server" width="100%">
                                            <tr>
                                                <td style="text-align: left; width: 120px;" valign="Left">
                                                    <asp:Label ID="lblPartitions" Text="Partitions" runat="server"></asp:Label>
                                                </td>
                                                <td>
                                                    <ig:WebDropDown ID="cboPartitons" runat="server" DisplayMode="DropDownList" Width="300px"
                                                        EnableDropDownAsChild="false" AutoPostBack="true" OnSelectionChanged="cboPartitons_SelectedRowChanged">
                                                    </ig:WebDropDown>
                                                </td>
                                            </tr>
                                        </table>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell ColumnSpan="2">
                                <igmisc:WebGroupBox ID="WebGroupBox3" runat="server" BackColor="Transparent">
                                    <Template>
                                        <asp:Table ID="Table3" runat="server" Width="100%" Height="100%">
                                            <asp:TableRow>
                                                <asp:TableCell HorizontalAlign="left">
                                                    <asp:CheckBox ID="chkAlphaSort" runat="server" Text="Sort alphabetically" OnCheckedChanged="chkAlphaSort_CheckedChanged"
                                                        AutoPostBack="true"></asp:CheckBox>
                                                </asp:TableCell>
                                            </asp:TableRow>
                                            <asp:TableRow>
                                                <asp:TableCell>
                                                    <igmisc:WebGroupBox ID="pnlChkReaders" runat="server" Text="" Height="320px" BackColor="Transparent">
                                                        <Template>
                                                            <div id="divReadersList" style="overflow: auto; height: 300px;" onscroll="setReadersListPosition()">
                                                                <%--<br />--%>
                                                                <asp:CheckBoxList ID="clbDoor" RepeatDirection="Vertical" AutoPostBack="true" OnSelectedIndexChanged="clbDoor_SelectedIndexChanged"
                                                                    runat="server">
                                                                </asp:CheckBoxList>
                                                            </div>
                                                        </Template>
                                                    </igmisc:WebGroupBox>
                                                </asp:TableCell>
                                            </asp:TableRow>
                                        </asp:Table>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell ColumnSpan="2">
                                <igmisc:WebGroupBox ID="btnGroup" runat="server" Text="" BackColor="Transparent">
                                    <Template>
                                        <div style="padding: 8px;">
                                            <igtxt:WebImageButton ID="btnSelectAll" runat="server" Text=" Select All " Width="60px"
                                                Height="24px" Style="display: inline-table; float: left;" OnClick="btnSelectAll_Click">
                                            </igtxt:WebImageButton>
                                            &nbsp;&nbsp;
                                            <igtxt:WebImageButton ID="btnClearAll" runat="server" Text=" Clear All " Width="60px"
                                                Height="24px" Style="display: inline-table;" OnClick="btnClearAll_Click" />
                                        </div>
                                    </Template>
                                </igmisc:WebGroupBox>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </Template>
            </igmisc:WebGroupBox>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
