﻿
function $Kleenex_ShowError(message, stackTrace)
{
    // look for the Error container
    if ($('#Error').size() === 0)
    {
        // TODO position it within the currently visible space (ScrollTop + 5?)
        var style = "position: absolute; top: 5px; left: 5px; padding: 5px; font-weight: bold; font-size: 2em;";
        $('body').append('<div id="Error" style="' + style + '"></div>');
    }
    // TODO remove the jump to the top using scrollTop
    $(window).scrollTop(0);
    $('#Error').empty().append(message).css('background', '#d00').css('color', '#fff').fadeIn(250);
    setTimeout(function() {$('#Error').fadeOut(250);}, 250);
    setTimeout(function() {$('#Error').css('background', '#900').fadeIn(250);}, 500);
    setTimeout(function() {$('#Error').fadeOut(500);}, 5000);
}

function $Kleenex_ErrorHandler(exception, context)
{
    //exception._exceptionType;
    //exception._message;
    //exception._stackTrace;
    //exception._statusCode;
    //exception._timedOut;
    //alert('Error: ' + exception._message);
    context.ShowError(exception._message, exception._stackTrace);
}
