function createXmlHttpRequest()
{
    if(typeof XMLHttpRequest != "undefined")
    {
        // For Firefox/Safari/Opera etc.
        return new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var aVersions =
        [
            "MSXML2.XmlHttp.5.0",
            "MSXML2.XmlHttp.4.0",
            "MSXML2.XmlHttp.3.0",
            "MSXML2.XmlHttp",
            "Microsoft.XmlHttp"
        ];

        // Keep trying each version of MSXML (starting from latest)
        // until you find the one that's supported
        for(var i = 0; i < aVersions.length; i++)
        {
            try
            {
                var oXhr = new ActiveXObject(aVersions[i]);
                return oXhr;
            }
            catch(oError) {}
        }

        return null;
    }
    else
    {
        return null;
    }
}