window.onerror = function(error, url, line) {
    try {
        var xmlhttp = false;
        /*@cc_on @*/
        /*@if (@_jscript_version >= 5)
        // JScript gives us Conditional compilation, we can cope with old IE versions.
        // and security blocked creation of the objects.
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        @end @*/

        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                xmlhttp=false;
            }
        }

        if (!xmlhttp && window.createRequest) {
            try {
                xmlhttp = window.createRequest();
            }catch (e) {
                xmlhttp=false;
            }
        }

        if (xmlhttp) {
            xmlhttp.open("POST", '/error-log.php', false);
            
            var boundary = "Boundary_" + new Date().getMilliseconds();
            xmlhttp.setRequestHeader("Content-Type", "multipart/form-data; boundary="+boundary);
            
            var dataString = "";

            var params = {error: error, script_url: url, browser_url: window.document.location.href, line: line};
            
            for (var propName in params) {
                dataString += '--' + boundary + '\r\n';
                dataString += 'content-disposition: form-data; name="' + propName + '"' + '\r\n';
                dataString += 'content-type: application/octet-stream;\r\n\r\n\r\n';
                dataString += params[propName] + '\r\n';
            }
            dataString += "--"+boundary;
            
            xmlhttp.send(dataString);
        }
    } catch (e) {
    }
}

