

function requestPage(url, callback) {
   var req;
   if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.open("GET", url, true);
		req.onreadystatechange=function() {
			if (req.readyState==4) {
			    //alert(url + " -> " + req.responseText);//pete's test...
				callback(req.responseText);
	  		}
		}
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.open("GET", url, true);
	    
	    req.onreadystatechange=function() {
		if (req.readyState==4) {
			callback(req.responseText);
	  	}
	    }
	    req.send(null);
        }
    }
}


/**
 * ajaxQuery() is designed to make it really easy to query
 * the server.  For simplicity, it'll only query /ajax.php.
 * (see that file for more info)
 * 
 * Params:
 * 	action	string	Name of the action to be performed.
 * 			Must correspond to an action listed
 *			in ajax.php.
 * 	keys	array	An array of the names of GET params
 *			to be passed to ajax.php.
 *	values	array	An array of the values of GET params
 *			to be passed to ajax.php.
 *	callback func	Function that is called when response
 *			is complete.  It is sent one arg, the
 * 			responseText (the output of ajax.php).
 *
 * Obviously, keys and values should be arrays of the same
 * size.
 **/
function ajaxQuery(action, keys, values, callback) {
	url = "/ajax.php?action="+escape(action);
	for (i=0; i<keys.length; i++) {
		url += "&" + escape(keys[i]) + "=" + escape(values[i]);
	}
	if(action == "addgrouproute")
		alert(url);
	requestPage(url, callback);
}

