<%@ Page Title="" Language="C#" MasterPageFile="~/Master/ELSiteMaster.Master" AutoEventWireup="true" CodeBehind="EntityLibraryPage.aspx.cs" Inherits="MKInsight.Online.ActionTracking.EntityLibrary.EntityLibraryPage"  %>

<%@ Register Src="../UIControls/EntityLibrary/EntityFilterControl.ascx" TagName="EntityFilterControl" TagPrefix="uc1" %>
<%@ Register Src="~/UIControls/UserComments/UserCommentsControl.ascx" TagPrefix="uc1" TagName="UserCommentsControl" %>
<%@ Register Assembly="UIWebControls" Namespace="UIWebControls" TagPrefix="cc4" %>
<%@ Register Src="../UIControls/Metabase/MetabaseViewer.ascx" TagName="MetabaseViewer" TagPrefix="uc2" %>
<%@ Register Src="../UIControls/Interface/MultilineTextBoxEx.ascx" TagName="MultilineTextBoxEx" TagPrefix="uc3" %>
<%@ Register Src="../UIControls/Interface/LabelEx.ascx" TagName="LabelEx" TagPrefix="uc4" %>
<%@ Register Src="../UIControls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc5" %>
<%@ Register Src="../UIControls/EntityLibrary/MarkEffectiveControl.ascx" TagName="MarkEffectiveControl" TagPrefix="uc6" %>
<%@ Register Src="../UIControls/Interface/LinkButtonEx.ascx" TagName="LinkButtonEx" TagPrefix="uc7" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register src="../UIControls/Interface/CheckListFlyout.ascx" tagname="CheckListFlyout" tagprefix="uc8" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" src="../scripts/jquery/jquery_min.js"></script>
    <script type="text/javascript">
        function setdata(value) {
            PageMethods.SetData(value);
        }
    </script>

    <script type='text/javascript' src="../scripts/jquery/jquery_min.js"></script>
    <script type='text/javascript' src="../scripts/jquery/jquery.box-min.js"></script>
    <link rel="stylesheet" type="text/css" href="../scripts/jquery/jqbox.css" />

   <script type="text/javascript" src="../scripts/ASTJavascript/astreeview/astreeview_packed.js"></script>    
    <link rel="stylesheet" type="text/css" href="../scripts/ASTJavascript/astreeview/astreeview.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/ASTJavascript/asdropdowntreeview/dropdowntreeview.css" />

    <style type="text/css">
        .auto-style1 {
            height: 130px;
        }
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="c_M" runat="server">
    <asp:UpdatePanel ID="u" runat="server">
        <ContentTemplate>

            <uc5:MessageBox ID="u_m" runat="server" />

            <div style="width: 100%">
                <div style="float: left;">
                </div>
            </div>

            <table style="border-spacing: 0px; width: 99.5%; height: 100%; max-height: 100%;">
                <tr>
                    <td style="vertical-align: top;" class="rightborder">

                        <cc1:CollapsiblePanelExtender ID="u_cp" runat="server" CollapseControlID="p_cp"
                            CollapsedImage="../images/close16.png" ExpandControlID="p_cp" ExpandedImage="../images/close16.png"
                            ImageControlID="img_f" SuppressPostBack="true" TargetControlID="pn_f"
                            Collapsed="false" ExpandDirection="Vertical">
                        </cc1:CollapsiblePanelExtender>
                        <asp:Panel ID="p_cp" runat="server" Style="margin-bottom: -17px; padding-left: -5px;">
                            <asp:Image ID="img_f" runat="server" ImageUrl="../images/close16.png" />
                        </asp:Panel>

                        <asp:Panel ID="pn_f" runat="server">
                            <table style="border-spacing: 0px; max-width: 800px; height: 100%">
                                <tr>
                                    <td style="vertical-align: top;" class="auto-style1">

                                        <asp:Panel ID="tbP" runat="server" CssClass="w-bar">

                                            <asp:LinkButton runat="server" ID="tbl_Search" CssClass="w-button" Style="background: url(../images/search32.png);" OnClick="OnSearch">
                                                <asp:Label ID="tbl_SearchLabel" runat="server"></asp:Label>
                                            </asp:LinkButton>

                                            <asp:LinkButton runat="server" ID="tbl_Customise" CssClass="w-button" Style="background: url(../images/customise32.png);" OnClientClick="return false;">
                                                <asp:Label ID="tbl_CustomiseLabel" runat="server"></asp:Label>
                                            </asp:LinkButton>

                                            <asp:LinkButton runat="server" ID="tbl_Clear" CssClass="w-button" Style="background: url(../images/clear32.png);" OnClick="OnClear">
                                                <asp:Label ID="tbl_ClearLabel" runat="server"></asp:Label>
                                            </asp:LinkButton>

                                        </asp:Panel>

                                        <uc1:EntityFilterControl ID="u_f" runat="server" />

                                    </td>
                                    <td style="vertical-align: top;" class="auto-style1">
                                        <asp:Panel ID="pn_g" runat="server" ScrollBars="Vertical">
                                            <cc4:MKGridView ID="dg_AS" runat="server" AllowSorting="True" AllowPaging="false"
                                                AutoGenerateColumns="False" BorderStyle="None" CellPadding="3" DataKeyNames="GuidId,Id"
                                                OnRowDataBound="OnRowDataBound" Width="400"
                                                OnSelectedIndexChanged="OnSelectedControl"
                                                OnSorting="OnGridSorting">
                                                <AlternatingRowStyle CssClass="alternatingrowstyle" />

                                                <HeaderStyle CssClass="headerstyle" Font-Bold="True" HorizontalAlign="Left" Wrap="False" />

                                                <Columns>
                                                    <asp:TemplateField Visible="false" HeaderStyle-Width="0">
                                                        <ItemTemplate>
                                                            <asp:HiddenField ID="hdGuidID" runat="server" Value='<%# Eval("GuidId") %>' />
                                                            <asp:HiddenField ID="hdId" runat="server" Value='<%# Eval("Id") %>' />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:CommandField HeaderText="Select" ShowSelectButton="True" />
                                                    <asp:ImageField DataImageUrlField="ImgUrl"></asp:ImageField>
                                                    <asp:BoundField DataField="DisplayID" HeaderText="elib_UniqueReference" SortExpression="Id"/>
                                                    <asp:BoundField DataField="Name" HeaderText="elib_Name" SortExpression="Name" />
                                                    <asp:BoundField DataField="State" HeaderText="elib_Group_State" SortExpression="State" ItemStyle-Width="160" />

                                                </Columns>

                                                <SelectedRowStyle BackColor="#D6E8FF" ForeColor="Black" />
                                            </cc4:MKGridView>
                                        </asp:Panel>
                                        <uc8:CheckListFlyout ID="u_Customise" runat="server" />
                                    </td>

                                </tr>
                            </table>
                        </asp:Panel>

                    </td>

                    <td style="width: 100%; vertical-align: top;">

                        <asp:Panel ID="pn_d" runat="server">
                            <asp:Panel ID="tb_main" runat="server" CssClass="w-bar" Style="margin-top: 0px; padding-left: 12px;">

                                <asp:LinkButton runat="server" ID="tbl_Details" CssClass="w-button" Style="background: url(../images/property32.png); " OnClick="OnDetails">
                                    <asp:Label ID="tbl_DetailsLabel" runat="server"></asp:Label>

                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_Changes" CssClass="w-button" Style="background: url(../images/history32.png); " OnClick="OnReviewChanges">
                                    <asp:Label ID="tbl_ChangesLabel" runat="server"></asp:Label>

                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_EffectivenessLog" CssClass="w-button" Style="background: url(../images/okc32.png); " OnClick="OnEffectivenessLog">
                                    <asp:Label ID="tbl_EffectivenessLogLabel" runat="server"></asp:Label>

                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_Comments" CssClass="w-button" Style="background: url(../images/note32.png); " OnClick="OnComments">
                                    <asp:Label ID="tbl_CommentsLabel" runat="server"></asp:Label>

                                </asp:LinkButton>

                            </asp:Panel>
                            <asp:Panel ID="tb_details" runat="server" CssClass="w-bar" Style="margin-top: 0px; padding-left: 12px;">
                                <asp:LinkButton runat="server" ID="tbl_Save" CssClass="w-button" Style="background: url(../images/save32.png); " OnClick="OnSave">
                                    <asp:Label ID="tbl_SaveLabel" runat="server"></asp:Label>
                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_ReviewChanges" CssClass="w-button" Style="background: url(../images/review_partial32.png); " OnClick="OnConsolidation">
                                    <asp:Label ID="tbl_ReviewChangesLabel" runat="server"></asp:Label>
                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_RejectChanges" CssClass="w-button" Style="background: url(../images/review_fail32.png); " OnClick="OnRjectChanges">
                                    <asp:Label ID="tbl_RejectChangesLabel" runat="server"></asp:Label>
                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_Archive" CssClass="w-button" Style="background: url(../images/archive32.png); " OnClick="OnChangeState">
                                    <asp:Label ID="tbl_ArchiveLabel" runat="server"></asp:Label>
                                </asp:LinkButton>

                                <asp:LinkButton runat="server" ID="tbl_Activate" CssClass="w-button" Style="background: url(../images/activate32.png); " OnClick="OnChangeState">
                                    <asp:Label ID="tbl_ActivateLabel" runat="server"></asp:Label>
                                </asp:LinkButton>
                            </asp:Panel>
                            <asp:Panel ID="pn" runat="server">
                                <table style="width: 100%">
                                    <tr>
                                        <td>

                                            <uc4:LabelEx ID="u_Id" runat="server" />

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>

                                            <uc3:MultilineTextBoxEx ID="u_Name" runat="server" />

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>

                                            <uc7:LinkButtonEx ID="u_State" runat="server" />

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <uc7:LinkButtonEx ID="u_Eff" runat="server" />
                                        </td>
                                    </tr>

                                </table>
                            </asp:Panel>
                            <asp:MultiView ID="mv" runat="server">
                                <asp:View ID="vd" runat="server">

                                    <asp:Panel ID="pn_meta" runat="server">
                                        <uc2:MetabaseViewer ID="mb" runat="server" />
                                    </asp:Panel>

                                </asp:View>
                                <asp:View ID="vc" runat="server">
                                    <h4 class="lineheader">
                                        <asp:Label runat="server" ID="lbl_CommentsHeader"></asp:Label></h4>
                                    <uc1:UserCommentsControl runat="server" ID="u_comments" />
                                </asp:View>
                                <asp:View ID="vr" runat="server">
                                    <h4 class="lineheader">
                                        <asp:Label runat="server" ID="lbl_ReviewChangesHeader"></asp:Label></h4>

                                    <table>

                                        <tr>
                                            <td>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <asp:CheckBox ID="mki_ShowHideFullRev" runat="server" AutoPostBack="true" OnCheckedChanged="OnShowHideFullRevisionHistory" />
                                                        </td>
                                                        <td>|
                                                        </td>
                                                        <td>
                                                            <span style="padding-top: 3px;">
                                                                <asp:ImageButton runat="server" ID="btn_Refresh" ImageUrl="../images/refresh16.png" OnClick="OnRefresh" /></span>
                                                        </td>
                                                    </tr>
                                                </table>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td>

                                                <cc4:MKGridView ID="dg_r" runat="server" AllowSorting="True" AllowPaging="false"
                                                    AutoGenerateColumns="False" BorderStyle="None" CellPadding="3"
                                                    OnRowDataBound="OnReviewChangesRowDataBound" Width="95%"
                                                    OnSorting="OnReviewChangesGridSorting">
                                                    <AlternatingRowStyle CssClass="alternatingrowstyle" />

                                                    <HeaderStyle CssClass="headerstyle" Font-Bold="True" HorizontalAlign="Left" Wrap="False" />

                                                    <Columns>
                                                        <asp:ImageField DataImageUrlField="ImgUrl"></asp:ImageField>
                                                        <asp:BoundField DataField="ChangeDate" HeaderText="ChangeDate" SortExpression="ChangeDate" />
                                                        <asp:BoundField DataField="ChangedByUser" HeaderText="ChangedBy" SortExpression="ChangedByUser" />
                                                        <asp:BoundField DataField="state" HeaderText="ReviewState" SortExpression="state" />
                                                        <asp:BoundField DataField="section" HeaderText="elib_Group_Origin" SortExpression="section" />
                                                    </Columns>

                                                    <SelectedRowStyle BackColor="#D6E8FF" ForeColor="Black" />
                                                </cc4:MKGridView>
                                                <asp:Label ID="lbl_NoChanges" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </asp:View>
                                <asp:View ID="ve" runat="server">
                                    <h4 class="lineheader">
                                        <asp:Label runat="server" ID="lbl_EffectivenessHeader"></asp:Label></h4>
                                    <asp:Panel ID="pn_tbeff" runat="server" CssClass="w-bar" Style="margin-top: 0px; padding-left: 12px;">
                                        <asp:LinkButton runat="server" ID="tbl_MarkAsEffective" CssClass="w-button" Style="background: url(../images/okc32.png); " OnClick="OnNewEffectiveComment">
                                            <asp:Label ID="tbl_MarkAsEffectiveLabel" runat="server"></asp:Label>
                                        </asp:LinkButton>
                                        <asp:LinkButton runat="server" ID="tbl_RetractComment" CssClass="w-button" Style="background: url(../images/error32.png); " OnClick="OnRetractComment">
                                            <asp:Label ID="tbl_RetractCommentLabel" runat="server"></asp:Label>
                                        </asp:LinkButton>

                                    </asp:Panel>
                                    <table>
                                        <tr>
                                            <td style="width: 100%">
                                                <cc4:MKGridView ID="dg_e" runat="server" AllowSorting="True" AllowPaging="false"
                                                    AutoGenerateColumns="False" BorderStyle="None" CellPadding="3" DataKeyNames="Id,UserID"
                                                    OnRowDataBound="OnEffectivenessRowDataBound" Width="95%"
                                                    OnSorting="OnEffectivenessGridSorting" OnSelectedIndexChanged="OnSelectedEffectivenessLog">
                                                    <AlternatingRowStyle CssClass="alternatingrowstyle" />

                                                    <HeaderStyle CssClass="headerstyle" Font-Bold="True" HorizontalAlign="Left" Wrap="False" />

                                                    <Columns>

                                                        <asp:TemplateField Visible="false" HeaderStyle-Width="0">
                                                            <ItemTemplate>
                                                                <asp:HiddenField ID="hdUserID" runat="server" Value='<%# Eval("UserID") %>' />
                                                                <asp:HiddenField ID="hdID" runat="server" Value='<%# Eval("ID") %>' />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:CommandField HeaderText="Select" ShowSelectButton="True" />
                                                        <asp:ImageField DataImageUrlField="ImgUrl"></asp:ImageField>
                                                        <asp:BoundField DataField="LogDate" HeaderText="Date_" SortExpression="LogDate" ItemStyle-Width="150" />
                                                        <asp:BoundField DataField="User" HeaderText="User" SortExpression="User" ItemStyle-Width="100" />
                                                        <asp:BoundField DataField="Comments" HeaderText="Comments_" SortExpression="Comments" />
                                                        <asp:BoundField DataField="Effectiveness" HeaderText="elib_Effectiveness" SortExpression="Effectiveness" />
                                                    </Columns>

                                                    <SelectedRowStyle BackColor="#D6E8FF" ForeColor="Black" />
                                                </cc4:MKGridView>
                                                <uc6:MarkEffectiveControl ID="u_newLog" runat="server" />
                                                <asp:Label ID="lbl_NoEffectivenessRecords" runat="server"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </asp:View>
                            </asp:MultiView>
                        </asp:Panel>
                    </td>

                </tr>
            </table>

            <script type="text/javascript">

                var prm = Sys.WebForms.PageRequestManager.getInstance();

                function BeginRequestHandler(sender, args) {
                }

                function EndRequestHandler(sender, args) {
                    getWidth(screen.width)
                }

                prm.add_beginRequest(BeginRequestHandler);
                prm.add_endRequest(EndRequestHandler);

                function getWidth(width) {
                    try {
                        if ($get('<%:pn_d.ClientID%>').scrollHeight > 400)
                            $get('<%:pn_g.ClientID%>').style.height = $get('<%:pn_d.ClientID%>').scrollHeight + 'px';
                    }
                    catch (err){ };

                }

            </script>

            <asp:UpdateProgress ID="pr" runat="server" AssociatedUpdatePanelID="u" DisplayAfter="200">
                <ProgressTemplate>
                    <div class="UpdateProgressBackground">
                        <center>
                            <div class="UpdateProgressContent">
                                <h3>
                                    <asp:Label ID="lbl_Wait" runat="server"></asp:Label></h3>

                                <br />
                                <img src="../images/ajax.gif" alt="" />
                            </div>
                        </center>
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
        </ContentTemplate>
    </asp:UpdatePanel>

        <script>

                try {
                    $(document).ready(function () {

                        var xPos1, yPos1, timer1;

                        var prm = Sys.WebForms.PageRequestManager.getInstance();
                        prm.add_beginRequest(BeginRequestHandler);
                        prm.add_endRequest(EndRequestHandler);

                        function BeginRequestHandler(sender, args) {

                            try {
                                yPos1 = $(window).scrollTop();
                            } catch (err) { }
                        }

                        function EndRequestHandler(sender, args) {
                            try {
                                $(window).scrollTop(yPos1);
                                timer1 = window.setTimeout(function () { $(window).scrollTop(yPos1); }, 100);

                                $(window).scrollTop(yPos1);
                            }
                            catch (err) { }
                        }

                    });
                }
                catch (err) { }

    </script>

</asp:Content>
