var ajax_request = false;

function create_object()    {

    if(window.ActiveXObject)     {
        //IE
        // loops through the various versions of XMLHTTP to ensure we're using the latest
	var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                        "Microsoft.XMLHTTP"];

        for (var i = 0; i < versions.length ; i++) {
            try {
                // try to create the object
                // if it doesn't work, we'll try again
                // if it does work, we'll save a reference to the proper one to speed up future instantiations
                ajax_request = new ActiveXObject(versions[i]);

                if (ajax_request) {
                    break;
                }
            }catch (objException) {
                // trap; try next one
            } ;
        }
    }

    if (!ajax_request && typeof XMLHttpRequest != 'undefined') {
        ajax_request = new XMLHttpRequest ();
    }

}

function loadUrl(url) {
    ajax_request.open("GET", url, false);
    ajax_request.send(null);

    if(ajax_request.readyState == 4 && ajax_request.status == 200)    {
        var response_text = ajax_request.responseText;
        var mydiv = document.getElementById("mydiv");
        mydiv.innerHTML = response_text;
    }
}
