/* 
Apple's developer documentation
http://developer.apple.com/internet/webcontent/xmlhttpreq.html
*/
var req;
function loadXMLDoc(url)
{
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }

	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}

function processReqChange() 
{
    // only if req shows "complete"
    if (req.readyState == 4)
    {
        // only if "OK"
        if (req.status == 200)
        {
            // ...processing statements go here...
			var response = req.responseXML.documentElement;
			var method = response.getElementsByTagName('method')[0].firstChild.data;

			/* pass of the result part of the XML response and let the
			   function specific to the task parse it */			
			var result = response.getElementsByTagName('result')[0].childNodes;

			eval(method + '(\'\', result)');

        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}
