var Try = {
    these: function() {
        var returnValue;

        for (var i = 0, length = arguments.length; i < length; i++) {
            var lambda = arguments[i];
            try {
                returnValue = lambda();
                break;
            } catch (e) {
            }
        }

        return returnValue;
    }
};

function getXHR() {
    return Try.these(
            function() { return new XMLHttpRequest() },
            function() { return new ActiveXObject('Msxml2.XMLHTTP') },
            function() { return new ActiveXObject('Microsoft.XMLHTTP') }
            ) || false;
}

function updateEvery(elementId, url, interval) {
    window.setInterval(function() {
        var xhr = getXHR();
        if (!xhr) return;

        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                var e = document.getElementById(elementId);
                if (e != null) e.innerHTML = xhr.responseText;
            }
        };
        var nocache = "?" + (new Date().getTime());
        xhr.open("GET", url + nocache, true);
        xhr.send(null);
    }, interval);
}