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

     File:          fac_edit_template.asp
     Description:   Bewerk het css-template
     Parameters:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="fac.inc" -->

<%
FCLTHeader.Requires({ plugins:["jQuery"] })

var autfunction = "WEB_LAYOUT";
var authparams = user.checkAutorisation(autfunction);


function prettyJson(j)
{
  try
  {
    var xx = JSON.stringify(eval("(" + j + ")"), null, 2);
    if (xx == "null")
        return "";
    return xx;
  }
  catch (e)
  {
    return j;
  };
};

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script type="text/javascript" >

      function doSubmit()
      {
        if (!confirm("Opslaan? Dit geldt direct voor alle gebruikers!"))
            return;
        $("input[name=previewmode]").val(2); // Moet in combinatie met save
        $("input[name=submitting]").val(1);

        //if (!validateForm("u2"))
        //  return false;
        document.u2.submit();
      }
      function preview(mode, submitting)
      {
        $("input[name=previewmode]").val(mode);
        $("input[name=submitting]").val(submitting||0);

        //if (!validateForm("u2"))
        //  return false;
        document.u2.submit();
      }

      function doCancel()
      {
          FcltMgr.closeDetail(window, { cancel: true } );
      }
    </script>
    <style>
        th { width: 100px; }
    </style>
  </head>

  <body id="editbody">
<%  buttons = []
    buttons.push ({title: L("lcl_submit"),  icon: "opslaan.png", action: "doSubmit()" });
    buttons.push( {title: L("lcl_cancel"), icon: "undo.png", action: "doCancel()" } );
    IFRAMER_HEADER("Template", buttons);
%>
    <div id="edit">
      <form name=u2
            method="post"
            action="fac_edit_template_save.asp?"
            target="workFrame"
            onSubmit="doSubmit();">
        <input type='hidden' name='previewmode'>
        <input type='hidden' name='submitting'>
<%
        BLOCK_START("template_css", "Stijlen");
        var custtemplate = S("csstemplate");
%><table>
    <tr><th style='width:180px;'>Naam</th><th>Default</th><th>Actueel</th><th>Concept</th></tr>
<%
        for (itm in FCLTHeader.defaultTemplate)
        {
            var act = "";
            if (itm in S("csstemplate"))
                act = S("csstemplate")[itm];
            var con = "";
            if (itm in S("csstemplate"))
                con = S("csstemplate")[itm];
%><tr><td class='label'><label><%=safe.html(itm)%></label></td>
      <td><%=safe.html(FCLTHeader.defaultTemplate[itm])%></td>
      <td><%=safe.html(act)%></td>
      <td><input name='<%=safe.html(itm)%>' value='<%=safe.htmlattr(con)%>'></td>
  </tr><%
        }
%>
    <tr><td></td><td><input type='button' class='button' value='Preview' onclick='preview(1)'></td>
                 <td><input type='button' class='button' value='Preview' onclick='preview(0)'></td>
                 <td><input type='button' class='button' value='Preview' onclick='preview(2)'></td></tr>
</table><%
        BLOCK_END();

        IFACE.FORM_END();
%>
      </form>
    </div>

    <div id="result">
      <iframe width="100%" height="100%"
              src="../Shared/empty.asp"
              name="workFrame" id="workFrame"
              onload="FcltMgr.iframeLoaded(this, false, true)"
              frameborder="0" scrolling="no">
      </iframe>
    </div>

  </body>
</html>
