var objAjxSearch;

function ajx_loadUrl(strLink, mixPostFunction, mixPreFunction, strPostData)
{

	if (typeof mixPostFunction != 'function')
	{
		alert('ajx_loadUrl Error' + " - Post Function is not a function");
		return false;
	}

	if (typeof mixPreFunction != 'function')
	{
		if (typeof showCoffeeLayer == 'function')
		{
			mixPreFunction = showCoffeeLayer
		} else if (typeof beheer_AjxPreFunction == 'function')
		{
			mixPreFunction = beheer_AjxPreFunction
		} else
		{
			alert('ajx_loadUrl Error' +  " - There is no showCoffeeLayer of beheer_AjxPreFunction function.");
			mixPreFunction = function () {
				//Blaat
			}
			return false;
		}

	}

	if(objAjxSearch == null)
	{
		objAjxSearch = new ajxGetXmlHttpObject();
	}
	if (objAjxSearch.readyState > 1) 
	{ 
		objAjxSearch.abort();
		objAjxSearch = new ajxGetXmlHttpObject();
		//return false;
	}
	mixPreFunction();
	method = "GET";
		if (strPostData!=null)
		{
				method = "POST";
		} else
		{
				strPostData = null;
		}
	objAjxSearch.onreadystatechange = mixPostFunction;
//	alert(objAjxSearch.readyState);
	objAjxSearch.open( method, strLink, true );
//	alert(objAjxSearch.readyState);
	counter = 0;
	if (method=="POST")
		{
		while(objAjxSearch.readyState<1)
		{
			// Just Wait (i hope)
			counter++;
			if (counter > 10)
			{
				objAjxSearch.open( method, strLink, true );
				counter = 0;
			}
		}
		try { objAjxSearch.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); } catch(e) { alert("Content-type, application/x-www-form-urlencoded"); }
		try { objAjxSearch.setRequestHeader("Content-length", strPostData.length); } catch(e) { alert("Content-length, "+ strPostData.length); }
		try { objAjxSearch.setRequestHeader("Connection", "close"); } catch(e) { alert("Connection, close"); }
		
		
		}
	try { objAjxSearch.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'); }
	catch(e) { noOneCares++; }
	try { objAjxSearch.send(strPostData); }
	catch(e) { noOneCares++; }
}

function ajxGetXmlHttpObject()
{
	var objXmlHttp = null;

	if (window.XMLHttpRequest)
	{
		objXmlHttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (objXmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return null;
	}
	else {
		return objXmlHttp;
	}
}
