﻿// JScript File

var _traceLength = 1000;

// set the trace length to a different value
function setTraceLength (length) 
{
    _traceLength = length;
}

// look for the debug text area and write to it
function clearTrace ()
{
    traceArea = document.getElementById("_trace");
    if (traceArea != null && traceArea.tagName == "TEXTAREA") {
        traceArea.value = "";
    }
}

function trace(text) 
{
    traceArea = document.getElementById("_trace");
    if (traceArea != null && traceArea.tagName == "TEXTAREA") {
        traceArea.value = (text + "\n" + traceArea.value).substr(0, _traceLength);
    }
}

// traces the function name and arguments
function traceFunctionDetails() 
{
    var caller = traceFunctionDetails.caller;
    if (caller != null) {
        var text = "Function: " + caller.name + " Arguments: ";
        for (var i = 0; i < caller.arguments.length; i++) {
            text += caller.arguments[i] + ((i < caller.arguments.length - 1) ? ", " : "");
        }
        // trace the resulting text
        trace(text);
    }
}