<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Search.aspx.cs" Inherits="Tjenestetorget.Administrator.Search"
    MasterPageFile="~/Site.master" %>

<%@ Register Src="SearchTemplateResult.ascx" TagName="SearchTemplateResult" TagPrefix="uc2" %>
<%@ Register Src="SearchInstanceResult.ascx" TagName="SearchInstanceResult" TagPrefix="uc3" %>
<%@ OutputCache Location="None" %>
<%@ Register Src="SearchCriteria.ascx" TagName="SearchCriteria" TagPrefix="uc1" %>

<asp:Content ID="content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="skjema-admin__page-pre-title">
        Innsendte skjema
    </div>
    <h1 class="skjema-admin__page-title mt-0">
        Statistikk og data
    </h1>
    <uc1:SearchCriteria ID="SearchCriteria1" runat="server" OnUpdated="SearchCriteria1_Updated" />

    <div id="divTabs" style="margin-top: 40px;"><!-- hvorfor funker ikke skjema-admin__mt-40? -->
        <div class="skjema-admin__tabs" style="margin-bottom: 20px;">
            <button id="oversiktOgSkjemadata" class="skjema-admin__tabs__tab skjema-admin__tabs__tab--active skjema-admin__mr-40" 
                type="button" 
                data-jscomponent="tabToggle" 
                data-tab-id="1">
                Oversikt og skjemadata
            </button>

            <button id="unikeInnsendinger" class="skjema-admin__tabs__tab skjema-admin__mr-40" 
                type="button" 
                data-jscomponent="tabToggle" 
                data-tab-id="2">
                Unike innsendinger
            </button> 
        </div>

        <div class="mb-5">
            <div data-jscomponent="tabPanel" data-tab-id="1">
               <div>
                   <uc2:SearchTemplateResult ID="SearchTemplateResult1" runat="server" />
                </div>
            </div>

            <div class="d-none" data-jscomponent="tabPanel" data-tab-id="2">
                <div>
                    <uc3:SearchInstanceResult ID="SearchInstanceResult1" runat="server" />
                </div>
            </div>
        </div>
    </div>

    <script>
    document.addEventListener("DOMContentLoaded", function () {

        $(document).ready(function () {
            
            var btnOversiktOgSkjemadata = sessionStorage.getItem("btnOversiktOgSkjemadata");
            var btnUnikeInnsendinger = sessionStorage.getItem("btnUnikeInnsendinger");

            if (btnOversiktOgSkjemadata == "true") {
                $("#oversiktOgSkjemadata").click();
            }

            if (btnUnikeInnsendinger == "true") {
                $("#unikeInnsendinger").click();
            }

            $('#oversiktOgSkjemadata').on('click', function (evt) {
                //alert('funker');
                sessionStorage.setItem("btnOversiktOgSkjemadata", "true");
                sessionStorage.setItem("btnUnikeInnsendinger", "false");
            });

            $('#unikeInnsendinger').on('click', function (evt) {
                //alert('funker 2');
                sessionStorage.setItem("btnUnikeInnsendinger", "true");
                sessionStorage.setItem("btnOversiktOgSkjemadata", "false");
            });
 
        });
    });
    </script>
    
</asp:Content>