function ajaxObject(url,callbackFunction)
{
	var that=this;
	this.updating = false;
	this.abort = function()
	{
		if(that.updating)
		{
			that.updating=false;
			that.AJAX.abort();
			that.AJAX=null;
		}
	}
	this.update = function(passData,postMethod,cdiv)
	{
		var setdiv	= cdiv;
		if(that.updating){ return false; }
		that.AJAX = null;
		if(window.XMLHttpRequest)
		{
			that.AJAX=new XMLHttpRequest();
			if (that.AJAX.overrideMimeType)
			{
				//Das Ergebnis soll als XML-Dokument betrachtet werden.
				that.AJAX.overrideMimeType('text/xml');     
			}
		}
		else if (window.ActiveXObject)
		{ 
			try
			{
				that.AJAX=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}
		if (!that.AJAX)
		{ 
			alert('[AJAX FEHLER] Es kann kein Request Objekt erzeugt werden.'); 
			return false;
		}
		else
		{
			that.AJAX.onreadystatechange = function()
			{
				if(that.AJAX.readyState==4)
				{
					that.updating=false;
					that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML,setdiv);
				}
			}
			that.updating = new Date();
			if(/post/i.test(postMethod))
			{
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				that.AJAX.setRequestHeader("Content-Length", passData.length);
				that.AJAX.send(passData);
			}
			else
			{
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());
				that.AJAX.open("GET", uri, true);
				that.AJAX.send(null);
			}
			return true;
		}
	}
	var urlCall = url;
	this.callback = callbackFunction || function () {};
}

function processData(responseText, responseStatus,responseXML,responsediv)
{
	if (responseStatus==200)
	{
		cdiv=document.getElementById(responsediv);
		cdiv.innerHTML=responseText;
	}
}

function initProcessData(responsediv)
{
	cdiv=document.getElementById(responsediv);
	cdiv.innerHTML='<div class="axloading"><img src="/cms/upload/loading/17.gif" title="loading"></div>';
}

var arrAjaxObj = new Array();
function reqAjax(paURL,cdiv)
{
	requestURI			=	paURL.substr(0,(paURL.search(/\?/)));;
	query_string		=	paURL.substr((paURL.search(/\?/)+1));
	arrAjaxObj[cdiv] 	= 	new ajaxObject(requestURI, processData);
	arrAjaxObj[cdiv].update(query_string,'POST',cdiv);
}

function reqGetAjax(paURL,cdiv)
{
	requestURI			=	paURL.substr(0,(paURL.search(/\?/)));;
	query_string		=	paURL.substr((paURL.search(/\?/)+1));
	initProcessData(cdiv);
	arrAjaxObj[cdiv] 	= 	new ajaxObject(requestURI, processData);
	arrAjaxObj[cdiv].update(query_string,'GET',cdiv);
}


function ajxSaveHandler(mAction,mForm)
{

	XTCsname	=	mForm.sessionName.value;
	XTCsid		=	mForm.sessionID.value;

	if(mAction == 'assignePreveredHdl')
	{
		haendlerID		=	mForm.fk_tblext_haendler.value;
		customer_id		=	mForm.customer_id.value;
		cdiv		=	'dassignHdl';
		paURL	=	"/ajax.handler.php?ajxHandler=save&mAction=assignePreveredHdl&customer_id="+customer_id+"&haendlerID="+haendlerID+"&"+XTCsname+"="+XTCsid;
		reqGetAjax(paURL,cdiv);
	}
}
