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

    File:           alg_terreinsector
    Description:    Terreinsector wrapper

    Parameters:

    Context:
    Note:

*/ %>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->

<%
FCLTHeader.Requires({plugins:["jQuery", "suggest"], // suggest voor alg_edit_terreinsector.asp
                     js: []})

var ter_key = getQParamInt("ter_key", -1);

if (ter_key > 0)
{
    sql = "SELECT t.alg_terreinsector_code, "
        + "       l.alg_locatie_code "
        + "  FROM alg_terreinsector t, "
        + "       alg_locatie l "
        + " WHERE t.alg_terreinsector_key = " + ter_key
        + "   AND t.alg_locatie_key = l.alg_locatie_key ";

   oRs = Oracle.Execute(sql);

   var loc_code = oRs("alg_locatie_code").value;
   var ter_code = oRs("alg_terreinsector_code").value;

   var ter_naam   = " " + loc_code + "-" + ter_code;
}
else
{
  var ter_naam = "";
}
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      FcltMgr.setTitle("<%=L("lcl_terra")%> <%=safe.jsstring(ter_naam)%> ", {hot: false});
<%    if (ter_key == -1) { %>FcltMgr.startEdit(window);<% } %>
      function algClose(params)
      {
          <% if (ter_key == -1)
             { %>
              if (params.cancel)
              {
                  FcltMgr.closeDetail(window, params );
                  return true;
              }
              if (!params.keepForm)
                  window.location.href = "alg_terreinsector.asp?verynew=1&ter_key=" + params.ter_key;
          <% } else { /* Bestaande terreinsector bewerkt, switch naar show-mode */ %>
              if (params.close)
              {
                FcltMgr.closeDetail(window, { close: true})
              }
              if (!params.keepForm)
                  $("#algFrame")[0].src = "alg_show_terreinsector.asp?ter_key=<%=ter_key%>";
          <% } %>
      }
    </script>
  </head>

  <body>
<%  if (ter_key == -1)
      var page = "alg_edit_terreinsector.asp"; // Maak een nieuw
    else
      var page = "alg_show_terreinsector.asp";
    page += "?ter_key=" + ter_key;

    IFRAMER("algFrame", page, { title: L("lcl_alg_terreinsector_frame"),
                                initHeight: "450px",
                                FcltClose: "algClose" } );
%>
  </body>
</html>
