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

    File:               ToonIMG.asp
    Description:
    Parameters:
        ShowButtons     Shows default button set
    Context:
*/
%>
<!--#include file="../Shared/common.inc"-->
<!--#include file="../Shared/iface.inc"-->
<!-- #INCLUDE FILE="./SLNKDWF.inc" -->
<%
  FCLTHeader.Requires({ plugins: ["jQuery"],
                        js: ["jquery-ui.js", "./toonimg.js"],
                        css: ["./SLNKDwf.css"]});

var minDLL_VERSION_MAJOR = "4"
var minDLL_VERSION_MINOR = "16"

// Version check
try
{
    var _oAbout = Server.CreateObject('SLNKDWF.About');
    var dllMinor = _oAbout.VersionMinor
    var dllMajor = _oAbout.VersionMajor
    var dllPath = _oAbout.DLLPath;
    var fullPath = dllPath
}
catch (ee)
{
    SLNKDWFError("Unable to activate SLNKDWFx64.DLL at the webserver.\n" + ee.description);
}
if (typeof(dllMajor) == 'undefined' ||
    dllMajor < minDLL_VERSION_MAJOR ||
    dllMajor == minDLL_VERSION_MAJOR && dllMinor < minDLL_VERSION_MINOR)
{
    SLNKDWFError(fullPath + " is an too old version. Version v" + minDLL_VERSION_MAJOR + "." + minDLL_VERSION_MINOR + " is required.");
}

var ShowButtons    = getQParamInt("ShowButtons", 0) == 1;
var ShowLabelMenu  = getQParamInt("ShowLabelMenu", 0) == 1;

%>
<html style="height:100%;">
<head>
    <% FCLTHeader.Generate(); %>
    <script type="text/javascript">
        var SLNKMinMax,lastDWFfile;
<% if (user.checkAutorisation("WEB_PRSSYS", true)) { %>
        function SLNKAbout()
        {
            var version = "SLNKDWF <%=safe.jsstring(dllMajor+"."+dllMinor)%>"
                        + "\n\n(c) 2005-" + new Date().getFullYear() + " Aareon Nederland B.V.";
            if (gSLNKEvent && gSLNKEvent.success)
            {
                var accuracy = Math.max(0, 1-(Math.log(gSLNKEvent.scaleX)/Math.log(10)));

                version += "\n\n("+gSLNKEvent.viewminX.toFixed(accuracy)+","+gSLNKEvent.viewminY.toFixed(accuracy) +")";
                version +=   " -("+gSLNKEvent.viewmaxX.toFixed(accuracy)+","+gSLNKEvent.viewmaxY.toFixed(accuracy) + ")";
                version += " ="+(gSLNKEvent.viewmaxX-gSLNKEvent.viewminX).toFixed(accuracy)+"x"+
                                (gSLNKEvent.viewmaxY-gSLNKEvent.viewminY).toFixed(accuracy);
                version += " (~" + ((gSLNKEvent.viewmaxX-gSLNKEvent.viewminX)*(gSLNKEvent.viewmaxY-gSLNKEvent.viewminY)/1e6).toFixed(1) + "m2)";

            }
            FcltMgr.alert(version);
        }
<% } %>
       function setPanMode(panmode, pthis)
       {
          SetPanMode(panmode);
          setActive(pthis.id);
       }

       function setActive(pid)
       {
          // reset alle bekende buttons
          $("#navbuttons span").not('[data-toggleonly="true"]').removeClass("active");
          // en set de ene (als het een button was)
          if (pid)
                $("#"+pid).addClass("active");
       }
    </script>
</head>
<%
    var evtres = "onresize=\"scheduleRefresh()\"";
    var agent = String(Request.ServerVariables("HTTP_USER_AGENT"));
    if (agent.indexOf("iPad") != -1)
        evtres = ""; // geeft ongewenste resize bij uitzoomen

    // TODO in scenario_mode is het prj_fg_papercolor ipv fg_paperColor op zich, maar dat weet ik niet?
    //var customColor = parseInt(S("prj_fg_papercolor"),10) > 0x010101 && parseInt(S("prj_fg_papercolor"),10) < 0xFEFEFE;
    var customColor = parseInt(S("fg_paperColor"),10) > 0x010101 && parseInt(S("fg_paperColor"),10) < 0xFEFEFE;
    var menuoptions =
    [
      {id:"ImgArrow",       alt:"Info",            label: L("lcl_slnk_select"),             onClick: "setPanMode(1,this)",                  icon: "fa-mouse-pointer",   button: 1, menu: 0 },
      {id:"ImgPan",         alt:"Pan",             label: L("lcl_slnk_pan"),                onClick: "setPanMode(0,this)",                  icon: "fa-hand-pointer",    button: 0, menu: 0 },
      {id:"ImgZoomWin",     alt:"Zoom Window",     label: L("lcl_slnk_zoomrectangle"),      onClick: "setPanMode(2,this)",                  icon: "fa-crop-alt fa-flip-vertical", button: 1, menu: 1 },
      {id:"ImgZoomOut",     alt:"Zoom Out",        label: L("lcl_slnk_zoomout"),            onClick: "_doZoomoutCentre()",                  icon: "fa-search-minus",    button: 1, menu: 1 },
      {id:"ImgZoomExtents", alt:"Zoom Extents",    label: L("lcl_slnk_zoomextents"),        onClick: "ZoomExtents(event)",                  icon: "fa-expand-arrows",   button: 1, menu: 1 },
      {id:"ImgRefresh",     alt:"Refresh",         label: L("lcl_slnk_refresh"),            onClick: "Refresh(false,true)",                 icon: "fa-fclt-refresh",            button: 1, menu: 1 },
      {id:"ImgPrint",       alt:"Print",           label: L("lcl_slnk_print"),              onClick: "onPrint(event)",                      icon: "fa-print",           button: 1, menu: 0 },
      {id:"",               alt:"",                label: L("lcl_slnk_backgroundblack"),    onClick: "SetPaperColor(0);Refresh()",          icon: "fa-square fas",      button: 0, menu: 1, iconcolor: "#000" },
      {id:"",               alt:"",                label: L("lcl_slnk_backgroundwhite"),    onClick: "SetPaperColor(0xFFFFFF);Refresh()",   icon: "fa-square fas",      button: 0, menu: 1, iconcolor: "#FFF" },
      {id:"",               alt:"",                label: L("lcl_slnk_backgrounddefault"),  onClick: "SetPaperColor("+S("fg_paperColor")+");Refresh()", icon: "fa-square fas", button: 0, menu: (customColor ? 1 : 0),
                                                                                            iconcolor: "#"+("000000"+S("fg_paperColor").toString(16)).slice(-6)},
      {id:"",               alt:"",                label: L("lcl_slnk_labelcenter"),        onClick: "SetLabelPosition(2);Refresh()",       icon: "fa-align-center fa-flip-vertical", button: 0, menu: (ShowLabelMenu ? 1 : 0) },
      {id:"",               alt:"",                label: L("lcl_slnk_labeltopleft"),       onClick: "SetLabelPosition(3);Refresh()",       icon: "fa-align-left fa-flip-vertical",   button: 0, menu: (ShowLabelMenu ? 1 : 0) },
      {id:"",               alt:"",                label: L("lcl_slnk_labeldefault"),       onClick: "SetLabelPosition(1);Refresh()",       icon: "fa-align-justify",   button: 0, menu: (ShowLabelMenu ? 1 : 0) },
      {id:"",               alt:"",                label: "About SLNKDwf",                  onClick: "SLNKAbout()",                         icon: "fa-copyright",       button: 0, menu: (user.checkAutorisation("WEB_PRSSYS", true) ? 1 : 0) }
    ];
    if (S("fg_dwfviewer_installed"))
    {
        menuoptions.push({id:"ImgDwf", alt:"Dwf", label: L("lcl_slnk_dwfviewer"), onClick: "onDwf(event)", icon: "fa-file-export", button: 1, menu: 0 });
    }
%>
<body id="idBody" name="idBody" onload="Init();Reset();" <%=evtres%>
        style="background-color:white;margin:0;padding:0;"
        onmouseleave="_onMouseLeave(event)"
        onselect="document.selection.empty();"
        onkeydown="return _onKeyDown(event)">
    <div id="rubberBand" onclick="_stopRubber(event)" onmousemove="_moveRubber(event);"
         onmouseup="_onMouseUp(event);" oncontextmenu="return _oncontextmenu(event);"></div>
    <div id="dist" onclick="_stopRubber(event)" onmousemove="_moveRubber(event);"></div>
    <div id="dwgDist" style="z-index:4" onmousemove="_onMouseMove(event);">Hier komt de afstand</div>
    <div id="DragAndDrop" onMouseMove="Dropper_onMouseMove(event)" onMouseUp="Dropper_onMouseUp(event)">
             Hier komt de drag-and-drop HTML
    </div>

<% if (ShowButtons) { %>
    <div id="navbuttons" >
<%
    for (var butt in menuoptions) {
        if (menuoptions[butt].button == 1)
            Response.Write("<span id='"+menuoptions[butt].id+"' alt='"+menuoptions[butt].alt+"' title='"+menuoptions[butt].label+"' onClick='javascript:"+menuoptions[butt].onClick+"'>"+I(menuoptions[butt].icon)+"</span>");
    }
%>
    </div>
<% } %>

    <div id="defaultContextMenu" class="slnkmenu" style="display:none">
    <div class="menuItem menuTitle"><%=L("lcl_slnk_viewmenu")%></div>
<%
    for (var butt in menuoptions) {
        if (menuoptions[butt].menu == 1)
        {
            if (menuoptions[butt].iconcolor)
                var thisicon = "<span style='color:"+menuoptions[butt].iconcolor+"'>"+I(menuoptions[butt].icon+" fa-lg")+"</span>"
            else
                var thisicon = I(menuoptions[butt].icon+" fa-lg");

            Response.Write("<div class='menuItem' monClick='"+menuoptions[butt].onClick+"'>"+thisicon+"&nbsp;"+menuoptions[butt].label+"</div>");
        }
    }
%>
    </div>
    <div id="Pickpoint" ondragstart="return false;"
        onmouseover="_PickHot(event)" onmouseout="_PickCold(event)" onmousedown="return _onMouseDown(event)"
        oncontextmenu="return _onPickcontextmenu(event)"></div>
    <div id="Snapper"></div>
    <span class="fgindicator" id="busymarker"><%=I("fa-fclt-refresh fa-pulse fa-4x", { "fastyle": "fas" })%></span>
    <img id="Eview" usemap="#SystemMap" style="width:100%;height:100%;position:absolute;z-index:0;">
    <map id="SystemMap" name="SystemMap" onmouseover="_areain(event);" onmouseout="_areaout(event)"></map>
</body>
</html>
<% ASPPAGE_END(); %>