<SCRIPT LANGUAGE="JavaScript" RUNAT="Server">

// SESSION must be started like: http://dit03/facilitorwork/dijk?logging

function padout(number) { return (number < 10) ? '0' + number : number; }
function __LogAppend(s)
{
    if (Session("logging")&&(Session("logging")&32))
    {
        var objFile, objText
        var lPath = "C:/Temp/log_"+Session("customerId")+".html";
        objFile = Server.CreateObject("Scripting.FileSystemObject");
        var IsNew = (!objFile.FileExists(lPath))

        objText = objFile.OpenTextFile(lPath, 8, true, 0);
        objText.WriteLine(s);

        objText.Close();
        objText = null;
        objFile = null;
    }
}
function VB_Log(s) {
    if (Session("logging")&&(Session("logging")&32))
    {
        var objFile, objText
        // var lPath = "C:/Temp/log_"+Session("customerId")+".html";
        var lPath = Server.MapPath("../../temp/flog_"+Session("customerId")+".html")
        objFile = Server.CreateObject("Scripting.FileSystemObject");
        var IsNew = (!objFile.FileExists(lPath))

        objText = objFile.OpenTextFile(lPath, 8, true, 0);
        if (IsNew)
        {    objText.WriteLine("<style>");
             objText.WriteLine("td {");
             objText.WriteLine("  font-family: Verdana;");
             objText.WriteLine("  font-size: smaller;");
             objText.WriteLine("  font-weight: normal;");
             objText.WriteLine("  color: #000000;");
             objText.WriteLine("  text-decoration: none;");
             objText.WriteLine("  padding-bottom: 2px;");
             objText.WriteLine("  padding-top: 2px;");
             objText.WriteLine("  padding-left: 2px;");
             objText.WriteLine("  padding-right: 2px;");
             objText.WriteLine("  background-color: #D6D8E8;");
             objText.WriteLine("}");
             objText.WriteLine("</style>");
             objText.WriteLine("");
             objText.WriteLine("<form action=./../shared/wisLog.asp>")
             objText.WriteLine("    <input type=submit value=\"CLEAR this logfile\">");
             objText.WriteLine("</form>");
             objText.WriteLine("<table>"); // The closing </table> is never placed. IE doesn't care
             objText.WriteLine("<tr><td colspan='3' align='center'>Logging was reset");
        }

        var now = new Date();
        var sNow = now.getFullYear()+"/"+padout(now.getMonth()+1)+"/"+padout(now.getDate())+"&nbsp;"+
                   padout(now.getHours())+":"+padout(now.getMinutes())+":"+padout(now.getSeconds());
        var x = Request.ServerVariables("URL")+"";
        //x = x.substring(Session("wwwroot").length+1);

        var ip = Request.ServerVariables("REMOTE_ADDR") + "";
        // while (ip.indexOf(".") >= 0)
        //     ip = ip.substring(1)
        ip = Request.ServerVariables("REMOTE_USER") + " " + ip

        objText.WriteLine("</td></tr><tr><td valign='top' title='"+ ip + "'>" + Session("user_key") + " "+sNow+"<br>" + x + "</td><td>" +s+"");

        objText.Close();
        objText = null;
        objFile = null;
    }
}

</SCRIPT>
