function XmlAjaxLib(endPoint)
{
	// Generic endpoint, where the requests are sent
	this.EndPoint = endPoint;	
	
	// Random url key, auto appended to url when the method is GET
	this.GetRndKey = function ()
	{
		return Math.random()*10000;
	}
	
	// Combines the edpoint, action and the querystring, and key to a fully qualified url
	this.MakeUrl = function (action, querystring)
	{
		return endPoint + "&action="+action+"&"+querystring+"&rndkey="+this.GetRndKey();
	}
	
	// Syncronized GET, halt exceution until the data is recieved
	//
	// action		= the method to invoke at the endpoint
	// querystring	= parameterlist defined as a param-set. e.g: param1=xxx&param2=yyy 
	// destination	= id og object that recieves the data, if null the function returns the data as a string
	this.SyncGET = function (action, querystring, destination)
	{
		var url = this.MakeUrl(action, querystring);
		var s = tsAjax.innerHTML(url);
		if (destination!=null)
		{
			if (typeof (destination)=="string") document.getElementById(destination).innerHTML = s;
			else destination.innerHTML = s;
		}
		else return s;
	}
	
	// ASyncronized GET, execution continues and the callback is invoked when the data are ready
	//
	// action		= the method to invoke at the endpoint
	// querystring	= parameterlist defined as a param-set. e.g: param1=xxx&param2=yyy 
	// callback		= custom callback that is invoked when the data are ready. 
	//				  The method must abide to this format: function callbackname (action, XmlDoc [, extra1, extra2, extra3])
	// extra1-3		= custom parameters that can be supplieded to the callback
	this.ASyncGET = function (action, querystring, callback, extra1, extra2, extra3, extra4, extra5, extra6)
	{
		var key = this.GetRndKey();
		var url = this.MakeUrl(action, querystring);
		var storage = tsAjax.createInstance(action+key);
		storage.method="get";
		storage.doc = new XML();		
		storage.xmlCallback = callback;
		storage.instanceName = action;
		storage.extraItem1 = extra1;
		storage.extraItem2 = extra2;
		storage.extraItem3 = extra3;			
		storage.extraItem4 = extra4;
		storage.extraItem5 = extra5;
		storage.extraItem6 = extra6;			
		tsAjax.innerHTML(url,'tsAjax',action+key,null,null, this.xmlcallback);
	}
	
	// ToDo
	this.SyncPOST = function (action, querystring, form)
	{
		var url = this.MakeUrl(action, querystring);
		var storage = tsAjax.createInstance(action);
		storage.method="post";		
		var s = tsAjax.innerHTML(url,null,action);
		if (destination!=null)
		{
			if (typeof (destination)=="string") document.getElementById(destination).innerHTML = s;
			else destination.innerHTML = s;
		}
	}
	
	// ToDo
	this.ASyncPOST = function (action, querystring, formname, callback)
	{
		var url = this.MakeUrl(action, querystring);
		var storage = tsAjax.createInstance(action);
		if (formname) storage.getPostData(formname);
		storage.method="post";
		storage.doc = new XML();		
		storage.xmlCallback = callback;
		storage.instanceName = action;		
		tsAjax.innerHTML(url,'tsAjax',action, destination, status, this.xmlcallback);
	}   
	
	// The generic callback used to hook into the normal Tangora Ajax chain - invokes the custom callback when done
	this.xmlcallback = function () {
	if (this.ajaxObj!=null) {
		if (this.ajaxObj.readyState==4) {			
			var RT = this.ajaxObj.responseText;			
			if (this.statusElement!=null) {this.statusElement.innerHTML = this.statusText_Done;}
			if (this.resultElement!=null) {this.resultElement.innerHTML = RT}												
			this.doc.LoadXML(RT);			
			this.xmlCallback(this.instanceName, this.doc, this.extraItem1, this.extraItem2, this.extraItem3, this.extraItem4, this.extraItem5, this.extraItem6);
		} else {
			
		}			
	} else {
		var RT = this.IF.innerHTML;
		if (this.statusElement!=null) {this.statusElement.innerHTML = this.statusText_Done;}
		if (this.resultElement!=null) {this.resultElement.innerHTML = RT}
	}
}
}

// The global ajaxlib object
if (typeof(Util)=="undefined") Util = new Object();
//Util.AjaxLib = new XmlAjaxLib("http://"+location.host+"/services/proxy.ashx?endpoint=mail.ingelise.dk/Forlagsservice/ajax.ashx");
Util.AjaxLib = new XmlAjaxLib("http://"+location.host+"/services/proxy.ashx?endpoint=87.54.30.67/Forlagsservice/ajax.ashx");
//alert(document.domain);
//document.domain = "mail.ingelise.dk";
//Util.AjaxLib = new XmlAjaxLib("http://mail.ingelise.dk/Forlagsservice/ajax.ashx");