<%@ Page Language="vb" AutoEventWireup="false"  MasterPageFile="~/WFAdmin/ModalAdminPage.master" CodeBehind="NinkiMobileControlItems.aspx.vb" Inherits="WF.Ninki.UI.NinkiMobileControlItems" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TagHead" runat="server">
    <script src="../../WFResources/Themes/js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getElementsByClassName(node, classname) {
            var a = [];
            var re = new RegExp('(^| )' + classname + '( |$)');
            var els = node.getElementsByTagName("*");
            for (var i = 0, j = els.length; i < j; i++)
                if (re.test(els[i].className)) a.push(els[i]);
            return a;
        }

        function CheckButtons() {
            var txtV = document.getElementById('txtValue');
            var txtT = document.getElementById('txtText');
            var btnA = document.getElementById('btnAdd');
            var btnO = document.getElementById('btnOK');
            var btnCO = document.getElementById('btnCancel');
            var pnl = document.getElementById('pnlItems');
            var imgBtns = getElementsByClassName(document.body, 'rptButton');
            if (txtV.value.length == 0 || txtT.value.length == 0) {
                btnA.disabled = true;
                btnO.disabled = false;
                btnCO.disabled = false;
                pnl.disabled = false;
                for (var i = 0; i < imgBtns.length; i++) {
                    imgBtns[i].disabled = false
                }
            } else {
                btnA.disabled = false;
                btnO.disabled = true;
                btnCO.disabled = true;
                pnl.disabled = true;
                for (var i = 0; i < imgBtns.length; i++) {
                    imgBtns[i].disabled = true
                }
            }
        }

        function CancelAdd() {
            var txtV = document.getElementById('txtValue');
            var txtT = document.getElementById('txtText');
            var btnA = document.getElementById('btnAdd');
            var btnO = document.getElementById('btnOK');
            var btnCO = document.getElementById('btnCancel');
            var pnl = document.getElementById('pnlItems');
            var imgBtns = getElementsByClassName(document.body, 'rptButton');
            btnA.disabled = true;
            btnO.disabled = false;
            btnCO.disabled = false;
            pnl.disabled = false;
            for (var i = 0; i < imgBtns.length; i++) {
                imgBtns[i].disabled = false
            }
            txtT.value = '';
            txtV.value = '';
            return false;
        }

        function RefreshParent() {
            if (window.opener != null && !window.opener.closed) {
                window.opener.RefreshControlConfig();
            }
            CloseMe();
        }

        function CloseMe() {
            window.close();
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <h1>
            <asp:Label runat="server" ID="lblTitle" /></h1>
        <label>
            <asp:Label CssClass="fieldtitle" runat="server" ID="lblText" />
            <asp:TextBox CssClass="fieldvalue" runat="server" ID="txtText" onKeyUp="javascript: CheckButtons();" />
        </label>
        <label>
            <asp:Label CssClass="fieldtitle" runat="server" ID="lblValue" />
            <asp:TextBox CssClass="fieldvalue" runat="server" ID="txtValue" onKeyUp="javascript: CheckButtons();" />
        </label>
        <section class="actions">
            <asp:Button runat="server" CssClass="fieldsbutton" ID="btnAdd" CommandName="ADD" />&nbsp;
            <asp:Button runat="server" CssClass="fieldsbutton" ID="btnCancelAdd" />
        </section>
        <h1>
            <asp:Label runat="server" ID="lblAddedItems" /></h1>
        <asp:Repeater runat="server" ID="rptItems">
            <HeaderTemplate>
                <table>
                    <tr>
                        <td style="width: 18px;"></td>
                        <td style="width: 18px;"></td>
                        <td style="width: 22px;"></td>
                        <td style="width: 140px;"><asp:Label runat="server" CssClass="fieldtitle" ID="lblHText" Text="Texto" /></td>
                        <td style="width: 140px;"><asp:Label runat="server" CssClass="fieldtitle" ID="lblHValue" Text="Valor" /></td>
                    </tr>
            </HeaderTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
            <ItemTemplate>
                    <tr>
                        <td style="width: 18px;"><asp:ImageButton runat="server" ID="btnIDel" CommandName="DEL" ImageUrl="~/WFResources/Common/Images/icons/delete.png" /></td>
                        <td style="width: 18px;"><asp:ImageButton runat="server" ID="btnIEdit" CommandName="EDIT" ImageUrl="~/WFResources/Common/Images/icons/edit.png" /></td>
                        <td style="width: 22px;">
                            <asp:ImageButton runat="server" ID="btnIUp" CommandName="UP" Style="width: 13px; margin-bottom: 1px;" ImageUrl="~/WFResources/Common/Images/icons/move-up.png" />
                            <asp:ImageButton runat="server" ID="btnIDown" CommandName="DOWN" Style="width: 13px; margin-top: 1px;" ImageUrl="~/WFResources/Common/Images/icons/move-down.png" />
                        </td>
                        <td style="width: 140px;"><asp:Label runat="server" ID="lblIText" /></td>
                        <td style="width: 140px;"><asp:Label runat="server" ID="lblIValue" /></td>
                    </tr>
            </ItemTemplate>
        </asp:Repeater>
        <section class="actions">
            <asp:Button CssClass="fieldsbutton" runat="server" ID="btnOK" />&nbsp;
            <asp:Button CssClass="fieldsbutton" runat="server" ID="btnCancel" OnClientClick="return CloseMe();" />
        </section>
</asp:Content>