/*
 * AHAH code as found at http://microformats.org/wiki/rest/ahah
 */
function ahah(url,target, method) {
    var req = null;
    //document.getElementById(target).innerHTML = 'loading data...';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {ahahDone(target, req);};
        req.open(method, url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {ahahDone(target, req);};
            req.open(method, url, true);
            req.send();
        }
    }
}

function ahahDone(target, req) {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           document.getElementById(target).innerHTML = results;
       } else {
           document.getElementById(target).innerHTML="ahah error:\n" +
               req.statusText;
       }
   }
}
