function Assert() {}
Assert.isTrue = function(value) {
	return (value == true);
};
Assert.isFalse = function(value) {
	return (value == false);
};
Assert.same = function(value1, value2) {
	return (value1 == value2);
};
Assert.notSame = function(value1, value2) {
	return !Assert.same(value1, value2);
};
Assert.isNull = function(value) {
	return (value == null);
};
Assert.notNull = function(value) {
	return !Assert.isNull(value);
};
Assert.isEmpty = function(value) {
	return (value == null || value == "");
};
Assert.isNotEmpty = function(value) {
	return !Assert.isEmpty(value);
};Array.prototype.add = function(value) {
	for (var i = 0; i < arguments.length; i++) {
		this[this.length] = arguments[i];
	}
	return this.length;
};
Array.prototype.remove = function(value) {
	for (var i = 0; i < arguments.length; i++) {
		for (var j = 0; j < this.length; j++) {
			if (this[j] == arguments[i]) {
				for (var k = j; k < this.length - 1; k++) {
					this[k] = this[k + 1];
				}
				this.length--;
			}
		}
	}
	return this;
};
Array.prototype.removeByIndex = function(index) {
	for (var i = 0; i < arguments.length; i++) {
		for (j = 0; j < this.length; j++) {
			if (j == arguments[i]) {
				for (var k = j; k < this.length - 1; k++) {
					this[k] = this[k + 1];
				}
				this.length--;
			}
		}
	}
	return this;
};
Array.prototype.clear = function() {
	this.length = 0;
	return this;
};
Array.prototype.isEmpty = function() {
	return this.length == 0;
};
Array.prototype.merge = function(array) {
	var p = this.length;
	for (i = 0; i < arguments.length; i++) {
		this.length += arguments[i].length;
		for (j = 0; j < arguments[i].length; j++) {
			this[p] = arguments[i][j];
			p++;
		}
	}
	return this;
};
Array.prototype.indexOf = function(value) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == value) {
			return i;
		}
	}
	return -1;
};
Array.prototype.contains = function(value) {
	for (i = 0; i < arguments.length; i++) {
		if (this.indexOf(arguments[i]) == -1) {
			return false;
		}
	}
	return true;
};
Array.prototype.shuffle = function() {
	for (var j, x, i = this.length; i; j = parseInt(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
	return this;
};
Array.prototype.implode = function(glue) {
	var text = "";
	if (glue == null) {
		glue = "";
	}
	for (i = 0; i < this.length; i++) {
		if (i > 0) {
			text += glue;
		}
		text += this[i];
	}
	return text;
};String.prototype.contains = function(string) {
	return (this.indexOf(string) != -1);
};
String.prototype.startsWith = function(string) {
	return this.indexOf(string) == 0;
};
String.prototype.endsWith = function(string) {
	return this.substring(this.length - string.length, this.length) == string;
};
String.prototype.replaceAll = function(find, replace) {
	return this.replace(new RegExp(find, "gi"), replace);
};
String.prototype.escape = function() {
	return escape(this).replaceAll("\\+", "%2B").replaceAll("\n", "%0A").replaceAll("/", "%2F");
};
String.prototype.ltrim = function() {
	return this.replace(/^\s+/, "");
};
String.prototype.rtrim = function() {
	return this.replace(/\s+$/, "");
};
String.prototype.trim = function() {
	return this.ltrim().rtrim();
};
String.prototype.pad = function(length, character) {
	var loop = (length < 0) ? -length : length;
	if (loop - this.length <= 0) {
		return this;
	}
	var pad = "";
	for (var i = 0; i < loop - this.length; i++) {
		pad += character;
	}
	if (length > 0) {
		return this + pad;
	}
	return pad + this;
};
String.prototype.explode = function(separator, chunks) {
	if (chunks <= 1) {
		return this;
	}
	var parts = this.split(separator);
	if (chunks == null || parts.length <= chunks) {
		return parts;
	}
	var loop = parts.length - chunks;
	for (var i = 0; i < loop; i++) {
		parts[parts.length - 2] += separator + parts.pop();
	}
	return parts;
};
String.prototype.url2obj = function() {
	var string = this;
	var pos = string.indexOf("?");
	if (pos != -1) { string = string.substring(pos + 1); }
	var pairs = string.split("&");
	var obj = {};
	for (var p = 0; p < pairs.length; p++) {
		pairs[p] = pairs[p].explode("=", 2);
		obj[pairs[p][0]] = pairs[p][1];
	}
	return obj;
};
String.prototype.stripComments = function() {
	return this.replace(/<!(--.*--)?>/g, "");
};
String.prototype.stripHTML = function(entities, allowed) {
	var string = this.stripComments();
	if (arguments.length == 0) {
		string = string.replace(/<\/?(?!\!)[^>]*>/gi, "");
	} else if (allowed) {
		var regExp = "<\/?(?!(" + entities.join("|") + ")\\b)\\b[^>]*>";
		string = string.replace(new RegExp(regExp, "gi"), "");
	} else {
		var regExp = "<\/?(" + entities.join("|") + ")(\\s+[^>]*)?>";
		string = string.replace(new RegExp(regExp, "gi"), "");
	}
	return string;
};
String.prototype.$ = function() {
	try {
		return $(String(this));
	} catch(e) {
		alert(e.message);
	}
	return null;
};Function.prototype.method = function(name, func) {
	this.prototype[name] = func;
	return this;
};
Function.prototype.inheritsFrom = function(parentClass) {
	function inheritance() {};
	inheritance.prototype = parentClass.prototype;
	this.prototype = new inheritance();
	this.prototype.constructor = this;
	this.superConstructor = parentClass;
	this.superClass = parentClass.prototype;
	return this;
};
Function.prototype.inherits = function(parent) {
	var d = {}, p = (this.prototype = new parent());
	this.method("uber", function(name) {
		if (!(name in d)) {
			d[name] = 0;
		}
		var f, r, t = d[name], v = parent.prototype;
		if (t) {
			while (t) {
				v = v.constructor.prototype;
				t -= 1;
			}
			f = v[name];
		} else {
			f = p[name];
			if (f == this[name]) {
				f = v[name];
			}
		}
		d[name] += 1;
		r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
		d[name] -= 1;
		return r;
	});
	return this;
};var Debugger = new function() {
	this.target = null;
	this.visible = false;
	this.maxLines = 25;
	this.lines = 0;
	this.createWindow = function(options) {
		if (options == null) {
			options = "toolbar,width=800,height=600,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes";
		}
		return window.open("", "debugWindow", options);
	};
	this.writeInWindow = function(message, options) {
		var debugWindow = this.createWindow();
		if (debugWindow != null) {
			debugWindow.document.write(message);
			debugWindow.document.close();
		}
		return this;
	};
	this.write = function() {
		var message = "", value;
		for (var i = 0; i < arguments.length; i++) {
			value = arguments[i];
			if (i > 0) {
				message += "<br />\n<br />\n";
			}
			if (typeof(value) == "string") {
				message += value;
			} else if (typeof(value) == "object") {
				message += GlobalKit.getElementTree(value, 2);
			}
		}
		if (message != "") {
			if (this.target != null) {
				if (this.lines == this.maxLines) {
					this.lines = 0;
					$(this.target).update("<b>" + new Date() + "</b><br /><br />" + message + "<hr />");
				} else {
					$(this.target).prepend("<b>" + new Date() + "</b><br /><br />" + message + "<hr />");
				}
				this.lines++;
				this.show();
				return this;
			}
			this.writeInWindow(message);
		}
		return this;
	};
	this.setTarget = function(target) {
		this.target = target;
		if (target != null && this.isVisible()) {
			this.show();
		}
		return this;
	};
	this.isVisible = function(visible) {
		if (visible == null) {
			return this.visible;
		}
		this.visible = visible;
		return this;
	};
	this.show = function() {
		this.isVisible(true);
		if (this.target != null) {
			this.target.show();
		}
		return this;
	};
	this.hide = function() {
		this.isVisible(false);
		if (this.target != null) {
			this.target.hide();
		}
		return this;
	};
};function createXmlHttpObject() {
	var xmlHttp;
	if (window.ActiveXObject) {
		var ie_versions = [
		        "MSXML2.XMLHttp.6.0", 
				"MSXML2.XMLHttp.5.0", 
				"MSXML2.XMLHttp.4.0", 
				"MSXML2.XMLHttp.3.0", 
				"MSXML2.XMLHttp", 
				"Microsoft.XMLHttp"
			];
		for (var i = 0; i < ie_versions.length; i++) {
			try {
				xmlHttp = new ActiveXObject(ie_versions[i]);
				break;
			} catch (error) {
				xmlHttp = null;
			}
		}
		if (xmlHttp == null) {
			alert("Error: Did not find Ajax-support!");
		}
	} else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}
function Ajax(element, url, callBack, onLoad, onSuccess, onFailure, async, method, context) {
	this.xmlHttp = createXmlHttpObject();
	this.element = element;
	this.url = url;
	this.callBacks = (callBack == null) ? new Array() : new Array(callBack);
	if (onLoad == null) {
		onLoad = function() {
		};
	}
	this.onLoad = onLoad;
	if (onSuccess == null) {
		onSuccess = function(response, callBacks, context) {
			if (element != null) {
				element.innerHTML = response;
			}
			for (var i = 0; i < callBacks.length; i++) {
				if (callBacks[i] != null) {
					callBacks[i].call(this, response, context);
				}
			}
		};
	}
	this.onSuccess = onSuccess;
	if (onFailure == null) {
		onFailure = function(response) {
			alert("Failure: " + response);
		};
	}
	this.onFailure = onFailure;
	this.async = true;
	if (async == false) {
		this.async = false;
	}
	if (method == null) { method = "POST"; }
	this.method = method;
	this.context = context;
}
Ajax.prototype.addCallBack = function(callBack) {
	this.callBacks.add(callBack);
};
Ajax.prototype.clearCallBacks = function() {
	this.callBacks.clear();
};
Ajax.prototype.request = function() {
	if (this.xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return;
	}
	var onLoad = this.onLoad;
	onLoad(this.context);
	var url;
	if (this.url.indexOf("?", 0) == -1) {
		url = this.url + "?";
	} else {
		url = this.url + "&";
	}
	url = url + "sid=" + Math.random();
	if (this.method == "POST") {
		this.xmlHttp.open(this.method, url.substr(0, url.indexOf("?")), this.async);
	} else {
		this.xmlHttp.open(this.method, url, this.async);
	}
	if (this.method == "POST") {
		var params = url.substr(url.indexOf("?") + 1);
		this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlHttp.setRequestHeader("Content-length", params.length);
		this.xmlHttp.setRequestHeader("Connection", "close");
	}
	var xmlHttp = this.xmlHttp;
	var element = this.element;
	var onSuccess = this.onSuccess;
	var onFailure = this.onFailure;
	var callBacks = this.callBacks;
	var context = this.context;
	this.xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 0) {
		} else if (xmlHttp.readyState == 1) {
		} else if (xmlHttp.readyState == 2) {
		} else if (xmlHttp.readyState == 3) {
		} else if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				onSuccess(xmlHttp.responseText, callBacks, context);
			} else if (xmlHttp.status == 403) {
				onFailure("AJAX error: Access denied to page!", context);
			} else if (xmlHttp.status == 404) {
				onFailure("AJAX error: Page '" + url + "' not found!", context);
			} else if (xmlHttp.status != 0) {
				onFailure("AJAX error: Unknown error " + xmlHttp.status + "!", context);
			}
		}
	};
	this.xmlHttp.send((this.method == "POST") ? params : null);
};
Ajax.prototype.abort = function() {
	try {
		this.xmlHttp.abort();
	} catch(e) {
		alert("Exception on aborting ajax request: " + e.message);
	}
};JSON = function(url, handler) {
	this.url = url;
	this.handler = handler;
};
JSON.parse = function(data) {
	return new Function("return " + data)();
};
JSON.stringify = function(element) {
	var json = "";
	if (typeof element == "string") {
		json += "\"" + element.replaceAll("\"", "\\\"") + "\"";
	} else if (GlobalKit.isArray(element)) {
		json += "[ ";
		for (var i = 0; i < element.length; i++) {
			json += (i > 0) ? ", " : "";
			json += JSON.stringify(element[i]);
		}
		json += " ]";
	} else if (typeof element == "object") {
		json += "{ ";
		var i = 0;
		for (var child in element) {
			var key = new String(child);
			var value = element[key];
			json += (i > 0) ? ", " : "";
			json += "\"" + key + "\": " + JSON.stringify(value);
			i++;
		}
		json += " }";
	} else {
		json += element;
	}
	return json;
};
JSON.prototype.request = function() {
	new Ajax(null, this.url, null, null, this.handler).request();
};function GlobalKit() {}
GlobalKit.classExists = function(c) {
	return (typeof(c) == "function" && typeof(c.prototype) == "object");
};
GlobalKit.isArray = function(array) {
	return !(!array || (!array.length || array.length == 0) || typeof array !== 'object' || !array.constructor || array.nodeType || array.item); 
};
GlobalKit.isString = function(string) {
	return typeof(string) == "string";
};
GlobalKit.browser = function() {
	return navigator.appVersion;
};
GlobalKit.screenWidth = function() {
	var h = 0;
	if (typeof(window.innerWidth) == "number") {
		h = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		h = document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		h = document.body.clientWidth;
	}
	return h;
};
GlobalKit.screenHeight = function() {
	var h = 0;
	if (typeof(window.innerHeight) == "number") {
		h = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		h = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		h = document.body.clientHeight;
	}
	return h;
};
GlobalKit.keyCode = function(e) {
	if (!e) { e = window.event; }
	if (e.which) { return e.which; }
	return e.keyCode ? e.keyCode : e.charCode; 
};
GlobalKit.scrollPos = function() {
	var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
	var dsocleft = document.all ? iebody.scrollLeft : pageXOffset;
	var dsoctop = document.all ? iebody.scrollTop : pageYOffset;
	return { x: dsocleft, y: dsoctop };
};
GlobalKit.mousePos = function(e) {
	if (e.pageX && e.pageY) {
		return { x: e.pageX, y: e.pageY};
	}
	var x = e.clientX;
	var y = e.clientY;
	if (document.body) {
		x += (document.body.scrollLeft) ? document.body.scrollLeft : 0;
		x -= (document.body.clientLeft) ? document.body.clientLeft : 0;
		y += (document.body.scrollTop) ? document.body.scrollTop : 0;
		y -= (document.body.clientTop) ? document.body.clientTop : 0;
	}
	return { x: x, y: y };
};
GlobalKit.stopEvent = function(e) {
	if (!e) e = window.event;
	e.cancelBubble = true;
	e.returnValue = false;
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	return false;
};
GlobalKit.d2h = function(value) {
	return parseInt(value).toString(16);
};
GlobalKit.h2d = function(value) {
	return parseInt(value, 16);
};
GlobalKit.rgb2h = function(rgb) {
	rgb = rgb.replace(/rgb\(|\)/g, "").split(",");
	rgb[0] = parseInt(rgb[0], 10).toString(16).toLowerCase();
	rgb[1] = parseInt(rgb[1], 10).toString(16).toLowerCase();
	rgb[2] = parseInt(rgb[2], 10).toString(16).toLowerCase();
	rgb[0] = (rgb[0].length == 1) ? "0" + rgb[0] : rgb[0];
	rgb[1] = (rgb[1].length == 1) ? "0" + rgb[1] : rgb[1];
	rgb[2] = (rgb[2].length == 1) ? "0" + rgb[2] : rgb[2];
	return "#" + rgb.join("");
};
GlobalKit.filesize2words = function(size) {
	var count = 0;
	var format = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
	while ((size / 1024) > 1 && count < 8) {
		size = size / 1024;
		count++;
	}
	if (size < 10) {
		decimals = 1;
	} else {
		decimals = 0;
	}
	return (Math.round(100 * size) / 100) + " " + format[count];
};
/**
 * Convert an object to a URL-string by converting the first level keys to parameter names and the first
 * level values to parameter values.
 * 
 * @param Object obj		The object to convert.
 * 
 * @return String			The URL-string.
 **/
GlobalKit.obj2url = function(obj) {
	var url = "", key, first = true;
	// Build the URL:
	for (key in obj) {
		if (first) {
			first = false;
		} else {
			url += "&";
		}
		url += key + "=" + obj[key];
	}
	return url;
};
GlobalKit.getDOMDepth = function(obj) {
	var depth = 0;
	if (obj.parentNode) {
		do {
			depth++;
		} while ((obj = obj.parentNode));
	}
	return depth;
};
GlobalKit.getElementTree = function(element, maxDepth) {
	text = "";
	if (element == null || maxDepth == 0) {
		return text;
	}
	text += "<table style='background-color: #cccccc; border: 1px solid #000000;'>";
	for (var param in element) {
		try {
			var value = new String(element[param]);
			value = value.replaceAll("<script>", "");
			value = value.replaceAll("</script>", "");
			value = value.replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\n", "\n<br>");
			text += "<tr><td style='background-color: #eeeeee; vertical-align: top; border: 1px solid #000000; border-right: 1px solid #eeeeee; text-align: right;'>" + param + "</td><td style='background-color: #ffffff; vertical-align: top; border: 1px solid #000000; border-left: 1px solid #eeeeee;' valign='top' nowrap>";
			if (GlobalKit.isArray(element[param])) {
				text += "<table style='background-color: #cccccc; border: 1px solid #000000;'><tr><th colspan='2'>Array</th></tr>";
				for (var i = 0; i < element[param].length; i++) {
					text += "<tr><td style='background-color: #eeeeee; vertical-align: top; border: 1px solid #000000; border-right: 1px solid #eeeeee; text-align: right;'>" + i + "</td><td style='background-color: #ffffff; vertical-align: top; border: 1px solid #000000; border-left: 1px solid #eeeeee;' valign='top' nowrap>";
					text += element[param][i];
					text += "</td></tr>";
				}
				text += "</table>";
			} else if (typeof(element[param]) == "object") {
				text += GlobalKit.getElementTree(element[param], maxDepth - 1);
			} else {
				text += value;
			}
			text += "</td></tr>";
		} catch(error) {
			text += "<tr><td style='background-color: #eeeeee; vertical-align: top; border: 1px solid #000000; border-right: 1px solid #eeeeee; text-align: right;'>ERROR</td><td style='background-color: #ffffff; vertical-align: top; border: 1px solid #000000; border-left: 1px solid #eeeeee;' valign='top' nowrap>";
			text += error.descripton;
			text += "</td></tr>";
		}
	}
	text += "</table>";
	return text;
};
GlobalKit.disableSelection = function(element) {
	if (typeof element.onselectstart != "undefined") {
		element.onselectstart = function() {
			return false;
		};
	} else if (typeof element.style.MozUserSelect!="undefined") {
		element.style.MozUserSelect = "none";
	} else {
		element.onmousedown = function() {
			return false;
		};
		element.style.cursor = "default";
	}
};
GlobalKit.getValues = function(element, tagName, mode, values) {
	if (!element) { return {}; }
	tagName = !tagName ? "ALL" : tagName.toUpperCase();
	mode = !mode ? "OBJ" : mode.toUpperCase();
	values = (!values) ? {} : values;
	if (tagName == "ALL") {
		values = GlobalKit.getValues(element, "SELECT", "OBJ", values);
		values = GlobalKit.getValues(element, "TEXTAREA", "OBJ", values);
		tagName = "INPUT";
	}
	var els = element.getElementsByTagName(tagName);	
	for (var i = 0; i < els.length; i++) {
		var el = els[i];
		var param = el.name ? el.name : el.id;
		var value = el.value;
		if (el.type == "checkbox") {
			if (el.checked) {
				values[param] = value;
			}
		} else if (el.type == "hidden") {
			values[param] = value;
		} else if (el.type == "password") {
			values[param] = value;
		} else if (el.type == "radio") {
			if (el.checked) {
				values[param] = value;
			}
		} else if (el.type == "select-one") {
			values[param] = value;
		} else if (el.type == "select-multiple") {
			var options = [];
			for (var j = 0; j < el.options.length; j++) {
				if (el.options[j].selected) {
					options.add(el.options[j].value);
				}
			}
			values[param] = options;
		} else if (el.type == "submit") {
			values[param] = value;
		} else if (el.type == "text") {
			values[param] = value;
		} else if (el.type == "textarea") {
			values[param] = value;
		}
	}
	if (mode == "URL") {
		var text = "";
		var first = true;
		for (param in values) {
			text += !first ? "&" : "";
			text += param + "=" + values[param].toString().escape();
			first = false;
		}
		values = text;
	} else if (mode == "JSON") {
		var temp = JSON.stringify(values);
		values = temp;
	}
	return values;
};
GlobalKit.getVars = function(element, tagName) {
	var getstr = "";
	if (tagName == null) {
		tagName = "INPUT";
		getstr = GlobalKit.getVars(element, "SELECT");
		getstr += GlobalKit.getVars(element, "TEXTAREA");
	}
	inputs = element.getElementsByTagName(tagName);
	for (var i = 0; i < inputs.length; i++){
		if (inputs[i].type == "checkbox") {
			if (inputs[i].checked) {
				getstr += (inputs[i].name + "=" + inputs[i].value + "&");
			}
		} else if (inputs[i].type == "hidden") {
			getstr += (inputs[i].name + "=" + inputs[i].value + "&");
		} else if (inputs[i].type == "password") {
			getstr += (inputs[i].name + "=" + inputs[i].value + "&");
		} else if (inputs[i].type == "radio") {
			if (inputs[i].checked) {
				getstr += (inputs[i].name + "=" + inputs[i].value + "&");
			}
		} else if (inputs[i].type == "select-one") {
			getstr += (inputs[i].name + "=" + inputs[i].value + "&");
		} else if (inputs[i].type == "submit") {
			getstr += ("submit=" + inputs[i].value + "&");
		} else if (inputs[i].type == "text") {
			getstr += (inputs[i].name + "=" + inputs[i].value + "&");
		} else if (inputs[i].type == "textarea") {
			getstr += (inputs[i].name + "=" + inputs[i].value.replaceAll("\n", "%0A") + "&");
		}
	}
	return getstr;
};
GlobalKit.loadedFiles = "";
GlobalKit._loadJS = function(filename) {
	if (GlobalKit.loadedFiles.indexOf("[" + filename + "]") != -1) {
		return;
	}
	new Ajax(null, filename, null, null, function(response) { eval(response); }).request();
	GlobalKit.loadedFiles += "[" + filename + "]";
};
GlobalKit.loadJS = function(filename) {
	if (GlobalKit.loadedFiles.indexOf("[" + filename + "]") != -1) {
		return;
	}
	var fileref = document.createElement("script");
	fileref.setAttribute("type", "text/javascript");
	fileref.setAttribute("src", filename);
	if (typeof fileref != "undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref);
		GlobalKit.loadedFiles += "[" + filename + "]";
	}
};
GlobalKit.loadCSS = function(filename) {
	if (GlobalKit.loadedFiles.indexOf("[" + filename + "]") != -1) {
		return;
	}
	var fileref = document.createElement("link");
	fileref.setAttribute("rel", "stylesheet");
	fileref.setAttribute("type", "text/css");
	fileref.setAttribute("href", filename);
	if (typeof fileref != "undefined") {
		document.getElementsByTagName("head")[0].appendChild(fileref);
		GlobalKit.loadedFiles += "[" + filename + "]";
	}
};
GlobalKit.css = function(style) {
	var head = document.getElementsByTagName("HEAD")[0];
	var elements = head.getElementsByTagName("STYLE");
	var element;
	if (elements.length == 0) {
		element = document.createElement("STYLE");
		element = head.appendChild(element);
	} else {
		element = elements[0];
	}
	if (element.styleSheet) {
		if (!element.styleSheet.cssText.contains(style)) {
			element.styleSheet.cssText += style;
		}
	} else if (!element.innerHTML.contains(style)) {
		element.innerHTML += style;
	}
};
document.getElementsByClassName = function(className, node, tag) {
	var elements = new Array();
	if (className == null) {
		return elements;
	}
	if (node == null) {
		node = document;
	}
	if (tag == null) {
		tag = "*";
	}
	var totalElements = node.getElementsByTagName(tag);
	var classNameRegExp = new RegExp("(^|\\s)" + className.replace(/\-/g, "\\-") + "(\\s|$)");
	for (var i = 0; i < totalElements.length; i++) {
		if (classNameRegExp.test(totalElements[i].className)) {
			elements.push(totalElements[i]);
		}
	}
	return elements;
};
if (typeof(DOMParser) == "undefined") {
	DOMParser = function() {};
	DOMParser.prototype.parsergbString = function(str, contentType) {
		if (typeof(ActiveXObject) != "undefined") {
			var xmldata = new ActiveXObject("MSXML.DomDocument");
			xmldata.async = false;
			xmldata.loadXML(str);
			return xmldata;
		} else if (typeof(XMLHttpRequest) != "undefined") {
			var xmldata = new XMLHttpRequest;
			if (!contentType) {
				contentType = "application/xml";
			}
			xmldata.open("GET", "data:" + contentType + ";charset=utf-8," + encodeURIComponent(str), false);
			if (xmldata.overrideMimeType) {
				xmldata.overrideMimeType(contentType);
			}
			xmldata.send(null);
			return xmldata.responseXML;
		}
		alert("Could not create DOMParser in globalkit.js!");
		return null;
	};
}function CSSRules() {};
CSSRules.head = document.getElementsByTagName("HEAD")[0];
CSSRules.style = document.createElement("STYLE");
CSSRules.style.type = "text/css";
CSSRules.head.appendChild(CSSRules.style);
CSSRules.add = function(selector, rule) {
	if (CSSRules.style.styleSheet) {
		CSSRules.style.styleSheet.cssText += selector + " { " + rule + " }";
	} else {
		CSSRules.style.appendChild(document.createTextNode(selector + " { " + rule + " }"));
	}
};function _$(els) {
	this.elements = [];
	for (var i = 0; i < els.length; i++) {
		var element = els[i];
		if (GlobalKit.isArray(element)) {
			for (var e = 0; e < element.length; e++) {
				this.addElement(element[e]);
			}
		} else if (typeof element == "string") {
			this.addElement(document.getElementById(element));
		} else {
			this.addElement(element);
		}
	}
	return this;
}
_$.prototype.$ = function(index) {
	if (index == null) {
		index = 0;
	}
	return this.elements[index];
};
_$.prototype.addElement = function(element) {
	for (var i = 0; i < arguments.length; i++) {
		if (arguments[i] != null) {
			if (!arguments[i].tweens) {
				arguments[i].tweens = [];
			}
			this.elements.push(arguments[i]);
		}
	}
	return this;
};
_$.prototype.removeElement = function(element) {
	for (var i = 0, len = this.elements.length; i < len; ++i) {
		for (var j = 0; j < arguments.length; j++) {
			if (this.elements[i] == arguments[j]) {
				this.elements.remove(arguments[j]);
				i--;
			}
		}
	}
	return this;
};
_$.prototype.each = function(func) {
	for (var i = 0, len = this.elements.length; i < len; ++i) {
		func.call(this, this.elements[i]);
	}
	return this;
};
_$.prototype.getElementsByTagName = function(tag, recursive) {
	var elements = [];
	tag = tag.toUpperCase();
	recursive = recursive ? true : false;
	this.each(function(element) {
		for (var i = 0; i < element.childNodes.length; i++) {
			if (element.childNodes[i].tagName == tag) {
				elements.add(element.childNodes[i]);
			}
			if (recursive) {
				elements.merge($(element.childNodes[i]).getElementsByTagName(tag, recursive).elements);
			}
		}
	});
	return new _$(elements);
};
_$.prototype.alert = function(message) {
	this.each(function(element) {
		alert("Element '" + element.id + "' alerts: " + message);
	});
	return this;
};
_$.prototype.debug = function(value) {
	var args = arguments;
	this.each(function(element) {
		var values = [];
		values.push("<b>Element '<em>" + element.id + "</em>' debug:</b>");
		for (var i = 0; i < args.length; i++) {
			if (args[i] == null) {
				values.push(element);
			} else {
				values.push(args[i]);
			}
		}
		try {
			Debugger.write.apply(Debugger, values).show();
		} catch(e) {
			$(element).alert("'" + e.name + "' in '_$.prototype.debug': " + e.message);
		}
	});
	return this;
};
_$.prototype.destroy = function() {
	this.each(function(element) {
		if (typeof element.destroy != "undefined") {
			element.destroy(element);
		} else {
			element.parentNode.removeChild(element);
		}
	});
	return this;
};
_$.prototype.update = function(html) {
	this.each(function(element) {
		if (typeof element.update != "undefined") {
			element.update(html);
		} else {
			element.innerHTML = html;
		}
	});
	return this;
};
_$.prototype.focus = function() {
	this.each(function(element) {
		element.focus();
	});
	return this;
};
_$.prototype.append = function(html) {
	this.each(function(element) {
		if (typeof element.append != "undefined") {
			element.append(html);
		} else {
			element.innerHTML += html;
		}
	});
	return this;
};
_$.prototype.prepend = function(html) {
	this.each(function(element) {
		if (typeof element.prepend != "undefined") {
			element.prepend(html);
		} else {
			element.innerHTML = html + element.innerHTML;
		}
	});
	return this;
};
_$.prototype.setStyle = function(property, value) {
	this.each(function(element) {
		if (property == "opacity") {
			$(element).setOpacity(value);
		} else if (property == "transparency") {
			$(element).setTransparency(value);
		}
		try {
			element.style[property] = value;
		} catch(e) {
			$(element).debug("Error in '_$.prototype.setStyle': " + e.message, element);
		}
	});
	return this;
};
_$.prototype.setEnabled = function(enabled) {
	this.each(function(element) {
		element.disabled = !enabled;
	});
	return this;
};
_$.prototype.setTitle = function(title) {
	this.each(function(element) {
		if (typeof element.setTitle != "undefined") {
			element.setTitle(title);
		} else {
			element.title = title;
		}
	});
	return this;
};
_$.prototype.getValues = function(tagName, mode, values) {
	values = (!values) ? {} : values;
	this.each(function(element) {
		values = GlobalKit.getValues(element, tagName, "OBJ", values);
	});
	var element = document.createElement("DIV");
	values = GlobalKit.getValues(element, tagName, mode, values);
	return values;
};
_$.prototype.getPos = function() {
	var curLeft = curTop = 0;
	var obj = this.elements[0];
	if (obj == null) {
		return {x: 0, y: 0, x2: 0, y2: 0 };
	}
	if (obj.offsetParent) {
		do {
			curLeft += obj.offsetLeft;
			curTop += obj.offsetTop;
		} while ((obj = obj.offsetParent));
	}
	return { x: curLeft, y: curTop };
};
_$.prototype.setPos = function(x, y) {
	if (x && x.x) {
		y = x.y;
		x = x.x;
	}
	x = !isNaN(x) ? x + "px" : x;
	y = !isNaN(y) ? y + "px" : y;
	this.each(function(element) {
		this.setStyle("left", x).setStyle("top", y);
	});
	return this;
};
_$.prototype.getBox = function() {
	var curLeft = curTop = curWidth = curHeight = 0;
	var obj = this.elements[0];
	curWidth = obj.offsetWidth;
	curHeight = obj.offsetHeight;
	if (obj.offsetParent) {
		do {
			curLeft += obj.offsetLeft;
			curTop += obj.offsetTop;
		} while ((obj = obj.offsetParent));
	}
	return { x: curLeft, y: curTop, x2: curLeft + curWidth, y2: curTop + curHeight, w: curWidth, h: curHeight };
};
_$.prototype.childOf = function(parent) {
	var allFound = true;
	this.each(function(element) {
		var found = false;
		do {
			found = (element.parentNode == parent);
		} while (!found && (element = element.parentNode));
		allFound = allFound & found;
	});
	return allFound;
};
_$.prototype.getStyle = function(property) {
	var style;
	try {
		var style = this.elements[0].style[property];
	} catch(e) {
		this.debug("Error in '_$.prototype.setStyle': " + e.message, element);
		return "";
	}
	return style;
};
_$.prototype.hasClass = function(className) {
	var match = true;
	this.each(function(element) {
		if (!element.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"))) {
			match = false;
		}
	});
	return match;
};
_$.prototype.addClass = function(className) {
	this.each(function(element) {
		if (!$(element).hasClass(className)) {
			element.className += " " + className;
		}
	});
	return this;
};
_$.prototype.removeClass = function(className) {
	this.each(function(element) {
		if ($(element).hasClass(className)) {
			var reg = new RegExp("(\\s|^)" + className + "(\\s|$)");
			element.className = element.className.replace(reg, " ");
		}
	});
	return this;
};
_$.prototype.toggleClass = function(className) {
	this.each(function(element) {
		if ($(element).hasClass(className)) {
			$(element).removeClass(className);
		} else {
			$(element).addClass(className);
		}
	});
	return this;
};
_$.prototype.css = function(properties) {
	var that = this;
	for (var property in properties) {
		that.setStyle(property, properties[property]);
	}
	return this;
};
_$.prototype.setColor = function(color) {
	return this.setStyle("color", color);
};
_$.prototype.setBColor = function(color) {
	return this.setStyle("backgroundColor", color);
};
_$.prototype.show = function() {
	this.each(function(element) {
		if (typeof element.show != "undefined") {
			element.show();
		} else {
			element.style["display"] = "block";
			element.style["visibility"] = "visible";
		}
	});
	return this;
};
_$.prototype.hide = function() {
	this.each(function(element) {
		if (typeof element.hide != "undefined") {
			element.hide();
		} else {
			element.style["display"] = "none";
			element.style["visibility"] = "hidden";
		}
	});
	return this;
};
_$.prototype.toggle = function() {
	this.each(function(element) {
		if (element.style["display"] == "" && element.style["visibility"] == "") {
			$(element).hide();
		} else if (element.style["display"] == "none" || element.style["visibility"] == "hidden") {
			$(element).show();
		} else if (element.style["display"] == "block" || element.style["visibility"] == "visible") {
			$(element).hide();
		}
	});
	return this;
};
_$.prototype.on = function(type, func) {
	var listen = function(element) {
		if (window.addEventListener) {
			element.addEventListener(type, func, false);
		} else if (window.attachEvent) {
			element.attachEvent("on" + type, function() {
				func.call(element, window.event);
			});
		}
	};
	this.each(function(element) {
		listen(element);
	});
	return this;
};
_$.prototype.addEvent = function(type, func) {
	return this.on(type, func);
};
_$.prototype.request = function(url, callBack, onLoad, onSuccess, onFailure, async, method, context) {
	this.each(function(element) {
		element.ajax = new Ajax(element, url, callBack, onLoad, onSuccess, onFailure, async, method, context);
		element.ajax.request();
	});
	return this;
};
_$.prototype.refresh = function() {
	this.each(function(element) {
			element.ajax.request();
	});
	return this;
};
_$.prototype.setOpacity = function(percentage) {
	if (percentage < 0) {
		percentage = 0;
	}
	if (percentage > 100) {
		percentage = 100;
	}
	this.each(function(element) {
		if (percentage == 100) {
			element.style.opacity = "1.0";
		} else {
			if (percentage < 10) {
				percentage = "0" + percentage;
			}
			element.style.opacity = "0." + percentage;
		}
		if (element.style) {
			element.style["filter"] = "alpha(opacity=" + percentage + ");";
		}
	});
	return this;
};
_$.prototype.setTransparency = function(percentage) {
	return this.setOpacity(100 - percentage);
};
_$.prototype.stopTweens = function() {
	this.each(function(element) {
		for (var i = 0; i < element.tweens.length; i++) {
			element.tweens[i].stop();
		}
		element.tweens.clear();
	});
	return this;
};
_$.prototype.moveX = function(fromX, toX, duration, type, fps, suffix) {
	if (fromX == null || toX == null) {
		return this;
	} else {
		fromX = parseInt(fromX);
		toX = parseInt(toX);
		fps = parseInt(fps);
	}
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (suffix == null) {
		suffix = "px";
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	this.each(function(element) {
		var tween = new Tween(element, "left", fromX, toX, suffix, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.moveY = function(fromY, toY, duration, type, fps, suffix) {
	if (fromY == null || toY == null) {
		return this;
	} else {
		fromY = parseInt(fromY);
		toY = parseInt(toY);
		fps = parseInt(fps);
	}
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (suffix == null) {
		suffix = "px";
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	this.each(function(element) {
		var tween = new Tween(element, "top", fromY, toY, suffix, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.move = function(fromX, fromY, toX, toY, duration, type, fps, suffix) {
	this.moveX(fromX, toX, duration, type, fps, suffix);
	this.moveY(fromY, toY, duration, type, fps, suffix);
	return this;
};
_$.prototype.moveTo = function(toX, toY, duration, type, fps) {
	this.each(function(element) {
		var fromX = parseInt($(element).getStyle("left").replace("px", "").replace("%", ""));
		var fromY = parseInt($(element).getStyle("top").replace("px", "").replace("%", ""));
		var suffixX = element.style["left"].contains("%") ? "%" : "px";
		var suffixY = element.style["top"].contains("%") ? "%" : "px";
		$(element).moveX(fromX, toX, duration, type, fps, suffixX);
		$(element).moveY(fromY, toY, duration, type, fps, suffixY);
	});
	return this;
};
_$.prototype.fade = function(from, to, duration, type, fps) {
	if (from == null) {
		from = 0;
	} else {
		from = parseInt(from);
	}
	if (to == null) {
		to = 100;
	} else {
		to = parseInt(to);
	}
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (type == null) {
		type = Tween.linear;
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	this.each(function(element) {
		var tween = new Tween(element, "transparency", from, to, null, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.fadeTo = function(to, duration, type, fps) {
	return this.alert("function 'fadeTo' not yet implemented!");
};
_$.prototype.colorFade = function(from, to, duration, type, fps) {
	from = from.replace("#", "");
	to = to.replace("#", "");
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (type == null) {
		type = Tween.linear;
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	this.each(function(element) {
		var tween = new Tween(element, "backgroundColor", from, to, null, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.colorFadeTo = function(to, duration, type, fps) {
	this.each(function(element) {
		var from = element.style["backgroundColor"];
		if (from == "") {
			from = "#ffffff";
		} else if (from.indexOf("rgb") != -1) {
			from = GlobalKit.rgb2h(from);
		}
		$(element).colorFade(from, to, duration, type, fps);
	});
	return this;
};
_$.prototype.resizeWidth = function(fromWidth, toWidth, duration, type, fps, suffix) {
	fromWidth = parseInt(fromWidth);
	toWidth = parseInt(toWidth);
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (type == null) {
		type = Tween.linear;
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	if (suffix == null) {
		suffix = "px";
	}
	this.each(function(element) {
		var tween = new Tween(element, "width", fromWidth, toWidth, suffix, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.resizeHeight = function(fromHeight, toHeight, duration, type, fps, suffix) {
	fromHeight = parseInt(fromHeight);
	toHeight = parseInt(toHeight);
	if (duration == null) {
		duration = Tween.defaultDuration;
	} else {
		duration = parseInt(duration);
	}
	if (type == null) {
		type = Tween.linear;
	}
	if (fps == null) {
		fps = Tween.defaultFPS;
	} else {
		fps = parseInt(fps);
	}
	if (suffix == null) {
		suffix = "px";
	}
	this.each(function(element) {
		var tween = new Tween(element, "height", fromHeight, toHeight, suffix, duration, type, fps);
		element.tweens.add(tween);
		tween.start();
	});
	return this;
};
_$.prototype.resize = function(fromWidth, fromHeight, toWidth, toHeight, duration, type, fps, suffix) {
	this.resizeWidth(fromWidth, toWidth, duration, type, fps, suffix);
	this.resizeHeight(fromHeight, toHeight, duration, type, fps, suffix);
	return this;
};
_$.prototype.resizeTo = function(toWidth, toHeight, duration, type, fps) {
	this.each(function(element) {
		var fromWidth = parseInt($(element).getStyle("width").replace("px", "").replace("%", ""));
		var fromHeight = parseInt($(element).getStyle("height").replace("px", "").replace("%", ""));
		var suffixWidth = $(element).getStyle("width").contains("%") ? "%" : "px";
		var suffixHeight = $(element).getStyle("height").contains("%") ? "%" : "px";
		if (toWidth != null) { $(element).resizeWidth(fromWidth, toWidth, duration, type, fps, suffixWidth); }
		if (toHeight != null) { $(element).resizeHeight(fromHeight, toHeight, duration, type, fps, suffixHeight); }
	});
	return this;
};
_$.prototype.submit = function(url, form, callBack, onLoad, onSuccess, onFailure, async, method) {
	if (form == null) {
		form = this.elements[0];
	}
	url += url.contains("?") ? "&" : "?";
	return this.request(url + GlobalKit.getValues(form, "ALL", "URL"), callBack, onLoad, onSuccess, onFailure, async, method);
};
_$.prototype.loadWidget = function(widgetName, parameters, callBack, onLoad, onSuccess, onFailure) {
	this.each(function(element) {
		Widget.load(element, widgetName, parameters, callBack, onLoad, onSuccess, onFailure);
	});
	return this;
};
_$.prototype.makeDraggable = function(dropObjects, graspHandler, dragHandler, releaseHandler) {
	this.each(function(element) {
		if (typeof element.makeDraggable != "undefined") {
			element.makeDraggable(dropObjects, graspHandler, dragHandler, releaseHandler);
		} else {
			Dragdropper.makeDraggable(element, dropObjects, graspHandler, dragHandler, releaseHandler);
		}
	});
	return this;
};
_$.prototype.makeDroppable = function(dragObjects, dropHandler) {
	this.each(function(element) {
		Dragdropper.makeDroppable(element, dragObjects, dropHandler);
	});
	return this;
};
_$.prototype.registerDragObject = function(dragObjects) {
	var draggables = [];
	for (var i = 0; i < arguments.length; i++) {
		var arg = arguments[i];
		if (GlobalKit.isArray(arg)) {
			draggables.merge(arg);
		} else if (arg instanceof DragObject) {
			draggables.add(arg);
		} else if (typeof(arg) == "string") {
			var dragObject = Dragdropper.getDragObject(document.getElementById(arg));
			if (dragObject != null) {
				draggables.add(dragObject);
			}
		} else {
			var dragObject = Dragdropper.getDragObject(arg);
			if (dragObject != null) {
				draggables.add(dragObject);
			}
		}
	}
	this.each(function(element) {
		var dropper = Dragdropper.getDropObject(element);
		if (dropper != null) {
			for (var i = 0; i < draggables.length; i++) {
				dropper.registerDragObject(draggables[i]);
			}
		} else {
			$(element).debug("This element cannot register drag object because it's not droppable!");
		}
	});
	return this;
};
_$.prototype.makeResizable = function() {
	this.each(function(element) {
		Dragdropper.makeResizable(element);
	});
	return this;
};
_$.prototype.click = function() {
	this.each(function(element) {
		element.onclick();
	});
	return this;
};
_$.prototype.attachMenu = function(menu) {
	return this.alert("function 'attachMenu' not yet implemented!");
};
_$.prototype.noSelect = function() {
	this.each(function(element) {
		if (typeof element.onselectstart != "undefined") {
			element.onselectstart = function() {
				return false;
			};
		} else if (typeof element.style.MozUserSelect != "undefined") {
			element.style.MozUserSelect = "none";
		} else {
			element.onmousedown = function() {
				return false;
			};
			element.style.cursor = "default";
		}
	});
	return this;
};
window.$ = function() {
	return new _$(arguments);
};
window.$$ = function() {
	var elements = [];
	for (var i = 0; i < arguments.length; i++) {
		var name = arguments[i];
		elements.merge(document.getElementsByName(name));
	}
	return elements;
};
window.$$$ = function() {
	var elements = [];
	for (var i = 0; i < arguments.length; i++) {
		var className = arguments[i];
		elements.merge(document.getElementsByClassName(className));
	}
	return elements;
};function Widget(id, wrapperEl, root, params, async, method) {
	this.id = id;
	this.wrapperEl = wrapperEl;
	this.root = root;
	this.params = GlobalKit.isString(params) ? params.url2obj() : params;
	this.async = async;
	this.method = method;
	return this;
};
Widget.prototype.getURL = function() {
	var url = this.root + "/index.php", key;
	if (this.params) {
		url += "?";
		var first = true;
		for (key in this.params) {
			if (first) { first = false; } else { url += "&"; }
			url += key + "=" + this.params[key];
		}
	}
	return url;
};
Widget.prototype.deploy = function() {
	$(this.wrapperEl).request(this.getURL(), this.callBack, this.onLoad, null, null, this.async, this.method, this);
	return this;
};
Widget.prototype.refresh = function(params) {
	params = GlobalKit.isString(params) ? params.url2obj() : params;
	for (var key in params) {
		this.params[key] = params[key];
	}
	return this.deploy();
};
Widget.prototype.callBack = function(response, context) {
};
Widget.prototype.onLoad = function(context) {
};
Widget.addClass = function() {
};
Widget.addCallBack = function() {
};
Widget.instances = {};
Widget.numInstances = function() {
	var size = 0, key;
	for (key in this.instances) {
		if (Widget.instances[key]) {
			size++;
		}
	}
	return size;
};
Widget.createInstance = function(id, element, type, params) {
	try {
		this.instances[id] = eval("new " + type + "(id, element, \"./Framework/Widgets/\" + type, params, false, \"POST\");");
	} catch(e) {
		this.instances[id] = new Widget(id, element, "./Framework/Widgets/" + type, params, false, "POST");
	}
	return this.instances[id];
};
Widget.getInstance = function(id, element, type, params) {
	if (id != null && this.instances[id]) {
		return this.instances[id];
	} else if (element != null && type != null && params != null) {
		return this.createInstance(id, element, type, params);
	}
	alert("Cannot get widget instance if the wrapper, type and parameters are missing!");
	return null;
};
Widget.removeInstance = function(id) {
	var widget = this.instances[id];
	delete this.instances[id];
	return widget;	
};
Widget.replaceHolder = function(holder, value, recreate) {
	var parts = value.split("?");
	var type = parts[0];
	var params = parts.remove(type).join("");
	return this.replace(holder, type, params, recreate);
};
Widget.replace = function(element, type, params, recreate) {
	if (!document.createElement || !document.childNodes ) {
		alert("Your browser is not DOM compliant!");
		return null;
	}
	var widgetWrapper = document.createElement("div");
	widgetWrapper.setAttribute("class", "widget_wrapper");
	element.parentNode.insertBefore(widgetWrapper, element);
	element.parentNode.removeChild(element);
	params = (params) ? params.url2obj() : {};
	if (!params.widgetId) {
		alert("Cannot create widget if no ID (widgetId) is set in the widget paremeters!");
		return null;
	}
	var id = params.widgetId;			
	var instance = recreate ? this.createInstance(id, widgetWrapper, type, params) : this.getInstance(id, widgetWrapper, type, params);
	return instance.deploy();
};
Widget.replaceAll = function(elements, recreate) {
	while (elements.length > 0) {
		var i = elements.length - 1;
		this.replaceHolder(elements[i], elements[i].value, recreate);
	}
};function Tween(element, property, begin, end, suffix, duration, type, fps, startTime, formatter) {
	if (property.toLowerCase().contains("color")) {
		begin 		= GlobalKit.h2d(begin);
		end 		= GlobalKit.h2d(end);
		fps 		= Tween.defaultFPS;
		formatter 	= Tween.colorFormatter;
	}
	this.element 		= Tween.ensureId(element);
	this.property 		= property;
	this.begin 			= begin;
	this.end 			= end;
	this.suffix 		= suffix;
	this.duration 		= (duration == null) ? Tween.defaultDuration : duration;
	this.animator 		= (type == null) ? Tween.linear : type;
	this.fps 			= (fps == null) ? Math.abs(this.end - this.begin) * 1000 / duration : fps;
	this.startTime		= (startTime == null) ? 0 : startTime;
	this.formatter 		= (formatter == null) ? Tween.defaultFormatter : formatter;
	// Working variables:
	this.timers 		= new Array();
	this.difference 	= Math.abs(this.end - this.begin);
	this.totalFrames 	= Math.ceil(this.duration * this.fps / 1000);
	this.timePerFrame 	= 1000 / this.fps;
	this.mul 			= this.difference / this.totalFrames;
	this.startFrame 	= this.startTime / this.timePerFrame;
}
Tween.defaultFPS = 30;
Tween.defaultDuration = 3000;
Tween.ensureId = function(element) {
	if (!element.id || element.id.length == 0) {
		var id;
		do {
			id = ("tween_" + Math.random()).replace("0\.", "");
		} while(document.getElementById(id) != null);
		element.id = id;
	}
	return element;
};
Tween.defaultFormatter = function(value, tween) {
	if (tween.suffix == null) {
		return Math.round(value);
	} else if (tween.suffix != "%") {
		value = Math.round(value);
	}
	return value + tween.suffix;
};
Tween.colorFormatter = function(value, tween) {
	var begin = GlobalKit.d2h(tween.begin).pad(-6, "0");
	var end = GlobalKit.d2h(tween.end).pad(-6, "0");
	var percent = value;
	if (tween.begin <= tween.end) {
		percent -= tween.begin;
		var r1 = GlobalKit.h2d(begin.slice(0, 2));
		var g1 = GlobalKit.h2d(begin.slice(2, 4));
		var b1 = GlobalKit.h2d(begin.slice(4, 6));
		var r2 = GlobalKit.h2d(end.slice(0, 2));
		var g2 = GlobalKit.h2d(end.slice(2, 4));
		var b2 = GlobalKit.h2d(end.slice(4, 6));
	} else {
		percent -= tween.end;
		var r1 = GlobalKit.h2d(end.slice(0, 2));
		var g1 = GlobalKit.h2d(end.slice(2, 4));
		var b1 = GlobalKit.h2d(end.slice(4, 6));
		var r2 = GlobalKit.h2d(begin.slice(0, 2));
		var g2 = GlobalKit.h2d(begin.slice(2, 4));
		var b2 = GlobalKit.h2d(begin.slice(4, 6));
	}
	percent /= tween.difference;
	// Calculate the new RGB:
    var r = Math.floor(r1 + (percent * (r2 - r1)) + .5);
    var g = Math.floor(g1 + (percent * (g2 - g1)) + .5);
    var b = Math.floor(b1 + (percent * (b2 - b1)) + .5);
	return ("#" + GlobalKit.d2h(r).pad(-2, "0") + GlobalKit.d2h(g).pad(-2, "0") + GlobalKit.d2h(b).pad(-2, "0"));
};
Tween.linear = function(tween) {
	return tween.currentFrame * tween.mul;
};
Tween.bounceOut = function(tween) {
	var domain = Math.PI;
	var domainMul = domain / tween.totalFrames;
	return ((Math.sin(tween.currentFrame * domainMul) * tween.totalFrames / 2 + (tween.currentFrame)) * tween.mul);
};
Tween.ease = function(tween) {
	var domain = 16;
	var domainShift = -domain / 2;
	var domainMul =  domain / tween.totalFrames;
	var reach = Math.PI * 11 / 12;
	var reachShift = reach / 2;
	var reachMul = tween.difference / reach;
	return (Math.atan(tween.currentFrame * domainMul + domainShift) + reachShift) * reachMul;
};
/**
 * The sinus tween animtion type.
 * 
 * @param Tween tween				The tween to animate.
 * 
 * @return mixed					The new property value (unformatted).
 **/
Tween.sinus = function(tween) {
	// The domain:
	var domain = Math.PI * 2;
	var domainMul = domain / tween.totalFrames;
	return ((Math.sin(tween.currentFrame * domainMul) * tween.totalFrames / 2 + tween.currentFrame) * tween.mul);
};
Tween.prototype.start = function() {
	for (var i = this.startFrame; i < this.totalFrames; i++) {
		this.currentFrame = i;
		var value = this.animator(this);
		if (this.currentFrame == this.startFrame) {
			value = this.begin;
		} else if (this.end >= this.begin) {
			value += this.begin;
		} else if (this.end < this.begin) {
			value = this.begin - value;
		}
		value = this.formatter(value, this);
		this.timeout(value, (this.currentFrame - this.startFrame) * this.timePerFrame);
	}
	value = this.formatter(this.end, this);
	this.timeout(value, this.duration - this.startTime);
};
Tween.prototype.stop = function() {
	for (var i = 0; i < this.timers.length; i++) {
		clearTimeout(this.timers[i]);
	}
	this.timers.clear();
	return this;
};
Tween.prototype.timeout = function(value, time) {
	this.timers.add(setTimeout('$("' + this.element.id + '").setStyle("' + this.property + '", "' + value + '")', time));
};function PopupWindow(id, x, y, w, h, title, transparency, icon, btnCfg) {
	if (PopupWindow.get(id) != null) {
		return PopupWindow.get(id);
	}
	this.id = id;
	this.x = (x == null) ? ((GlobalKit.screenWidth() - parseInt(w)) / 2) + "px" : x;
	this.y = (y == null) ? ((GlobalKit.screenHeight() - parseInt(h)) / 2) + "px" : y;
	this.w = w;
	this.h = h;
	this.title = title;
	this.transparency = (transparency == null) ? 50 : transparency;
	this.icon = icon;
	this.btnCfg = (btnCfg == null) ? ["center", "min", "max", "close"] : btnCfg;
	this.state = "normal";
	this.minWidth = 200;
	this.minHeight = 80;
	this.oncloseHandlers = [];
	this.init();
};
PopupWindow.windows = [];
PopupWindow.minimizedCols = 6;
PopupWindow.minimizedRows = 2;
PopupWindow.get = function(id) {
	for (var i = 0; i < PopupWindow.windows.length; i++) {
		if (PopupWindow.windows[i].id == id) {
			return PopupWindow.windows[i];
		}
	}
	return null;
};
PopupWindow.centerAll = function() {
	for (var i = 0; i < PopupWindow.windows.length; i++) {
		PopupWindow.windows[i].centerScreen();
	}
};
PopupWindow.minimizeAll = function() {
	for (var i = 0; i < PopupWindow.windows.length; i++) {
		PopupWindow.windows[i].minimize();
	}
};
PopupWindow.minimized = function() {
	var pos = 0;
	for (var i = 0; i < PopupWindow.windows.length; i++) {
		if (PopupWindow.windows[i].state == "min") {
			pos++;
		}
	}
	return pos;
};
PopupWindow.orderMinimized = function() {
	var pos = 0;
	for (var i = 0; i < PopupWindow.windows.length; i++) {
		if (PopupWindow.windows[i].state == "min") {
			var w = PopupWindow.windows[i].minWidth;
			var h = PopupWindow.windows[i].minHeight;
			var x = (pos % PopupWindow.minimizedCols) * w;
			var y = GlobalKit.screenHeight() - h - (h * Math.floor(pos / PopupWindow.minimizedCols));
			// Start animation:
			$(PopupWindow.windows[i].container).moveTo(x, y, 500, Tween.ease, 30).resizeTo(w, h, 500, Tween.ease, 30);
			pos++;
		}
	}
};
PopupWindow.create = function(id, x, y, w, h, title, transparency, icon) {
	return new PopupWindow(id, x, y, w, h, title, transparency, icon);
};
PopupWindow.prototype.fixOpera = function() {
	$(this.container).setStyle("display", "table");
};
PopupWindow.prototype.getScrollerHeight = function(height) {
	return (parseInt(height) - 12 - 32 - 8) + "px";
};
PopupWindow.prototype.init = function() {
	if (this.transparency != false) {
		this.filter = this.createFilter(this.transparency);
	}
	this.icon = this.createIcon(this.icon);
	this.title = this.createTitle(this.title);
	this.btnCenter = this.createBtnCenter();
	this.btnMin = this.createBtnMin();
	this.btnMax = this.createBtnMax();
	this.btnClose = this.createBtnClose();
	this.buttons = this.createButtons();
	this.configButtons(this.btnCfg);
	this.body = this.createBody(this.id);
	this.scroller = this.createScroller();
	this.container = this.createContainer(this.x, this.y, this.w, this.h);
	if (navigator.userAgent.contains("Opera")) {
		this.fixOpera();
	}
	PopupWindow.windows.add(this);
};
PopupWindow.prototype.createFilter = function(transparency) {
	var filter = document.createElement("DIV");
	filter.window = this;
	(GlobalKit.browser().contains("MSIE 6")) ? $(filter).setStyle("position", "absolute").setStyle("width", "100%") : $(filter).setStyle("position", "fixed").setStyle("width", "200%");
	$(filter).css({
			backgroundColor: "#000000",
			left: "0px",
			top: "0px",
			height: "100%"
	}).setTransparency(transparency);
	document.body.appendChild(filter);
	return filter;
};
PopupWindow.prototype.createIcon = function(image) {
	var icon = document.createElement("IMG");
	icon.window = this;
	if (image != null) {
		icon.src = image;
	} else {
		$(icon).addClass("empty");
	}
	$(icon).addClass("icon");
	return icon;
};
PopupWindow.prototype.createTitle = function(text) {
	var title = document.createElement("DIV");
	title.window = this;
	$(title).addClass("title").append(text);
	return title;
};
PopupWindow.prototype.createBtnCenter = function() {
	var center = document.createElement("A");
	center.window = this;
	center.href = "Javascript:void(0);";
	center.setAttribute("href", center.href);
	$(center).addClass("btnCenter").on("click", function() { this.window.centerScreen(); }).on("dblclick", function() { PopupWindow.centerAll(); });
	return center;
};
PopupWindow.prototype.createBtnMin = function() {
	var min = document.createElement("A");
	min.window = this;
	min.href = "Javascript:void(0);";
	min.setAttribute("href", min.href);
	$(min).addClass("btnMin").on("click", function() { this.window.minimize(); }).on("dblclick", function() { PopupWindow.minimizeAll(); });
	return min;
};
PopupWindow.prototype.createBtnMax = function() {
	var max = document.createElement("A");
	max.window = this;
	max.href = "Javascript:void(0);";
	max.setAttribute("href", max.href);
	$(max).on("click", function() {
		if (this.window.state == "normal") {
			this.window.maximize();
		} else {
			this.window.normalize();
		}
	}).addClass("btnMax");
	return max;
};
PopupWindow.prototype.createBtnClose = function() {
	var close = document.createElement("A");
	close.window = this;
	$(close).addClass("btnClose").on("mouseover", function() { $(this).setStyle("cursor", "pointer"); }).on("click", function() { this.window.hide(); });
	return close;
};
PopupWindow.prototype.createButtons = function() {
	var buttons = document.createElement("DIV");
	buttons.window = this;
	$(buttons).addClass("buttons");
	buttons.appendChild(this.btnCenter);
	buttons.appendChild(this.btnMin);
	buttons.appendChild(this.btnMax);
	buttons.appendChild(this.btnClose);
	return buttons;
};
PopupWindow.prototype.configButtons = function(config) {
	if (!config.contains("center") || this.state == "hidden") {
		$(this.btnCenter).hide();
	} else if (this.state != "hidden") {
		$(this.btnCenter).show();
	}
	if (!config.contains("min") || this.state == "hidden") {
		$(this.btnMin).hide();
	} else if (this.state != "hidden") {
		$(this.btnMin).show();
	}
	if (!config.contains("max") || this.state == "hidden") {
		$(this.btnMax).hide();
	} else if (this.state != "hidden") {
		$(this.btnMax).show();
	}
	if (!config.contains("close") || this.state == "hidden") {
		$(this.btnClose).hide();
	} else if (this.state != "hidden") {
		$(this.btnClose).show();
	}
	this.btnConfig = config;
	return this;
};
PopupWindow.prototype.createBody = function(id) {
	var body = document.createElement("DIV");
	body.window = this;
	body.id = id;
	$(body).addClass("body");
	body.destroy = function() {
		this.window.destroy();
	};
	body.show = function() {
		this.window.show();
	};
	body.hide = function() {
		this.window.hide();
	};
	body.setTitle = function(title) {
		this.window.setTitle(title);
	};
	body.makeDraggable = function() {
		this.window.makeDraggable();
	};
	body.makeResizable = function() {
		this.window.makeResizable();
	};
	return body;
};
PopupWindow.prototype.createScroller = function() {
	var scroller = document.createElement("DIV");
	scroller.window = this;
	scroller.id = this.id + "_scroller";
	$(scroller).addClass("scroller");
	scroller.appendChild(this.body);
	return scroller;
};
PopupWindow.prototype.createContainer = function(x, y, w, h) {
	var container = document.createElement("DIV");
	container.window = this;
	container.id = this.id + "_container";
	var cell = document.createElement("DIV");
	$(cell).addClass("topLeft");
	container.appendChild(cell);
	cell = document.createElement("DIV");
	cell.window = this;
	$(cell).addClass("top");
	cell.appendChild(this.icon);
	cell.appendChild(this.title);
	cell.appendChild(this.buttons);
	container.appendChild(cell);
	cell = document.createElement("DIV");
	$(cell).addClass("topRight");
	container.appendChild(cell);
	cell = document.createElement("DIV");
	$(cell).addClass("left");
	container.appendChild(cell);
	container.appendChild(this.scroller);
	cell = document.createElement("DIV");
	$(cell).addClass("right");
	container.appendChild(cell);
	cell = document.createElement("DIV");
	$(cell).addClass("bottomLeft");
	container.appendChild(cell);
	cell = document.createElement("DIV");
	$(cell).addClass("bottom");
	container.appendChild(cell);
	cell = document.createElement("DIV");
	$(cell).addClass("bottomRight");
	container.appendChild(cell);
	(GlobalKit.browser().contains("MSIE 6")) ? $(container).setStyle("position", "absolute") : $(container).setStyle("position", "fixed");
	$(container).css({
			left: x,
			top: y,
			width: w,
			height: h
		}).addClass("popupWindow");
	document.body.appendChild(container);
	return container;
};
PopupWindow.prototype.addOncloseHandler = function(func) {
	this.oncloseHandlers.add(func);
	return this;
};
PopupWindow.prototype.show = function() {
	this.state = "normal";
	$(this.filter, this.container).show();
	this.configButtons(this.btnCfg);
	if (navigator.userAgent.contains("Opera")) {
		this.fixOpera();
	}
	return this;
};
PopupWindow.prototype.hide = function() {
	this.state = "hidden";
	$(this.filter, this.container).hide();
	this.configButtons(this.btnCfg);
	if (navigator.userAgent.contains("Opera")) {
		this.fixOpera();
	}
	PopupWindow.orderMinimized();
	for (var i = 0; i < this.oncloseHandlers.length; i++) {
		this.oncloseHandlers[i].call(this.oncloseHandlers[i], this);
	}
	return this;
};
PopupWindow.prototype.destroy = function() {
	$(this.container).destroy();
	PopupWindow.windows.remove(this);
	PopupWindow.orderMinimized();
};
PopupWindow.prototype.setIcon = function(icon) {
	this.icon.src = icon;
	if (icon != null) {
		$(this.icon).removeClass("empty");
	} else {
		$(this.icon).addClass("empty");
	}
	return this;
};
PopupWindow.prototype.setTitle = function(title) {
	$(this.title).update(title);
	return this;
};
PopupWindow.prototype.makeDraggable = function() {
	$(this.container.children[1]).on("mouseover", function() { $(this).setStyle("cursor", "move"); });
	var graspHandler = function(dragObject, pos) {
		dragObject.original = {
				position: $(dragObject.element).getStyle("position"),
				left: $(dragObject.element).getStyle("left"),
				top: $(dragObject.element).getStyle("top")
			};
		$(dragObject.element).addClass("dragging").setStyle("position", "absolute");
		$(dragObject.element.parentNode.window.container).addClass("dragging");
		var box = $(dragObject.element).getBox();
		dragObject.offset.x = pos.x - box.x;
		dragObject.offset.y = pos.y - box.y;
	};
	var dragHandler = function(dragObject, pos) {
		var element = dragObject.element.parentNode;
		var x = (pos.x - dragObject.offset.x);
		var y = (pos.y - dragObject.offset.y);
		var box = $(element).getBox();
		if (x < 0) {
			x = 0;
		} else if ((x + box.w) > GlobalKit.screenWidth()) {
			x = GlobalKit.screenWidth() - box.w;
		}
		if (y < 0) {
			y = 0;
		} else if ((y + box.h) > GlobalKit.screenHeight()) {
			y = GlobalKit.screenHeight() - box.h;
		}
		if (element.window.state != "min") {
			element.window.x = x + "px";
			element.window.y = y + "px";
		}
		$(element).css({
			left: x + "px",
			top: y + "px"
		});
	};
	var releaseHandler = function(dragObject) {
		$(dragObject.element).removeClass("dragging").css({
				position: dragObject.original.position,
				left: dragObject.original.left,
				top: dragObject.original.top
			});
		$(dragObject.element.parentNode.window.container).removeClass("dragging");
		dragObject.original = { position: null, x: 0, y: 0 };
		dragObject.offset = { x: 0, y: 0 };
		if (Dragdropper.dropObject != null) {
			Dragdropper.dropObject.drop(dragObject);
		}
	};
	Dragdropper.makeDraggable(this.container.children[1], null, graspHandler, dragHandler, releaseHandler);
	return this;
};
PopupWindow.prototype.makeResizable = function() {
	var releaseHandler = function(dragObject) {
		$(dragObject.element).removeClass("dragging").css({
				position: dragObject.original.position,
				left: dragObject.original.left,
				top: dragObject.original.top
			});
		dragObject.original = { position: null, x: 0, y: 0 };
		dragObject.offset = { x: 0, y: 0 };
		if (Dragdropper.dropObject != null) {
			Dragdropper.dropObject.drop(dragObject);
		}
		dragObject.element.parentNode.window.x = $(dragObject.element.parentNode).getStyle("left");
		dragObject.element.parentNode.window.y = $(dragObject.element.parentNode).getStyle("top");
		dragObject.element.parentNode.window.w = $(dragObject.element.parentNode).getStyle("width");
		dragObject.element.parentNode.window.h = $(dragObject.element.parentNode).getStyle("height");
	};
	Dragdropper.makeResizable(this.container, null, releaseHandler);
	return this;
};
PopupWindow.prototype.minimize = function() {
	if (this.state == "min") {
		return;
	}
	PopupWindow.orderMinimized();
	var pos = PopupWindow.minimized();
	this.state = "min";
	var w = this.minWidth;
	var h = this.minHeight;
	var x = (pos % PopupWindow.minimizedCols) * w;
	var y = GlobalKit.screenHeight() - h - (h * Math.floor(pos / PopupWindow.minimizedCols));
	$(this.container).moveTo(x, y, 1000, Tween.ease, 30).resizeTo(w, h, 1000, Tween.ease, 30);
};
/**
 * Set the position and size of the window to the original position.
 **/
PopupWindow.prototype.normalize = function() {
	// Don't normalize if already normalized:
	if (this.state == "normal") {
		return;
	}
	this.state = "normal";
	// Start the animation:
	$(this.container).moveTo(this.x, this.y, 1000, Tween.ease, 30).resizeTo(this.w, this.h, 1000, Tween.ease, 30);
	// Re-order all minimized windows:
	PopupWindow.orderMinimized();
};
/**
 * Maximize the window.
 **/
PopupWindow.prototype.maximize = function() {
	// Don't maximize if already maximized:
	if (this.state == "max") {
		return;
	}
	this.state = "max";
	$(this.container).moveTo(0, 0, 1000, Tween.ease, 30).resizeTo(GlobalKit.screenWidth(), GlobalKit.screenHeight(), 1000, Tween.ease, 30);
	PopupWindow.orderMinimized();
};
PopupWindow.prototype.centerScreen = function() {
	this.x = ((GlobalKit.screenWidth() - parseInt(this.w)) / 2) + "px";
	this.y = ((GlobalKit.screenHeight() - parseInt(this.h)) / 2) + "px";
	$(this.container).css({
			position: "fixed",
			left: this.x,
			top: this.y,
			width: this.w,
			height: this.h
		});
};function DragObject(element, dropObjects, graspHandler, dragHandler, releaseHandler) {
	this.element = element;
	this.dropObjects = (dropObjects == null) ? [] : dropObjects;
	this.graspHandler = (graspHandler == null) ? DragObject.defaultGraspHandler : graspHandler;
	this.dragHandler = (dragHandler == null) ? DragObject.defaultDragHandler : dragHandler;
	this.releaseHandler = (releaseHandler == null) ? DragObject.defaultReleaseHandler : releaseHandler;
	this.original = { position: null, x: 0, y: 0 };
	this.offset = { x: 0, y: 0 };
	$(element).noSelect().addClass("dragObject");
};
DragObject.defaultGraspHandler = function(dragObject, pos) {
	dragObject.original = {
			position: $(dragObject.element).getStyle("position"),
			left: $(dragObject.element).getStyle("left"),
			top: $(dragObject.element).getStyle("top")
		};
	var box = $(dragObject.element).setStyle("position", "absolute").getBox();
	dragObject.offset.x = pos.x - box.x;
	dragObject.offset.y = pos.y - box.y;
	if (dragObject.offset.x < 0 || dragObject.offset.x > box.w) { dragObject.offset.x = 4; }
	if (dragObject.offset.y < 0 || dragObject.offset.y > box.h) { dragObject.offset.y = 4; }
	$(dragObject.element).addClass("dragging").setStyle("position", "fixed");
	var scroll = GlobalKit.scrollPos();
	var x = (pos.x - dragObject.offset.x - scroll.x);
	var y = (pos.y - dragObject.offset.y - scroll.y);
	$(dragObject.element).css({
		left: x + "px",
		top: y + "px"
	});
	var dropObject = dragObject.detectDropObject(pos.x, pos.y);
	if (Dragdropper.dropObject != dropObject) {
		if (Dragdropper.dropObject != null) {
			$(Dragdropper.dropObject.element).removeClass("dropObject");
		}
		if (dropObject != null) {
			$(dropObject.element).addClass("dropObject");
		}
		Dragdropper.dropObject = dropObject;
	}
};
DragObject.defaultDragHandler = function(dragObject, pos) {
	var scroll = GlobalKit.scrollPos();
	var x = (pos.x - dragObject.offset.x - scroll.x);
	var y = (pos.y - dragObject.offset.y - scroll.y);
	var box = $(dragObject.element).getBox();
	if (x < 0) {
		x = 0;
	} else if ((x + box.w) > GlobalKit.screenWidth()) {
		x = GlobalKit.screenWidth() - box.w;
	}
	if (y < 0) {
		y = 0;
	} else if ((y + box.h) > GlobalKit.screenHeight()) {
		y = GlobalKit.screenHeight() - box.h;
	}
	$(dragObject.element).css({
		left: x + "px",
		top: y + "px"
	});
	var dropObject = dragObject.detectDropObject(pos.x, pos.y);
	if (Dragdropper.dropObject != dropObject) {
		if (Dragdropper.dropObject != null) {
			$(Dragdropper.dropObject.element).removeClass("dropObject");
		}
		if (dropObject != null) {
			$(dropObject.element).addClass("dropObject");
		}
		Dragdropper.dropObject = dropObject;
	}
};
DragObject.defaultReleaseHandler = function(dragObject) {
	$(dragObject.element).removeClass("dragging").css({
			position: dragObject.original.position,
			left: dragObject.original.left,
			top: dragObject.original.top
		});
	dragObject.original = { position: null, x: 0, y: 0 };
	dragObject.offset = { x: 0, y: 0 };
	if (Dragdropper.dropObject != null) {
		Dragdropper.dropObject.drop(dragObject);
	}
};
DragObject.prototype.registerDropObject = function(dropObject) {
	if (dropObject == null) {
		Debugger.write("Drop object is NULL!");
		return;
	}
	if (this.element == dropObject.element) {
		return;
	}
	if (!this.dropObjects.contains(dropObject)) {
		this.dropObjects.add(dropObject);
	}
	if (!dropObject.dragObjects.contains(this)) {
		dropObject.registerDragObject(this);
	}
};
DragObject.prototype.grasp = function(pos) {
	this.graspHandler(this, pos);
};
DragObject.prototype.drag = function(pos) {
	this.dragHandler(this, pos);
};
DragObject.prototype.release = function() {
	this.releaseHandler(this);
};
DragObject.prototype.detectDropObject = function(x, y) {
	this.dropObjects.sort(function(a, b) {
		var aDepth = GlobalKit.getDOMDepth(a.element);
		var bDepth = GlobalKit.getDOMDepth(b.element);
		if (aDepth < bDepth) {
			return 1;
		} else if (aDepth > bDepth) {
			return -1;
		} else {
			return 0;
		}
	});
	for (var i = 0; i < this.dropObjects.length; i++) {
		var old = $(this.dropObjects[i].element).getStyle("position");
		var box = $(this.dropObjects[i].element).setStyle("position", "absolute").getBox();
		$(this.dropObjects[i].element).setStyle("position", old);
		if ((x >= box.x) && (x <= box.x2) && (y >= box.y) && (y <= box.y2)) {
			return this.dropObjects[i];
		}
	}
	return null;
};
function DropObject(element, dragObjects, dropHandler) {
	this.element = element;
	this.dragObjects = (dragObjects == null) ? [] : dragObjects;
	this.dropHandler = (dropHandler == null) ? DropObject.defaultDropHandler : dropHandler;
	$(element).noSelect();
};
DropObject.defaultDropHandler = function(dropObject, dragObject) {
	$(Dragdropper.dropObject.element).removeClass("dropObject");
	Dragdropper.dropObject = null;
	if (dropObject.element == dragObject.element) {
		Debugger.write("Cannot drop '" + dragObject.element.id + "' into itself!");
		return;
	}
	dragObject.element.parentNode.removeChild(dragObject.element);
	dropObject.element.appendChild(dragObject.element);
};
DropObject.prototype.registerDragObject = function(dragObject) {
	if (dragObject == null) {
		Debugger.write("Drag object is NULL!");
		return;
	}
	if (this.element == dragObject.element) {
		return;
	}
	if (!this.dragObjects.contains(dragObject)) {
		this.dragObjects.add(dragObject);
	}
	if (!dragObject.dropObjects.contains(this)) {
		dragObject.registerDropObject(this);
	}
};
DropObject.prototype.drop = function(dragObject) {
	this.dropHandler(this, dragObject);
};
function Dragdropper() {};
Dragdropper.dragObject = null;
Dragdropper.dropObject = null;
Dragdropper.dragObjects = [];
Dragdropper.dropObjects = [];
Dragdropper.init = function() {
	$(document).on("mousemove",
		Dragdropper.mousemoveHandler
	).on("mousedown",
		Dragdropper.mousedownHandler
	).on("mouseup",
		Dragdropper.mouseupHandler
	).on("mousedrag",
		Dragdropper.mousedragHandler
	);
	$(window).on("scroll", function(e) {
		Dragdropper.scrollHandler(e);
	});
};
Dragdropper.getDragObject = function(element) {
	for (var i = 0; i < Dragdropper.dragObjects.length; i++) {
		if (Dragdropper.dragObjects[i].element == element) {
			return Dragdropper.dragObjects[i];
		}
	}
	return null;
};
Dragdropper.getDropObject = function(element) {
	for (var i = 0; i < Dragdropper.dropObjects.length; i++) {
		if (Dragdropper.dropObjects[i].element == element) {
			return Dragdropper.dropObjects[i];
		}
	}
	return null;
};
Dragdropper.isDraggable = function(element) {
	return (Dragdropper.getDragObject(element) != null);
};
Dragdropper.isDroppable = function(element) {
	return (Dragdropper.getDropObject(element) != null);
};
Dragdropper.makeDraggable = function(element, dropObjects, graspHandler, dragHandler, releaseHandler) {
	if (element.tagName != "DIV") {
		Debugger.write("WARNING: The element ('" + element.id + "' | '" + element.tagName + "') that is made draggable is NOT a DIV!");
	}
	var dragObject = new DragObject(element, dropObjects, graspHandler, dragHandler, releaseHandler);
	Dragdropper.dragObjects.add(dragObject);
	return dragObject;
};
Dragdropper.makeDroppable = function(element, dragObjects, dropHandler) {
	var dropObject = new DropObject(element, dragObjects, dropHandler);
	Dragdropper.dropObjects.add(dropObject);
	return dropObject;
};
Dragdropper.makeResizable = function(element, graspHandler, releaseHandler) {
	var fix = navigator.userAgent.contains("Firefox") ? 1 : 0;
	fix = 0; 
	var bar = 8;
	var graspHandler = function(dragObject, pos) {
		dragObject.original = {
				position: $(dragObject.element).getStyle("position"),
				left: $(dragObject.element).getStyle("left"),
				top: $(dragObject.element).getStyle("top")
			};
		var box = $(dragObject.element).setStyle("position", "absolute").getBox();
		dragObject.offset.x = pos.x - box.x;
		dragObject.offset.y = pos.y - box.y;
		if (dragObject.offset.x < 0 || dragObject.offset.x > box.w) { dragObject.offset.x = 4; }
		if (dragObject.offset.y < 0 || dragObject.offset.y > box.h) { dragObject.offset.y = 4; }
		$(dragObject.element).addClass("dragging");
	};
	var topDragHandler = function(dragObject, pos) {
		var x = (pos.x - dragObject.offset.x);
		var y = (pos.y - dragObject.offset.y);
		y -= GlobalKit.scrollPos().y;
		y -= GlobalKit.browser().contains("MSIE 9.0") ? GlobalKit.scrollPos().y : 0;
		y = (y < 0) ? 0 : y;
		var oldStyle = $(dragObject.element.parentNode).getStyle("position");
		var box = $(dragObject.element.parentNode).setStyle("position", "absolute").getBox();
		var h = box.h + (box.y - y) + fix;
		$(dragObject.element).css({
			left: "0px",
			top: "0px"
		});
		$(dragObject.element.parentNode).css({
			top: y + "px",
			height: h + "px"
		}).setStyle("position", oldStyle);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		left: "0px",
		top: "0px",
		right: "0px",
		height: bar + "px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "n-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, topDragHandler, releaseHandler);
	element.appendChild(cell);
	var rightDragHandler = function(dragObject, pos) {
		var x = (pos.x - dragObject.offset.x);
		var y = (pos.y - dragObject.offset.y);
		x -= GlobalKit.scrollPos().x;
		x -= GlobalKit.browser().contains("MSIE 9.0") ? GlobalKit.scrollPos().x : 0;
		x = (x > GlobalKit.screenWidth()) ? GlobalKit.screenWidth() - fix : x;
		var oldStyle = $(dragObject.element.parentNode).getStyle("position");
		var box = $(dragObject.element.parentNode).setStyle("position", "absolute").getBox();
		var w = box.w + dragObject.offset.x + (x - box.x2);
		$(dragObject.element.parentNode).css({
			width: w + "px"
		}).setStyle("position", oldStyle);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		top: "0px",
		right: "0px",
		width: bar + "px",
		bottom: "0px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "e-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, rightDragHandler, releaseHandler);
	element.appendChild(cell);
	var bottomDragHandler = function(dragObject, pos) {
		var x = (pos.x - dragObject.offset.x);
		var y = (pos.y - dragObject.offset.y);
		y -= GlobalKit.scrollPos().y;
		y -= GlobalKit.browser().contains("MSIE 9.0") ? GlobalKit.scrollPos().y : 0;
		y = (y > GlobalKit.screenHeight()) ? GlobalKit.screenHeight() - fix : y;
		y -= fix;
		var oldStyle = $(dragObject.element.parentNode).getStyle("position");
		var box = $(dragObject.element.parentNode).setStyle("position", "absolute").getBox();
		var h = box.h + (y - box.y2) + fix;
		$(dragObject.element.parentNode).css({
			height: h + "px"
		}).setStyle("position", oldStyle);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		left: "0px",
		bottom: "0px",
		height: bar + "px",
		right: "0px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "s-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, bottomDragHandler, releaseHandler);
	element.appendChild(cell);
	var leftDragHandler = function(dragObject, pos) {
		var x = (pos.x - dragObject.offset.x);
		var y = (pos.y - dragObject.offset.y);
		x -= GlobalKit.scrollPos().x;
		x -= GlobalKit.browser().contains("MSIE 9.0") ? GlobalKit.scrollPos().x : 0;
		x = (x < 0) ? 0 : x;
		var oldStyle = $(dragObject.element.parentNode).getStyle("position");
		var box = $(dragObject.element.parentNode).setStyle("position", "absolute").getBox();
		var w = box.w + (box.x - x) + fix;
		$(dragObject.element.parentNode).css({
			left: x + "px",
			width: w + "px"
		}).setStyle("position", oldStyle);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		left: "0px",
		top: "0px",
		width: bar + "px",
		bottom: "0px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "w-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, leftDragHandler, releaseHandler);
	element.appendChild(cell);
	var topLeftDragHandler = function(dragObject, pos) {
		leftDragHandler(dragObject, pos);
		topDragHandler(dragObject, pos);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		left: "0px",
		top: "0px",
		width: (bar * 2) + "px",
		height: (bar * 2) + "px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "nw-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, topLeftDragHandler, releaseHandler);
	element.appendChild(cell);
	var topRightDragHandler = function(dragObject, pos) {
		topDragHandler(dragObject, pos);
		rightDragHandler(dragObject, pos);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		right: "0px",
		top: "0px",
		width: (bar * 2) + "px",
		height: (bar * 2) + "px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "ne-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, topRightDragHandler, releaseHandler);
	element.appendChild(cell);
	var bottomRightDragHandler = function(dragObject, pos) {
		rightDragHandler(dragObject, pos);
		bottomDragHandler(dragObject, pos);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		right: "0px",
		bottom: "0px",
		width: (bar * 2) + "px",
		height: (bar * 2) + "px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "se-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, bottomRightDragHandler, releaseHandler);
	element.appendChild(cell);
	var bottomLeftDragHandler = function(dragObject, pos) {
		bottomDragHandler(dragObject, pos);
		leftDragHandler(dragObject, pos);
	};
	var cell = document.createElement("DIV");
	$(cell).css({
		position: "absolute",
		left: "0px",
		bottom: "0px",
		width: (bar * 2) + "px",
		height: (bar * 2) + "px"
	}).addClass("resizer").on("mouseover", function() { $(this).setStyle("cursor", "sw-resize"); });
	Dragdropper.makeDraggable(cell, null, graspHandler, bottomLeftDragHandler, releaseHandler);
	element.appendChild(cell);
};
Dragdropper.mousemoveHandler = function(e) {
	e = e || window.event;
	if (Dragdropper.dragObject != null) {
		return Dragdropper.mousedragHandler(e);
	}
};
Dragdropper.mousedownHandler = function(e) {
	e = e || window.event;
	var target = e.target || e.srcElement;
	var isImg = (target.tagName == "IMG");
	if (target.tagName != "DIV") {
		target = target.parentNode;
	}
	if (Dragdropper.dragObject == null && Dragdropper.isDraggable(target)) {
		Dragdropper.dragObject = Dragdropper.getDragObject(target);
		var pos = GlobalKit.mousePos(e);
		var scroll = GlobalKit.scrollPos();
		if (GlobalKit.browser().contains("MSIE")) {
			pos.x += scroll.x;
			pos.y += scroll.y;
		}
		Dragdropper.dragObject.grasp(pos);
		return GlobalKit.stopEvent(e);
	}
	if (isImg) {
		return GlobalKit.stopEvent(e);
	}
};
Dragdropper.mouseupHandler = function(e) {
	if (Dragdropper.dragObject != null) {
		Dragdropper.dragObject.release();
		Dragdropper.dragObject = null;
	}
};
Dragdropper.mousedragHandler = function(e) {
	e = e || window.event;
	if (Dragdropper.dragObject != null) {
		var pos = GlobalKit.mousePos(e);
		var scroll = GlobalKit.scrollPos();
		if (GlobalKit.browser().contains("MSIE")) {
			pos.x += scroll.x;
			pos.y += scroll.y;
		}
		Dragdropper.dragObject.drag(pos);
		return GlobalKit.stopEvent(e);
	}
};
Dragdropper.scrollHandler = function(e) {
};
Dragdropper.init();function Cookie() {}
Cookie.save = function(name, value, expires, path, domain, secure) {
	var cookie = name + "=" + escape(value) + 
			((expires) ? "; expires=" + expires.toGMTString() : "") + 
			((path) ? "; path=" + path : "") + 
			((domain) ? "; domain=" + domain : "") + 
			((secure) ? "; secure" : "");
	document.cookie = cookie;
};
Cookie.get = function(name) {
	var allCookies = document.cookie.split(";");
	var tempCookie = "";
	var cookieName = "";
	var cookieValue = "";
	var cookieFound = false;
	for (var i = 0; i < allCookies.length; i++) {
		tempCookie = allCookies[i].split("=");
		cookieName = tempCookie[0].trim();
		if (cookieName == name) {
			cookieFound = true;
			if (tempCookie.length > 1) {
				cookieValue = unescape(tempCookie[1].trim());
			}
			return cookieValue;
		}
		tempCookie = null;
		cookieName = "";
	}
	return null;
};
Cookie.remove = function(name, path, domain) {
	if (Cookie.get(name)) {
		document.cookie = name + "=" +
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain : "") +
				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
};var onloadHandlers = Array();
function addOnloadHandler(handler) {
	if (handler != null) {
		onloadHandlers.add(handler);
	}
};
$(window).on("load", function() {
	new PopupWindow("popup", null, null, "600px", "400px", "Popup", 50).makeDraggable().makeResizable().hide();
	Debugger.setTarget(new PopupWindow("debug", null, null, "500px", "300px", "<font color='#dd0000'>The debugger</font>", false).makeDraggable().makeResizable().body).hide();
	Widget.replaceAll(document.getElementsByName("widget"));
	for (var i = 0; i < onloadHandlers.length; i++) {
		onloadHandlers[i]();
	}
});
