<!--

function AjaxDelegate(url, callback) {
	//>> url: URL of the page that will do the server-side AJAX processing
	//>> callback: the name of the javascript function to call when data is returned
	//>> arguments: 
	this.url = url;
	this.callback = callback; 
	this.callbackArguments = arguments;

	// methods
	this.Fetch = ajaxFetch;
	this.Post = ajaxPost;

	// XmlHttpRequest object
	this.request = null;
}

/*
ajaxFetch()
	Asynchronously calls the url specified in the AjaxDelegate constructor.
	When the call completes, the callback specified in the AjaxDelegate constructor
	is called, passing the responseText data in.
*/
function ajaxFetch() {
	// this gets the variables into a local scope
    var request = this.request;
    var callback = this.callback;
    var callbackArguments = this.callbackArguments;

	request = GetXmlHttpObject(	
		function () {
			if(request.readyState == 4) {
				if(request.status == 200) {
					//>> Setup a new array to pass as "arguments" to the callback method
					var args = new Array();
					args[0] = request.responseText;
					for (i = 2; i < callbackArguments.length; i++) {
						args[i-1] = callbackArguments[i];
					}

					//>> Apply these new arguments to the callback method					
					callback.apply(this, args);
				} else {
					alert("There was a problem retrieving the response:\n\n" + request.statusText);
				}
				// clean up
				request = null;
			}
		});
	request.open("GET", this.url, true);
	request.send("");
}

/*
ajaxPost()
	Asynchronously calls the url specified in the AjaxDelegate constructor.
	When the call completes, the callback specified in the AjaxDelegate constructor
	is called, passing the responseText data in.
*/
function ajaxPost(parms) {
	// this gets the variables into a local scope
    var request = this.request;
    var callback = this.callback;
    var callbackArguments = this.callbackArguments;

	request = GetXmlHttpObject(	
		function () {
			if(request.readyState == 4) {
				if(request.status == 200) {
					//>> Setup a new array to pass as "arguments" to the callback method
					var args = new Array();
					args[0] = request.responseText;
					for (i = 2; i < callbackArguments.length; i++) {
						args[i-1] = callbackArguments[i];
					}

					//>> Apply these new arguments to the callback method					
					callback.apply(this, args);
				} else {
					alert("There was a problem retrieving the response:\n\n" + request.statusText);
				}
				// clean up
				request = null;
			}
		});
	request.open("POST", this.url, true);
	request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	request.send(parms);
}
//-->

