if (!POC) var POC = {};

POC.Ajax = function(fn)
{
	var obj = this;
	// set return function
	this.whatToDo = fn;
	
	function createRequestObject()
	{
		var ro;
		if (window.XMLHttpRequest)
		{
			ro = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else ro = null;
		return ro;
	}
	
	this.http = createRequestObject();
	
	this.sendRequest = function(url)
	{
		this.http.open('get',url);
		this.http.onreadystatechange = this.handleResponse;
		this.http.send(null);
	}
	
	this.sendPostRequest = function(url,args)
	{
  	this.http.open('POST',url,true);
  	this.http.onreadystatechange = this.handleResponse;
  	this.http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  	this.http.send(args);
	}
	
	this.handleResponse = function()
	{
		if (obj.http.readyState == 4)
		{
			if (obj.http.status == 200)
			{
				// process response
				obj.whatToDo(obj.http.responseText);
			}
			else
			{
				// process error
				// TODO: add some sort of error handling here
				alert('ajax error: '+obj.http.status);
			}
		}
	}
}
