<%@language="javascript"%>
<% /*
     $Revision$
     $Id$

     File:          terms.asp
     Description:   Laat de user de algemene voorwaarden accepteren alvorens in te loggen
     Context:       Modal vanuit bepaalde schermen, submit naar terms_save.asp?

     NOTE:          Men moet algemene voorwaarden accepteren indien deze aanwezig zijn.
*/ %>
<%
var TERMS_CONDITIONS_OK = true;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/flexfiles.inc" -->
<%
    var readonly = user.terms_version() == L("lcl_terms_filename");

    var flexparam = flexProps("BDRADR", null, null, null, { getFile: L("lcl_terms_filename") });
    if (!flexparam.files.length)
        abort_with_warning(L("lcl_internal_error") + "\n" + L("lcl_terms_filename") + " not found");

    var termsFile = flexparam.AttachPath + flexparam.files[0].name;
    var ftekst = fso.OpenTextFile(termsFile);
    var tekst = ftekst.ReadAll();
    ftekst.Close();
%>
<html id="termshtml" cla>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript">

        function terms_accepted_callback(json)
        {
          <% if (readonly) { %>
              FcltMgr.closeDetail();
          <% } else { %>
              window.top.location.href = "<%=safe.jsstring(rooturl + "/")%>";
          <% } %>
        }

        function doAccept()
        {
            if (!($("input.trm_acc").prop("checked")))
                return;

            $.post($("form[name=u2]")[0].action, $("[name=u2]").serialize(), FcltCallbackAndThen(terms_accepted_callback), "json");
        }

        function toggleNext()
        {
            var vis = $("li.next").css("visibility");
            $("li.next").css("visibility", (vis == "hidden" ? "visible" : "hidden"));
        }

        $(function()
        {
            $(".fcltblocktab .terms").css("height", $(window).height() * .8);
            $("li.next").css("visibility", "hidden");
            $("input.trm_acc").on("click", toggleNext);
            FcltMgr.resized();
        });

    </script>
  </head>

  <body class="fclt-modal" id="mod_prs_termscond">
    <% MODAL_START(); %>
    <form action="terms_save.asp?submit=1" method="post" name="u2">
<%
      MODAL_BLOCK_START("prsAV", L("lcl_terms_conditions"), { "icon": "fa-clipboard-list-check" });
      %><tr><td><div id='terms'><%
        Response.Write(safe.html(tekst));
      %></div></td></tr><%
      if (!readonly)
        RWCHECKBOXTR("termsAcc", "trm_acc", L("lcl_terms_accept") + " " + L("lcl_terms_conditions") , null, { boxfirst: true } );
      MODAL_BLOCK_END();
      IFACE.FORM_END();
%>
    </form>
<%
      var buttons = [];
      if (!readonly)
        buttons.push({title: L("lcl_terms_volgende"), xclass: "next", action:"doAccept()", icon: "fa-check"});

      SIMPLE_BLOCK_START();
        CreateButtons(buttons);
      SIMPLE_BLOCK_END();
%>
<% MODAL_END(); %>
  </body>
</html>

<% ASPPAGE_END(); %>
