    var gAWDebugWin = null;
    function _awxdFindDebugWindow ()
    {
        if (gAWDebugWin == null || gAWDebugWin.closed) {
            var debugJS = AWDebugJSUrl;
            if (debugJS == null || debugJS == "") {
                alert ("AWDebugJS not set");
                return;
            }
            gAWDebugWin = window.open('', 'debugWin', 'scrollbars=yes, status=yes, resizable=yes, width=350, height=700, screenX=0, screenY=75, left=0, top=75');
            if (_awxdGetDocElement(gAWDebugWin.document, "content") == null) {
                var content =
                    '<html>\n' +
                    '<head>\n' +
                    '<script language="JavaScript" src="'+debugJS+'"></script>\n' +
                    '<style type="text/css">\n' +
                    'A, DIV, P, TD, TH, BLOCKQUOTE, LI, OL, UL { font:normal 8pt Verdana, Arial, Helvetica, sans-serif;}\n' +
                    'B { font:bold 10pt Verdana, Arial, Helvetica, sans-serif;}\n' +
                    '</style>\n' +
                    '</head>\n' +
                    '<body>\n' +
                    '<b>Debug</b><br/>\n' +
                    '<a href="#" onclick="javascript:getDebug().clear();return false;">clear</a>\n' +
                    '<a href="#" onClick="javascript:getDebug().toggleFunctionNames();return false;">function names</a>\n' +
                    '<hr/>\n' +
                    '<div id=content></div>\n' +
                    '<hr/>\n' +
                    '<a href="#" onclick="javascript:getDebug().clear();return false;">clear</a>\n' +
                    '<a href="#" onClick="javascript:getDebug().toggleFunctionNames();return false;">function names</a>\n' +
                    '</body>\n';
                gAWDebugWin.document.write(content);
                gAWDebugWin.document.close();
            }
            if (navigator.appName=="Microsoft Internet Explorer") {
                while (!gAWDebugWin.document || !gAWDebugWin.getDebug) {
                }
            }
        }
    }
    function awxdSetRequestStartTime (requestStart)
    {
        if (AWJSDebugEnabled) {
            _awxdFindDebugWindow();
            if (gAWDebugWin.getDebug) {
                gAWDebugWin.getDebug().setStartRequest(requestStart);
            }
        }
    }
    function awxdGetRequestStartTime ()
    {
        var requestStart = null;
        if (AWJSDebugEnabled) {
            _awxdFindDebugWindow();
            if (gAWDebugWin.getDebug) {
                requestStart = gAWDebugWin.getDebug().getRequestStart();
            }
        }
        return requestStart;
    }
    function awxdGetMethodName (func)
    {
        if (!func) return func;
        var sFunc = func.toString();
        return sFunc.substring(9,sFunc.search(/\(/)-1);
    }
    function awxdGetCaller (numAncestor)
    {
        if (!numAncestor) {
            numAncestor = 0;
        }
        var func = awxdGetCaller.caller;
        for (var i=0; i <= numAncestor; i++) {
            func = func.caller;
            if (!func) {
                return "--"; 
            }
        }
        if (func) {
            return awxdGetMethodName(func);
        }
        return "--";
    }
    function debug (sMsg, iHistory)
    {
        if (AWJSDebugEnabled) {
            _awxdFindDebugWindow();
            if (gAWDebugWin.getDebug) {
                if (!iHistory) iHistory = 2;
                var callerString = '';
                for (var i=0; i < iHistory; i++) {
                    if (i!=0) callerString += ",";
                    callerString += awxdGetCaller(i);
                }
                gAWDebugWin.getDebug().print(sMsg, callerString);
            }
        }
    }
    function awDebug (sMsg)
    {
        debug(sMsg);
    }
    function awxdPrintProperties (element)
    {
        if (AWJSDebugEnabled) {
            _awxdFindDebugWindow();
            if (gAWDebugWin.getDebug) {
                gAWDebugWin.getDebug().printProperties(element);
            }
        }
    }
    function awxdDebugDOM ()
    {
        if (AWJSDebugEnabled) {
            var doc = document;
            _awxdFindDebugWindow();
            if (gAWDebugWin.getDebug) {
                gAWDebugWin.getDebug().print("starting dom debug");
                gAWDebugWin.getDebug().printProperties(document);
            }
        }
    }
    function _awxdGetDocElement (doc, id)
    {
        var element = doc.getElementById ?
                        doc.getElementById(id) :
                        doc.all[id];
        return element;
    }
