function AjaxManager()
{
	this.contentType = "text/xml";

	// returns a XMLHttpRequest object
	this.getRequest = function()
	{
		var request = false;
		if (window.XMLHttpRequest)
		{
			request = new XMLHttpRequest();
			request.overrideMimeType(this.contentType);
		}
		else if (window.ActiveXObject)
		{
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return request;
	}
	
	// handles Ajax errors
	this.handleError = function(err)
	{
		alert(err + "\n" + err.name + "\n" + err.message + "\n" + err.number);
	}
	
	// posts info to a url
	this.post = function(url, callback, submitText)
	{
		this.send(url, callback, submitText, "POST");
	}
	
	// gets info to a url
	this.get = function(url, callback, submitText)
	{
		this.send(url, callback, submitText, "GET");
	}
	
	// demainds rights to open a foreign url
	this.demandRights = function(url)
	{
		var proposedUrl = new Url(url.toString());
		var currentUrl = new Url(window.location.toString());
		var isLocalUrl = proposedUrl.domain == currentUrl.domain;
		if (!isLocalUrl && window.XMLHttpRequest)
		{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
		}
	}
	
	// sends info to a url
	this.send = function(url, callback, submitText, method)
	{
		try
		{
			var response = this.request;
			this.demandRights(url);
			this.request.open(method, url, true);
			this.request.setRequestHeader("Content-Type", this.contentType);
			this.request.onreadystatechange = function() 
			{
				if (response.readyState == 4)
				{
					if (response.status==200)
					{
						callback(response);
					}
					else
					{
						alert("Error accessing " + url + ". Status=" + response.status);
					}
				}
			}
			this.request.send(submitText);
		}
		catch (e)
		{
			this.handleError(e);
		}
	}
	
	this.request = this.getRequest();
}


// A class for handling XMLDOM activities
function XmlManager()
{
	// set asynchronous retrieval property
	this.async = true;

	// gets an XML dOM document
	this.getDoc = function()
	{
		var doc;
		if (document.implementation && document.implementation.createDocument)
		{
			doc = document.implementation.createDocument("", "", null);
		}
		else if (window.ActiveXObject)
		{
			doc = new ActiveXObject("Microsoft.XMLDOM");
		}
		return doc;
	}
	
	// loads an XML document
	// arg = the url or text to load
	// isUrl = indicates if the arg is a url
	// callback = a callback function to call when the document is loaded, which passes a reference to the document
	this.load = function(arg, isUrl, callback)
	{
		var doc = this.getDoc();
		doc.async = this.async;
		
		if (callback)
		{
			doc.onreadystatechange = function()
			{
				if (doc.readyState == 4) callback(doc);
			}
		}
		
		doc.load(arg);
	
		return doc;
	}
	
	// loads an XML document from file and returns a reference
	// url = the url to load
	// callback = a callback function to call when the document is loaded
	this.loadFile = function(url, callback)
	{
		return this.load(url, true, callback);
	}
	
	// loads an XML document from text and returns a reference
	// text = the text to load
	// callback = a callback function to call when the document is loaded
	this.loadText = function(text, callback)
	{
		return this.load(text, false, callback);
	}

}