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

    File:           alg_gebouw.asp
    Status:
    Description:

    Parameters:

    Context:
    Note:

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

<%
FCLTHeader.Requires({plugins:["suggest","jQuery"], js: ["jquery-ui.js"]})

var bld_key = getQParamInt("key", -1);

if (bld_key > 0)
{
      sql = " select alg_gebouw_code, alg_locatie_key "
          + "  FROM alg_gebouw "
          + "  WHERE alg_gebouw_key = " + bld_key;

   oRs = Oracle.Execute(sql);

   var bld_name   = " " + oRs("alg_gebouw_code").value;
   var loc_key = oRs("alg_locatie_key").value;
}
else
{
  var bld_name = "";
  var loc_key = -1;
}

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      FcltMgr.setTitle("<%=L("lcl_building")%> <%=safe.jsstring(bld_name)%>", {hot:false});
<%    if (bld_key == -1) { %>FcltMgr.startEdit(window);<% } %>
      function algClose(params)
      {
          <% if (bld_key == -1)
             { %>
              if (params.cancel)
              {
                  FcltMgr.closeDetail(window, params );
                  return true;
              }
              if (!params.keepForm)
                  window.location.href = "alg_gebouw.asp?verynew=1&key=" + params.bld_key;
          <% } else { /* Bestaand gebouw bewerkt, switch naar show-mode */ %>
              if (params.close)
              {
                FcltMgr.closeDetail(window, { close: true})
              }
              if (!params.keepForm)
                  $("#algFrame")[0].src = "alg_show_gebouw.asp?bld_key=<%=bld_key%>";
          <% } %>
      }
    </script>
  </head>

  <body>
<%  if (bld_key == -1)
        var page="alg_edit_gebouw.asp"; // Maak een nieuw
    else
        var page="alg_show_gebouw.asp";
    page += "?bld_key="+bld_key;

    IFRAMER("algFrame", page, { title: L("lcl_alg_gebouw_frame"),
                                initHeight: "450px",
                                FcltClose: "algClose" } );
                                
    if (bld_key > -1)
    {
      var authparamsCNTUSE = user.checkAutorisation("WEB_CNTUSE", true);
      var authparamsCNTMAN = user.checkAutorisation("WEB_CNTMAN", true);
      var curole = "bo";
      
      if (!authparamsCNTMAN && authparamsCNTUSE)
        curole = "fe";
            
      if (authparamsCNTMAN || authparamsCNTUSE)
      {
          var page1="../cnt/cnt_search_list.asp?embedded=1&tiny=1&collapsed=1&urole=" + curole + "&ffutu=1&fact=1&frap=1&fopz=1&sact=1&loc_key="+ loc_key + "&bld_key=" + bld_key
          IFRAMER("cntFrame", page1, { initHide: true } );
      }
    }                                
%>
  </body>
</html>
