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

    File:               mySlnkIMG.asp
    Description:        Selecteer een ruimte van een verdieping uit een plaatje
    Parameters:
        vKey            required: ALG_VERDIEPING.ALG_VERDIEPING_KEY
    Context:
    Note:
*/
%>
<!--#include file='../Shared/common.inc'-->
<!--#include file='../CAD/FGII.inc'-->
<!--#include file="../SlnkDWF/Slnk2IMG.inc" -->

<%
var stdm_key = getQParamInt("stdm_key", -1);
var pvKey = getQParamInt("ver_Key");
var thema_key = getQParamInt("thema", -1);
var discs = getQParamIntArray("discs", []);
var srtgs = getQParamIntArray("srtgs", []);
var srtds = getQParamIntArray("srtds", []);
if (discs.length > 0 && discs[0] == -1)
    discs.shift();
if (srtgs.length > 0 && srtgs[0] == -1)
    srtgs.shift();
if (srtds.length > 0 && srtds[0] == -1)
    srtds.shift();

var sql = "SELECT DISTINCT d.ins_discipline_key"
        + " FROM fac_v_my_disciplines m, ins_v_aanwezigdiscipline d, ins_disc_params dp "
        + " WHERE d.ins_discipline_key=m.ins_discipline_key"
        + "   AND d.ins_discipline_min_level = 1"
        + "   AND dp.ins_disc_params_cadlayers IS NOT NULL"
        + "   AND BITAND(dp.ins_disc_params_type, 1) > 0" // binnen
        + "   AND BITAND(dp.ins_disc_params_type, 4) > 0" // default aan
        + "   AND dp.ins_discipline_key = d.ins_discipline_key"
        + "   AND fac_functie_code IN ('WEB_INSUSE')"
        + "   AND prs_perslid_key = " + user_key;
var oRs = Oracle.Execute(sql);
while (!oRs.Eof)
{
    discs.push(oRs("ins_discipline_key").Value);
    oRs.MoveNext();
}
oRs.Close();

if (S("fg_publiclayers").length)
   discs = discs.concat(S("fg_publiclayers"));
%>
<html>
  <head>
    <% FCLTHeader.Generate(); %>
<script type='text/javascript'>
function init()
{
  MMap.Reset();
  MMap.SetIMGGenerator("../CAD/mySlnk2IMG.asp");
  MMap.SetLabelPosition(<%=S("fg_labelPosition")%>);
  MMap.SetPaperColor(<%=S("fg_paperColor")%>);
  MMap.SetCustomParameters("&mode=0&scenario_key=0"
                          + "&stdm_key=<%=stdm_key%>"
                          + "&vKey=<%=pvKey%>"
                          + "&discs=<%=discs.join(",")%>"
                          + "&srtgs=<%=srtgs.join(",")%>"
                          + "&srtds=<%=srtds.join(",")%>"
                          + "&thema=<%=thema_key%>");
  MMap.Refresh(true); // Try to zoom extents
}

var done=false;
function MMap_onClick(SlnkEvent)
{
  if (done) return; // Workaround for nasty recursion? We komen hier twee keer?
  done = true;
  // FcltMgr.alert("Geklikt op X=" + SlnkEvent.dwgX + " Y=" + SlnkEvent.dwgY + " ik denk ruimte " + SlnkEvent.ContourKey)
  var res_data = {};
  if (SlnkEvent.ContourLayer == "SLNK Contours")
  {
    res_data = { rui_key: SlnkEvent.Key,
                 rui_txt: SlnkEvent.DbLabel,
                 rui_dwgX: SlnkEvent.dwgX,
                 rui_dwgY: SlnkEvent.dwgY
               };
  }
  else if (SlnkEvent.ContourLayer == "SLNK Symbols")
  {
    res_data = { ins_key: parseInt(SlnkEvent.ContourKey.substr(2)) }; // I:20961 parsen
  }
  FcltMgr.closeDetail(window, res_data);
}

</script>
</head>

<body class='fclt-modal' id='docBody' onLoad='javascript:init();'>
  <!-- ==========================
       HET plaatje zonder buttons
  ============================ -->
  <iframe id="MMap" name="MMap" src="../SlnkDWF/ToonIMG.asp"
    frameborder='0' framespacing='0' scrolling="no"
    style="border-width:3;border-style=solid" width="100%"  height="100%" valign="center">
  </iframe>
</body>
</html>
<% ASPPAGE_END(); %>
