<%@ Page Title="" Language="C#" MasterPageFile="~/SiteMaster.Master" AutoEventWireup="true" CodeBehind="SearchSystemPage.aspx.cs" Inherits="MKInsight.Online.RRAM2.Support.SearchSystemPage" %>

<%@ Register Src="../UIControls/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="../UIControls/MessageBox.ascx" TagName="MessageBox" TagPrefix="uc2" %>
<%@ Register Assembly="UIWebControls" Namespace="UIWebControls" TagPrefix="cc4" %>
<%@ Register Src="../UIControls/Interface/SimpleSectionBreak.ascx" TagName="SimpleSectionBreak" TagPrefix="uc3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" src="../scripts/jquery/jquery_min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.box-min.js"></script>

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

<%--    <style>
        mark {
            background: yellow;
        }

            mark.current {
                background: orange;
            }

        .headersearch {
            padding: 10px;
            width: 100%;
            background: #eee;
            top: 0;
            left: 0;
        }

        .content {
            margin-top: 50px;
        }
    </style>
    <script>
        $(function () {

            // the input field
            var $input = $("input[type='search']"),
                // clear button
                $clearBtn = $("button[data-search='clear']"),
                // prev button
                $prevBtn = $("button[data-search='prev']"),
                // next button
                $nextBtn = $("button[data-search='next']"),
                // the context where to search
                $content = $(".content"),
                // jQuery object to save <mark> elements
                $results,
                // the class that will be appended to the current
                // focused element
                currentClass = "current",
                // top offset for the jump (the search bar)
                offsetTop = 50,
                // the current index of the focused element
                currentIndex = 0;

            /**
             * Jumps to the element matching the currentIndex
             */
            function jumpTo() {
                if ($results.length) {
                    var position,
                        $current = $results.eq(currentIndex);
                    $results.removeClass(currentClass);
                    if ($current.length) {
                        $current.addClass(currentClass);
                        position = $current.offset().top - offsetTop;
                        window.scrollTo(0, position);
                    }
                }
            }

            /**
             * Searches for the entered keyword in the
             * specified context on input
             */
            $input.on("input", function () {
                var searchVal = this.value;
                $content.unmark({
                    done: function () {
                        $content.mark(searchVal, {
                            separateWordSearch: true,
                            done: function () {
                                $results = $content.find("mark");
                                currentIndex = 0;
                                jumpTo();
                            }
                        });
                    }
                });
            });

            /**
             * Clears the search
             */
            $clearBtn.on("click", function () {
                $content.unmark();
                $input.val("").focus();
            });

            /**
             * Next and previous search jump to
             */
            $nextBtn.add($prevBtn).on("click", function () {
                if ($results.length) {
                    currentIndex += $(this).is($prevBtn) ? -1 : 1;
                    if (currentIndex < 0) {
                        currentIndex = $results.length - 1;
                    }
                    if (currentIndex > $results.length - 1) {
                        currentIndex = 0;
                    }
                    jumpTo();
                }
            });
        });
    </script>--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="c_M" runat="server">

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


            <uc1:Header ID="u_h" runat="server" />

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

            <table>
                <tr>
                    <td>
                        <asp:Label ID="lbl_Phrase" runat="server"></asp:Label>
                    </td>
                    <td colspan="2">


                        <asp:TextBox ID="txt_SearchPhrase" Width="400" runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <asp:Button ID="btn_Search" runat="server" OnClick="OnSearchSystem" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <hr class="ee" />
                    </td>
                </tr>
                <tr>
                    <td style="vertical-align: top;">
                        <asp:Label ID="lbl_Options" runat="server"></asp:Label>
                    </td>
                    <td style="vertical-align: top;">
                        <asp:CheckBox runat="server" ID="chk_ExactPhrase" AutoPostBack="True" OnCheckedChanged="OnExcatPhraseChanged" /><br />
                        <asp:CheckBox runat="server" ID="chk_IncludeAllWords" /><br />
                    </td>
                    <td style="vertical-align: top;">
                        <asp:CheckBox runat="server" ID="chk_SearchLogs" /><br />
                        <asp:CheckBox runat="server" ID="chk_SearchAuditTrails" /><br />
                        <asp:CheckBox runat="server" ID="chk_SearchDeleted" /><br />
                    </td>

                    <td style="vertical-align: top;">
                        <asp:CheckBox ID="chk_Unrestricted" runat="server" />
                    </td>

                </tr>
            </table>
            <div>

                <uc3:SimpleSectionBreak ID="u_search" runat="server" />

            </div>
           <%-- <div>

                <div class="headersearch">
                    Search:
                    <input type="search" placeholder="type here">
                    <button data-search="next">&darr;</button>
                    <button data-search="prev">&uarr;</button>
                    <button data-search="clear">✖</button>
                </div>

             
            </div>--%>
            <div class="content">


                <cc4:MKGridView ID="dg_logs" runat="server" AllowPaging="false" AllowSorting="True" AutoGenerateColumns="False"
                    BorderStyle="None" CellPadding="3" PageSize="100"
                    OnRowDataBound="OnRowDataBound" Width="95%">
                    <AlternatingRowStyle CssClass="alternatingrowstyle" />
                    <FooterStyle BackColor="White" ForeColor="#000066" />
                    <HeaderStyle CssClass="headerstyle" Font-Bold="True" HorizontalAlign="Left" Wrap="False" />
                    <PagerStyle HorizontalAlign="Left" />
                    <Columns>

                        <asp:TemplateField>
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField ItemStyle-Width="32">
                            <ItemTemplate>
                                <img enableviewstate="true" alt="Open in new window" onclick="$.colorbox({ transition: 'none', width: '40%', height: '40%', iframe: true,href:'SearchSystemFileFrameWindow.aspx?id=<%#DataBinder.Eval(Container.DataItem,"BinaryId")%>' }); return false;"
                                    src="../images/windows16.png" style="cursor: pointer;" />

                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:BoundField DataField="BinaryId" HeaderText="BinaryId" />
                        <asp:BoundField DataField="Matched" HeaderText="Matched" />
                        <asp:BoundField DataField="Type" HeaderText="Type" />
                        <asp:BoundField DataField="Field" HeaderText="Field" />
                        <asp:BoundField DataField="Context" HeaderText="Context" />

                    </Columns>
                    <PagerTemplate>
                        <asp:Label ID="lbl_ShowRows" runat="server" Text="Show rows:" /><asp:DropDownList
                            ID="ddlPageSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="OnSelectedIndexChanged">

                            <asp:ListItem Value="100" />
                            <asp:ListItem Value="150" />
                            <asp:ListItem Value="250" />
                            <asp:ListItem Value="500" />
                            <asp:ListItem Value="1000" />
                        </asp:DropDownList>
                        &#160;&#160;<asp:Label ID="lbl_page" runat="server" Text="Page" />
                        <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" CssClass="gotopage"
                            OnTextChanged="GoToPageOnTextChanged" />
                        <asp:Label ID="lbl_Of" runat="server" Text="of" />
                        <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                        &nbsp;&nbsp;<asp:Button ID="btn_p" runat="server" CommandArgument="Prev" SkinID="_" CommandName="Page"
                            CssClass="previous" ToolTip="Previous Page" /><asp:Button ID="btn_n" runat="server"
                                CommandArgument="Next" SkinID="_" CommandName="Page" CssClass="next" ToolTip="Next Page" />
                    </PagerTemplate>
                    <SelectedRowStyle BackColor="#D6E8FF" ForeColor="Black" />
                </cc4:MKGridView>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="prz" runat="server" AssociatedUpdatePanelID="up_a" DisplayAfter="20" DynamicLayout="true">

        <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>
</asp:Content>
