/**********************************************************************
 * Error.js 2.7 Free Edition                               Jun 25, 2001
 *
 * Error and Message Logging Console
 * 
 * This code is provided "as is" without warranty of any kind.
 * Cirkadia further disclaims all implied warranties including fitness 
 * for any particular purpose. The entire risk arising out of the use 
 * or performace of this code remains with you.
 * 
 * Contact productinfo@cirkadia.com for any other usage.
 * 
 * Copyright © 2000-2001  Cirkadia Ltd.  All rights reserved.
 * 
 * http://www.cirkadia.com
 * 
 **********************************************************************/ 


/**********************************************************************
 *
 * Browser Identification
 *
 **********************************************************************/ 

var IE4plus = false;
var NS6plus = false;
var Opera   = false;

if (navigator.userAgent.indexOf('Opera') > 0) 
{
    Opera = true;
}

if (!Opera)
{
    if (document.all)
    {
        IE4plus = true;
    }

    else if (document.childNodes) 
    {
        NS6plus = true;
    }
}

if (IE4plus)
{
    window.onerror=LogError;
}

/**********************************************************************
 *
 * Error and Logging Console Functions
 *
 **********************************************************************/ 

var sConsoleName     = 'CirkadiaJSConsole';
var sConsoleFeatures = 'height=400,width=300,scrollbars,resizable';
var sConsoleTitle    = '<title>Cirkadia JavaScript Console</title>';
var sSupportEmail    = '';

var bFirstMessage = true;
var bFirstError   = true;

var sConsoleHTML  = '';

function LogError(message, url, line)
{
    if (bFirstError)
    {
        bFirstError = false;

        Log('<b>JavaScript Error(s)</b><hr>We hope this doesn\'t spoil your visit!');

        if (sSupportEmail.length > 0)
        {
            Log('Please mail this log to <a href="mailto:' + sSupportEmail + '?subject=JavaScript Error(s)">' + sSupportEmail + '</a>');
        }

        Log('<hr>', false);

        Log('Browser: ' + navigator.userAgent);
        Log('Page: ' + url + '<hr>', false);
    }

    Log('Line: ' + line);
    Log(message + '<hr>', false);

    return false;
}

function Log(message, linebreak)
{
    var oConsole = window.open('', sConsoleName, sConsoleFeatures);

    oConsole.focus();

    var oDocument = oConsole.document;

    if (bFirstMessage == true)
    {
        bFirstMessage = false;

        sConsoleHTML = sConsoleTitle + '<nobr>';
    }

    sConsoleHTML = sConsoleHTML + message + (linebreak == false ? '' : '<br>')

    oDocument.open();
    oDocument.clear();
    oDocument.write(sConsoleHTML + '</nobr>');
    oDocument.close();
}

function ClearLog()
{
    var oConsole = window.open('', sConsoleName, sConsoleFeatures);

    oConsole.focus();

    var oDocument = oConsole.document;

    oDocument.open();
    oDocument.clear();
    oDocument.close();

    bFirstMessage = true;
}