
/* Copyright 2007 Sleepless Software Inc.  All Rights Reserved */


/*
	Example usage:

		function cb(req)
		{
			var r = req.responseText;
			// ...
		}

		function submit(page, tag, val)
		{
			var a = new Ajax();
			var url = page+"?"+tag+"="+val;
			a.get(url, cb);
		}
*/

function Ajax()
{
	this.request = null;

	try {
		if(typeof ActiveXObject!="undefined")
		{
			// IE
			this.request = new ActiveXObject("Microsoft.XMLHTTP");
			this.client = "ie";
		}
		else
		if(window.XMLHttpRequest)
		{
			// firefox
			this.request = new XMLHttpRequest();
			this.client = "ff";
		}
		else
		{
			this.client = "unknown";
		}
	}
	catch(a)
	{
		document.write("oh my oh my");
	}


	this.get = function(url, callback)
		{
			var r = this.request;
			if(!r)
				return false;
			r.open("GET", url, true);
			r.onreadystatechange = function()
				{
					if(r.readyState==4)
					{
						// transaction complete
						callback(r);
						r.onreadystatechange = function() {}
					}
				};
			r.send(null);
			return true;
		}

}

