// ajax class

function createxhr()
{
	if(window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		return new ActiveXObject("Msxml2.XMLHTTP");
	}
}

function Ajax(url, properties)
{
	this.xhr = createxhr();
	if(!this.xhr)
	{
		throw new Error("Kon XMLHttpRequest niet aanmaken.");
	}
	
	this.postprops = null;
	if(properties.method == "GET")
	{
		this.xhr.open(properties.method, url + "?" + properties.vars, true);
	}
	else if(properties.method == "POST")
	{
		this.xhr.open(properties.method, url, true);
		this.xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.postprops = properties.vars;
	}
	
	this.xhr.onreadystatechange = function()
	{
		switch(this.readyState)
		{
			case 4: properties.onComplete(this); break;
		}
	}
}

function ajaxGet()
{
	this.xhr.send(this.postprops);
}

Ajax.prototype.get = ajaxGet;