<%@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 pvKey = getQParamInt("ver_Key");
    var discs = getQParamIntArray("discs", []);
    if (discs.length > 0 && discs[0] == -1)
        discs.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.SetStyleSheet("<%=custpath%>/cust.css");
    MMap.SetCustomParameters("&mode=0&scenario_key=0&vKey=<%=pvKey%>&discs=<%=discs.join(",")%>");
    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;
    //alert("Geklikt op X=" + SlnkEvent.dwgX + " Y=" + SlnkEvent.dwgY + " ik denk ruimte " + SlnkEvent.ContourKey)
    FcltMgr.closeDetail( window,
                         { rui_key: SlnkEvent.Key,
                           rui_txt: SlnkEvent.DbLabel
                         });
}

</script>
</head>

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