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

    File:               evictionplan.asp
    Description:        Toon verdiepingsgerelateerde tekening van (bv) vluchtplan
    Parameters:         -
    Context:            Called from portal
    Note:               De tekening staat in een andere directory (S("fg_vlucht_path")) maar moet dezelfde bestandsnaam hebben
                        als de gewone FG plattegrondtekening.
                        Als je schrijfrechten hebt, kun je hier bestanden uploaden
*/
 %>
<!--#include file="../Shared/common.inc" -->
<!--#include file="../Shared/iface.inc"-->
<!--#include file="../Shared/plaatsselector.inc"-->
<%
  FCLTHeader.Requires({ plugins: [],
                        js: ["jQuery-ui.js"],
                        css: []});

  FACPageTitle =L("lcl_eviction_plan_h") ;
  var authparams = user.checkAutorisation("WEB_CADUSE");
  var floor_key = getQParamInt("floor_key", user.alg_verdieping_key());

  // Ik zoek of ik deze verdieping mag muteren.
  authparams2 = user.checkAutorisation("WEB_CADFOF", true);
  // Ik versimpel nu: ik mag uploaden als ik dat voor alles mag (centraal beheer)
  // moet later indien wenselijk 3D op basis van floor_key bepaald worden
  var canUpload = (authparams && authparams.ALGwritelevel==-1);

%>
<html>
<head>
<%
   FCLTHeader.Generate();
%>
<script type="text/javascript">
<% if (canUpload) { %>
function Upload()
{
    var url = "<%=protectQS.create("../../appl/shared/BijlagenForm.asp?module=FGIIV&key=" + floor_key)%>";
    FcltMgr.openModalDetail(url, "",
                  { callback: FcltMgr.reload } );
}
<% } %>

function myRefresh(numFlr, dwfName)
{
    MMap.Reset();
    MMap.SetIMGGenerator("../CAD/mySlnk2IMGEv.asp");
    MMap.SetPaperColor(<%=S("fg_paperColor")%>);
    MMap.SetCustomParameters("&vKey=" + numFlr + "&dwfName=" + escape(dwfName));
    MMap.Refresh(true); // Do zoom extents
}

function OnFloorChanged()
{
    floor_key = $("#verdiepingkey").val();
    //myRefresh(floor_key);
    // herlees het rijtje tekeningen
    window.location.href = "../CAD/EvictionPlan.asp?floor_key=" + floor_key;
}

function resizeIframes()
{
    var height = parseInt(document.documentElement.clientHeight);
    document.getElementById('MMap').style.height = (height-5) +"px";
};

function init()
{
    resizeIframes();
    onOtherDrawing();
    var timerID=null;
    window.onresize = function()
    {
    	if (timerID) clearTimeout(timerID);
        timerID = setTimeout(resizeIframes, 100);// use a delay for IE because the resize event fires repeatly
    }
}

function onOtherDrawing()
{
    var floor_key = $("#verdiepingkey").val();
    var sel = document.getElementById("sDocuments");
    dwf = "";
    if (sel && sel.options.length > 0)
    {
        dwf = sel.options[sel.selectedIndex].text;
    }
    myRefresh(floor_key, dwf);
}

</script>
</head>

<body onload="init()">

 <table id='maintable' width="100%" height="100%" >
      <tr>
        <td id="LinkerNavi">
          <table>
            <%
             FCLTplaatsselector(authparams.ALGreadlevel, {no_table: true,
                                                          compact: true,
                                                          locatiekey: user.alg_locatie_key(),
                                                          gebouwkey: user.alg_gebouw_key(),
                                                          verdiepingkey: floor_key,
                                                          startlevel: 2, // Locatie
                                                          eindlevel: 4, // Verdieping
                                                          onVerChange: "OnFloorChanged()"
                                                        });
            %>
            <tr>
            <td>
                <%
                    if (canUpload)
                    {
                       CreateButtons([ { title: L("lcl_fg_upload"), action: "Upload();" }]);
                    }
                    else
                        Response.Write("<p>&nbsp;</p>");
                %>
            </td>
        </tr>
<%
      var pathName = S("fg_vlucht_path") + "/V" + floor_key;
      var fso = new ActiveXObject("Scripting.FileSystemObject");
      if (fso.FolderExists(pathName) )
      {
%>
        <tr>
            <td>
                <label><%=L("lcl_eviction_tekeningen")%></label>
                <select id="sDocuments" size="20" style="width:180" onchange="onOtherDrawing(this)">
                <%
                         var f1 = fso.GetFolder(pathName);
                         var fc4 = new Enumerator(f1.files);
                         var nn = 0;
                         for (; !fc4.atEnd(); fc4.moveNext())
                         {
                             var vTekening0 = fc4.item().Name;
                             if (vTekening0.match(/.dwf$/i))
                             {
                %>    <option <%=nn==0?" SELECTED='1'":""%>><%=Server.HTMLEncode(vTekening0)%></option>
                <%
                             }
                             nn ++;
                         }
                %>
                </select>
            </td>
        </tr>
<%
      }
%>
        </table>
        </td>
        <!-- DE Plattegrond -->
        <td id="RechterMap" align="right" id="mapCell" style="border:1px solid black; ">
            <iframe id="MMap" name="MMap" src='../SlnkDWF/ToonIMG.asp?ShowButtons'
                frameborder='0' framespacing='0' scrolling='no' width='100%' height='100%' valign='center'>
            </iframe>
        </td>
      </tr>
</table>
</body>

</html>
