if (typeof(RLdesign) === "undefined" || !RLdesign) {
	RLdesign = function() { }
}
if (!RLdesign.Utils) {
	RLdesign.Utils = function() {
		return {
			// returns a crossbrowser event object
			DefineEvent: function(e) {
				return e || window.event;
			},
	
			// tries to return an object from an arbitrary argument that can be a string or an object
			// if successfully finding an object, either from a search for the object-id or the object itself, 
			// returns the object. If unsuccessful, returns null
			DefineObject: function(el) {
				var elem = null;
				if (typeof(el) == "object") elem = el;
				else if (document.getElementById(el)) elem = document.getElementById(el);
				else if (typeof(el) == "string" && (el.indexOf("(") || el.indexOf("["))) eval("elem = " + el);
				else if (typeof(el) == "string") eval("elem = " + el);
				return elem;
			}
		}
	} ();
}


/// version 1.0.3.0



/// <summary>
/// Instantiates the namespace
/// </summary>
RLdesign.Xml = function() { };

RLdesign.Xml.GenericRemoteProvider = function(sProviderURL) {
	this.ready = false;
	this.isbusy = false;
	this.http = null;
	this.output = null;
	// mozilla, opera and IE7+
	if (typeof(XMLHttpRequest) != "undefined" || typeof(window.XMLHttpRequest) != "undefined") {
		try {
			this.ready = true;
			this.http = new XMLHttpRequest();
		}
		catch (e) {
			this.ready = false;
			this.http = null;
		}
	}
	// Internet Explorer up to v. 6
	if (this.http == null && typeof(ActiveXObject) != "undefined") {
		try {
			this.ready = true;
			this.http = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		}
		catch (e) {
			try {
				this.ready = true;
				this.http = new ActiveXObject("MSXML2.XMLHTTP");
			}
			catch (E) {
				try {
					this.http = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (eE) {
					this.ready = false;
					this.http = null;
				}
			}
		}
	}
	// IceBrowser
	if (this.http == null && typeof(window.createRequest) != "undefined") {
		try {
			this.ready = true;
			this.http = window.createRequest();
		}
		catch (e) {
			this.ready = false;
			this.http = null;
		}
	}
	if (this.http == null) {
		alert("No XMLHttpRequest object found.\nPlease use another browser, or activate ActiveX if you're using Internet Explorer");
	}
	if (!this.ready) return;
	if (sProviderURL != null && sProviderURL != "") {
		this.ready = true;
		this.providerurl = sProviderURL;
	}
	else {
		alert("No Provider-URL was provided.\nPlease contact a webmaster or administrator and make sure that an URL gets provided.");
	}
	
	this.AbortConnection = function() {
		if (this.ready) {
			try {
				var oHttp = this.http;
				oHttp.onreadystatechange = null;
				oHttp.abort();
				this.isbusy = false;
			}
			catch (err) {
				this.isbusy = false;
			}
		}
	}
	
	this.OpenConnection = function(fnReceivingFunction, oInput, bPassAlong) {
		if (this.ready) {
			var oThis = this;
			var oHttp = this.http;
			if (oHttp.readyState != 0 && oHttp.readyState != 4) {
				if (oThis.isbusy) oThis.isbusy = false;
				oHttp.onreadystatechange = function () {};
				oHttp.abort();
			}
			var sURL = this.providerurl;
			if (typeof(oInput) != "undefined" && typeof(oInput) == "object" && oInput != null) {
				var iCount = 0;
				for (var i in oInput) {
					if (typeof(oInput[i]) != "function") {
						sURL += (iCount == 0) ? "?" : "&";
						sURL += encodeURIComponent(i) + "=" + oInput[i];
						iCount++;
					}
				}
			}
			else if (typeof(oInput) == "string") {
				sURL += "?userInput=" + encodeURIComponent(oInput);
			}
			oHttp.open("get", sURL, true);
			oThis.isbusy = true;
			oHttp.onreadystatechange = function() {
				if (oHttp.readyState == 4 || oHttp.readyState == "complete") {
					// status=200: file found and loaded;
					// status=304: file found, but determined unchanged and loaded from cache
					if (oHttp.status == 200 || oHttp.status == 304) {
						var aReturnValues = null;
						if (oHttp.responseText && oHttp.responseText != "" && oHttp.responseText != " ") {
							//aReturnValues = eval("(" + oHttp.responseText + ")");
							aReturnValues = oHttp.responseText;
						}
						if (fnReceivingFunction != null) {
							fnReceivingFunction(aReturnValues, bPassAlong);
						}
						else {
							oThis.output = aReturnValues;
						}
					}
					oThis.isbusy = false;
				}
			}
			oHttp.send(null);
			if (fnReceivingFunction == null && this.output != null) {
				var out = this.output;
				this.output = null;
				return out;
			}
		}
	}
	this.OpenXMLConnection = function(fnReceivingFunction, oInput, bPassAlong) {
		if (this.ready) {
			var oThis = this;
			var oHttp = this.http;
			if (oHttp.readyState != 0 && oHttp.readyState != 4) {
				if (oThis.isbusy) oThis.isbusy = false;
				oHttp.onreadystatechange = function () {};
				oHttp.abort();
			}
			var sURL = this.providerurl;
			if (typeof(oInput) != "undefined" && typeof(oInput) == "object" && oInput != null) {
				var iCount = 0;
				for (var i in oInput) {
					if (typeof(oInput[i]) != "function") {
						sURL += (iCount == 0) ? "?" : "&";
						sURL += encodeURIComponent(i) + "=" + encodeURIComponent(oInput[i]);
						iCount++;
					}
				}
			}
			else if (typeof(oInput) == "string") {
				sURL += "?userInput=" + encodeURIComponent(oInput);
			}
			oHttp.open("get", sURL, true);
			// temporarily removed because of incompatibility with IE6
//			if (oHttp.setRequestHeader && oHttp.setRequestHeader != undefined) {
//				oHttp.setRequestHeader("Content-Type", "text/xml");
//			}
			oThis.isbusy = true;
			oHttp.onreadystatechange = function() {
				if (oHttp.readyState == 4 || oHttp.readyState == "complete") {
					// status=200: file found and loaded;
					// status=304: file found, but determined unchanged and loaded from cache
					if (oHttp.status == 200 || oHttp.status == 304) {
						var aReturnValues = null;
						if (typeof(oHttp.responseXML) != "undefined" && oHttp.responseXML != null) {
							aReturnValues = oHttp.responseXML;
						}
						fnReceivingFunction(aReturnValues, bPassAlong);
					}
					oThis.isbusy = false;
				}
			}
			oHttp.send(null);
		}
	}
	this.OpenSyncConnection = function(fnReceivingFunction, oInput, bPassAlong) {
		if (this.ready) {
			var oThis = this;
			var oHttp = this.http;
			if (oHttp.readyState != 0 && oHttp.readyState != 4) {
				if (oThis.isbusy) oThis.isbusy = false;
				oHttp.onreadystatechange = function () {};
				oHttp.abort();
			}
			var sURL = this.providerurl;
			if (typeof(oInput) != "undefined" && typeof(oInput) == "object" && oInput != null) {
				var iCount = 0;
				for (var i in oInput) {
					if (typeof(oInput[i]) != "function") {
						sURL += (iCount == 0) ? "?" : "&";
						sURL += encodeURIComponent(i) + "=" + encodeURIComponent(oInput[i]);
						iCount++;
					}
				}
			}
			else if (typeof(oInput) == "string") {
				sURL += "?userInput=" + encodeURIComponent(oInput);
			}
			oHttp.open("get", sURL, false);
			oThis.isbusy = true;
			oHttp.onreadystatechange = function() {
				if (oHttp.readyState == 4 || oHttp.readyState == "complete") {
					// status=200: file found and loaded;
					// status=304: file found, but determined unchanged and loaded from cache
					if (oHttp.status == 200 || oHttp.status == 304) {
						var aReturnValues = null;
						if (oHttp.responseText && oHttp.responseText != "" && oHttp.responseText != " ") {
							aReturnValues = eval("(" + oHttp.responseText + ")");
						}
						if (fnReceivingFunction != null) {
							fnReceivingFunction(aReturnValues, bPassAlong);
						}
						else {
							oThis.output = aReturnValues;
						}
					}
					oThis.isbusy = false;
				}
			}
			oHttp.send(null);
			if (fnReceivingFunction == null && this.output != null) {
				var out = this.output;
				this.output = null;
				return out;
			}
		}
	}
};