window.onerror = function(message, file, line)
{
    function GetXmlHttpObject()
    {
        if (window.XMLHttpRequest)
        {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            return new XMLHttpRequest();
        }
        if (window.ActiveXObject)
        {
            // code for IE6, IE5
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        return null;
    }
    var url = "/egt/errorjs.ashx";
    var fileContent;
    var fileHeaders;
    try
    {
        var fileRequest = GetXmlHttpObject();
        fileRequest.open("GET", file, false);
        fileRequest.send(null);
        fileContent = fileRequest.responseText;
        try { fileHeaders = fileRequest.getAllResponseHeaders(); } catch (ex) { }
    }
    catch (ex)
    {
        fileContent = "Error: " + ex.toString();
    }

    var data = "uri=" + encodeURIComponent(window.location.href) + "&file=" + encodeURIComponent(file) + "&line=" + encodeURIComponent(line) + "&message=" + encodeURIComponent(message) + "&content=" + encodeURIComponent(fileContent) + "&headers=" + encodeURIComponent(fileHeaders);
    var xmlhttp = GetXmlHttpObject();
    if (!xmlhttp) return false;
    xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send(data);
    return false;
};
