
var xmlReq;

function requestData( url, dataHandler)
{
    xmlReq = createXMLHttpRequest();
    xmlReq.onreadystatechange = responseCallback;
    xmlReq.handler = dataHandler; 
    xmlReq.open( "GET", url, true );
    xmlReq.send( "" );
}

function responseCallback() {
	if ( xmlReq.readyState == 4 ) // done loading
    {
        // xmlReq.status = 0   => loaded from file
        // xmlReq.status = 200 => HTTP "OK" status code
        // xmlReq.responseXML  => the response was well-formed text/xml
        if ( ( xmlReq.status == 0 || xmlReq.status == 200 ) && xmlReq.responseText )
        {
            xmlReq.handler.handleResponseText(xmlReq, xmlReq.responseText);
        }
        else
        {
        	xmlReq.handler.handleHttpFailure(xmlReq);
        }
    }
}

function createXMLHttpRequest()
{
    var xmlReq = null;

    if ( window.XMLHttpRequest )
    {
        xmlReq = new XMLHttpRequest();
    }
    else if ( window.ActiveXObject )
    {
        try
        {
            xmlReq = new ActiveXObject( "Msxml2.XMLHTTP" );
        }
        catch ( e )
        {
            xmlReq = new ActiveXObject( "Microsoft.XMLHTTP" );
        }
    }
    
    return xmlReq;
}
