﻿/*****************************************************************************/
/*
* httprequest tool
*/
var DEBUG_EMIT_EXTRA_EXCEPTION_INFO = true && DEBUG_MODE;

/// provides a regex to filter simple dotnet text template (eg, {0} and {1} but not {0:format})
var RE_PROTOTYPE_TEMPLATE_DOTNET_SYNTAX = /(^|.|\r|\n)(\{(\d+)})/;

var VOID_ID = -1;

function report_error(msg)
{
    if (DEBUG_EMIT_EXTRA_EXCEPTION_INFO)
    {
        alert(msg);
    }
}

/*****************************************************************************/
/*
* httprequest tool
*/
function ExtractResponse(xmlHttpTransport)
{
    //
    // strip end of xml wrapper
    //
    var text = xmlHttpTransport.responseText;
    //var re = new RegExp("^(?:<\?xml[^>]+>\n)" + "(?:<[^>]+>)" + ".+" + "(?:</[^>]>+)$", "m");
    var reXml = /^<[?]xml[^>]+>/;
    var reStartTag = /^<[^>]+>/m;
    var reEndTag = /<\/[^>]+>$/m;
    var reEmpty = /^<[^>]+\/>$/m;

    text = text.substring(reXml.exec(text)[0].length + 2); /* strip xml line */

    if (text.match(reEmpty)) return "";
    text = text.replace(reStartTag, "");
    text = text.replace(reEndTag, "");

    return text.unescapeHTML();
}

function Ajax_onFailure(sourceFunction, transport)
{
    //	if(new RegExp("Session empty").test(transport.responseText))
    //	{
    //		report_error('report update failure from method ' + sourceFunction + '\nError: ' + transport.responseText 
    //			+ '\nResponding with a page reload', location.href);
    //		location.reload();
    //		return;
    //	}
    alert('Er is een fout optreden bij het verversen van de lijst.\n\nDe foutmelding: ' + transport.responseText);
    //	report_error('report update failure from method ' + sourceFunction + '\nError: ' + transport.responseText, location.href);
}

function Ajax_onException(sourceFunction, transport, exception)
{
    if (DEBUG_EMIT_EXTRA_EXCEPTION_INFO)
    {
        alert(sourceFunction);
    }
    alert('Er is een fout opgetreden bij het bijwerken van de lijst.\n\nDe foutmelding is: ' + exception.message);
    //	report_error('report refresh failure from method ' + sourceFunction + '\nError: ' + exception.message, location.href, exception.fileName + ' ' + exception.lineNumber);
}



