<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UserGroup_FXD_TabAccess.aspx.vb" Inherits="FinIQWebApp.User_Group_FXD_tab_access" MasterPageFile="~/FiniqAppMasterPage.Master" Async="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<asp:Content ID="ContentCUDSettings" ContentPlaceHolderID="MainContent" runat="server">

    <style>
        .usergroupHeaderStyle {
        }    

        .Grid {
           overflow: hidden;
            table-layout: fixed; 
            border: solid 1px #ddd;
            border-collapse: collapse;
            border-spacing: 0px;
            background-color: #FFF !important;
			margin:5px;
			position:relative;
			float:left !important;
			width:50%;
        }

            .Grid thead {
                overflow: visible;
                display: block;
                z-index: 1;
            }

            .Grid tbody {
                overflow: scroll;
                display: block;
                margin-top: -1px;
            }

            .Grid tbody, .Grid thead, .Grid {
                position: relative;
            }

                .Grid th:nth-child(1), .Grid tr td:nth-child(1) {
                    position: relative;
                    left: 0px;
                    border: 1px solid #DDD !important;
                    border-collapse: collapse;
                }

                .Grid th:nth-child(1), .Grid tr td:nth-child(1) {
                    min-width: 50px !important;
                    max-width: 50px !important;
                    z-index: 998;
                    background-color: #f3f3f3;
                }


                .Grid th,
                .Grid td {
                    box-sizing: border-box !important;
                    text-align: center;
                    vertical-align: middle;
                    line-height: normal;
                    border: solid 1px #DDD;
                    border-collapse: collapse;
                    border-spacing: 0;
                    border-collapse: separate;
                    padding: 0px !important;
                }

                    .Grid th:nth-child(1) {
                        color: #000 !important;
                        background-color: lightgrey;
                        font-size: 20px !important;
                        min-width: 120px !important;
                        max-width: 120px !important;
                        width: 120px !important;
                        height: 120px !important;
                        font: bold 14px verdana !important;                               
                    }

                .Grid tr td:nth-child(1) {
                    min-width: 120px !important;
                    max-width: 120px !important;
                }

                .Grid th:not(:nth-child(1)) {
                    height: 200px !important;
                    font: normal 13px verdana !important; 
                    background-color: #f3f3f3;
                }

                .Grid td:not(:nth-child(1)) {
                    min-width: 50px !important;
                    max-width: 50px !important;
                }

             
                .Grid th:not(:nth-child(1)), .Grid td:not(:nth-child(1)) {
                    min-width: 50px !important;
                    max-width: 50px !important;
                }

                .Grid td input, .Grid th span {
                    padding: 10px !important; 
                    background-color: transparent;
                    box-sizing: border-box !important; 
                }
                      
                  .rotate, .Grid th span {
                    font: normal 13px verdana !important;
                    -moz-transform: rotate(270deg) translateX(-5px) translateY(-75px);
                    -webkit-transform: rotate(270deg) translateX(-5px) translateY(-75px);
                    transform: rotate(270deg) translateX(-5px) translateY(-75px);
                    display: block;
                    white-space: pre;
                      width: 200px !important;
                }

                .Grid th span {
                white-space:normal;
                }
                .Grid td input {
                    text-transform: uppercase;
                }

        body {
            padding-bottom: 28px !important;
        }
    </style>
    <script>



        function txtpageno_TextChanged() {
            document.getElementById('ctl00_MainContent_hdn_pagenochanged').value = "TRUE"
        }




        if (window.captureEvents) {
            window.captureEvents(Event.KeyUp);
            window.onkeyup = executeCode;
        }
        else if (window.attachEvent) {
            document.attachEvent('onkeyup', executeCode);


        }
        var CellID, CellIndex;
        var temp;
        var active = 0;
        function executeCode(event) {
            if (event == null) {
                event = event || window.event;
            }
            var theKey = parseInt(event.keyCode, 10);
            CellID = document.activeElement || event.currentTarget;
            CellIndex = CellID.cellIndex || CellID.parentElement.cellIndex;

            Current_Cell = document.activeElement.value || (CellID.textContent == "" ? (CellID.value != undefined ? CellID.value : "") : CellID.textContent);
            var rows = $(CellID).parent().parents('.Grid tbody').children().length;
            var columns = $(CellID).parents('tr.GridItem').children().length;
            $TDs = $(CellID).parents('tr.GridItem').children();
            prevValByFocused_Cell = document.activeElement.defaultValue || CellID.defaultValue;
            active = CellIndex;

            switch (theKey) {
                case 37:
                    temp = active;
                    while (temp > 0) {
                        temp = temp - 1;
                        if ($TDs.eq(temp).find('input:not(:disabled)').length != 0) {
                            active = temp;
                            break;
                        }
                    }
                    $TDs.eq(active).find('input')[0].select();
                    var input = $TDs.eq(active).find('input')[0].focus();
                    return true
                    break;
                case 38:
                    $(CellID).parents('tr.GridItem').prev().children().eq(CellIndex).find('input')[0].focus()
                    $(CellID).parents('tr.GridItem').prev().children().eq(CellIndex).find('input')[0].select();
                    return true
                    break;
                case 39:
                    temp = active;
                    while (temp < (columns * rows) - 1) {
                        temp = temp + 1;
                        if ($TDs.eq(temp).find('input:not(:disabled)').length != 0) {
                            active = temp;
                            break;
                        }
                    }
                    $TDs.eq(active).find('input')[0].select();
                    var input = $TDs.eq(active).find('input')[0].focus();
                    return true
                    break;
                case 40:
                    if (prevValByFocused_Cell != Current_Cell) {
                        Update_IndexMaster(CellID);
                    }
                    $(CellID).parents('tr.GridItem').next().children().eq(CellIndex).find('input')[0].focus()
                    $(CellID).parents('tr.GridItem').next().children().eq(CellIndex).find('input')[0].select();

                    return true
                    break;
                case 13:
                    $(CellID).parents('tr.GridItem').next().children().eq(CellIndex).find('input')[0].focus()
                    $(CellID).parents('tr.GridItem').next().children().eq(CellIndex).find('input')[0].select();
                    return true
                    break;
            }

   event.returnValue = false;
            return false;
        }
   </script>

    <asp:UpdatePanel ID="UpdatepanelMain" runat="server">
        <ContentTemplate>

            <script type="text/javascript">
                function isNumberKey(evt) {
                    var charCode = (evt.which) ? evt.which : evt.keyCode;
                    if (charCode > 31 && (charCode < 48 || charCode > 57))
                        return false;
                    return true;
                }
            </script>

            <table>
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td id="Td1" align="left" runat="server" style="padding-bottom: 10px; display:none;">
                                    <asp:Label ID="lblMessage" runat="server" Text="" CssClass="lbl" Style="color: green !important" Font-Size="Medium"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lblErrorMessage" runat="server" Text="" CssClass="lbl" Style="color: red !important" Font-Size="Medium"></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table>
                            <tr style="height: 45px; display:none;">
                                <td>
                                    <asp:Button runat="server" ID="btnLoad" Text="Load" CssClass="btnStyle btn" Visible="false" />
                                </td>

                                <td>
                                    <asp:Button runat="server" ID="btnCancel" Text="Cancel" CssClass="btnStyle btn" Visible="false" />
                                </td>
                            </tr>
                        </table>
                    </td>

                </tr>
                <tr>
                    <td>
                        <asp:Button ID="btnPrev" runat="server" Text="Prev" Style="border: 1PX; height: 25PX; width: 60PX; background-color: #f7f7f7 !important;" OnClick="btnPrev_Click1" />
                        <asp:TextBox ID="txtpageno_Grid" runat="server" Text="" MaxLength="6" Style="text-align: center;" Width="30px" onkeypress="return isNumberKey(event)" AutoPostBack="true"> </asp:TextBox>
                        <asp:Button ID="btnNext" runat="server" Text="Next" Style="border-style: none; border-color: inherit; border-width: 1PX; background-color: #f7f7f7 !important;" Width="37px"></asp:Button>
                    </td>
                    <tr>
                        <td>

                            <asp:GridView runat="server" ID="grdUserGroupFXDAccess" CssClass="Grid" AutoGenerateColumns="true" BorderStyle="Solid" BorderWidth="0px">
                                <SelectedRowStyle CssClass="GridItemSelect" />
                                <RowStyle CssClass="GridItem" />
                                <AlternatingRowStyle CssClass="GridItem" />
                                <HeaderStyle CssClass="GridHeader" />
                                <FooterStyle CssClass="GridFooter" />
                                <PagerStyle CssClass="GridPager" />
                                <EmptyDataTemplate>
                                    <asp:Label ID="lblgrdUserGroupFXDAccess" runat="server" CssClass="lbl" Text="No data found."></asp:Label>
                                </EmptyDataTemplate>

                            </asp:GridView>
                            <asp:HiddenField ID="HiddenField1" runat="server" />
                            <asp:HiddenField ID="hdn_pagenochanged" runat="server" />
                            <asp:HiddenField ID="hdn_pagenumber" runat="server" />

                        </td>
                    </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>


    <script type="text/javascript">
        var GridX, GridY = 0;
        $(document).ready(function () {
            SetGridColumnFreeze();

        });
        function SetGridColumnFreeze() {
            try {
                if ($('.Grid').find('thead').length == 0) {
                    // $('.Grid').find('thead').remove();
                    $('<thead></thead>').insertBefore($('.Grid').find('tbody'));
                    $('.Grid').find('thead').append($('.Grid .GridHeader'));
                }
                
                GridX = ($('.Grid').offset().left + 20);

                $('.Grid tbody').scroll(function (e) {

                    $('.Grid thead').css("left", (-1) * Number($(".Grid tbody").scrollLeft()));
                    $('.Grid thead th:nth-child(1), .Grid thead th:nth-child(2)').css("left", $(".Grid tbody").scrollLeft());
                    $('.Grid tbody td:nth-child(1), .Grid tbody td:nth-child(2)').css("left", $(".Grid tbody").scrollLeft());
                });

                $('.Grid td span, .Grid th span').css('display', '').css('padding', '0px').css('white-space', 'normal !important');
                
                $('.Grid').width(Number(window.innerWidth) - GridX);
                GridY = ($('.Grid').offset().top + $('.Grid thead').height()) + 20;
                $('.Grid  tbody').height(Number(window.innerHeight) - GridY);


                $(window).resize(function () {
                    $('.Grid').width(Number(window.innerWidth) - GridX);
                    GridY = ($('.Grid').offset().top + $('.Grid thead').height()) + 20;
                    $('.Grid  tbody').height(Number(window.innerHeight) - GridY);

                });
                 Sys.WebForms.PageRequestManager.getInstance().remove_endRequest();
                 Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () { SetGridColumnFreeze() });


                $('.Grid td input').each(function () {
                    $(this).on("keydown", function (event) {
                                             
                                             event = event || window.event;
                                             if (event.keyCode == 8 || event.keyCode == 46 || event.keyCode == 9 || event.keyCode == 13 || (event.keyCode >= 37 && event.keyCode <= 40)) {
                                                 return true;
                                             }
                        else if ((event.key == "Y" || event.key == "y" )) {
                            if (event.currentTarget.value.length > 0 && document.getSelection().type!="Range") {
                                return false
                            }
                            return true;
                        }
                        else { return false; }
                    });
                })

                    
                 
            } catch (er) { }
        }




    </script>

</asp:Content>

