function Dump(oVar, sName, nDepp, nLevel)
{
	var oItem = new Array();
	var oTemp = null;

	if(typeof(sName) == 'undefined')
	{
		sName = '';
	}
	else
	{
		sName += '.';
	};

	if(typeof(nDepp) == 'undefined')
	{
		nDepp = 0;
	};

	if(typeof(nLevel) == 'undefined')
	{
		nLevel = 0;
	};

	for(var sKey in oVar)
	{
		try
		{
			oTemp = new Array();
			oTemp[oTemp.length] = '' + sName + sKey + ' = ' + oVar[sKey] + '';
		}
		catch (e)
		{
			oTemp = new Array();
			oTemp[oTemp.length] = '' + 'ERROR@' + sName + sKey + ': ' + e;
		};

		if(oTemp.length)
		{
			oItem.push(oTemp);
		};

		try
		{
			oTemp = new Array();

			if((nLevel < nDepp) || (nDepp == (-1)))
			{
				if((typeof(oVar[sKey]) == 'array') || (typeof(oVar[sKey]) == 'object'))
				{
					oTemp = oTemp.concat(DebugVar(oVar[sKey], (sName + sKey), nDepp, (nLevel + 1)));
					oTemp[oTemp.length] = '------------------------------------------------------------------------------';
				};
			};
		}
		catch (e)
		{
			oTemp = new Array();
			oTemp[oTemp.length] = 'ERROR@' + sName + sKey + ': ' + e;
			oTemp[oTemp.length] = '------------------------------------------------------------------------------';
		};

		if(oTemp.length)
		{
			oItem = oItem.concat(oTemp);
		};
	};

	return(nLevel ? oItem : oItem.join(String.fromCharCode(10)));
};

function $(element)
{
	if(arguments.length > 1)
	{
		for(var i = 0, elements = [], length = arguments.length; i < length; i++)
		{
			elements.push($(arguments[i]));
		};

		return(elements);
	};

	if(typeof(element) === 'string')
	{
		element = document.getElementById(element);
    };

	return(Object.extend(element, UCMS.Element));
};

function $A(object)
{
	return(Array.prototype.slice.call(object));
};

Object.extend = function(destination, source)
{
	for(var property in source)
	{
		destination[property] = source[property];
	};

	return(destination);
};

Array.prototype.diff = function()
{
	for(var i = 0, result = [], args = $A(arguments); i < this.length; i++)
	{
		if(!args.exists(this[i]))
		{
			result.push(this[i]);
		};
	};

	return(result);
};

Array.prototype.exists = function(value)
{
	for(var i = 0; i < this.length; i++)
	{
		if(this[i] === value)
		{
			return(true);
		};
	};

	return(false);
};

Array.prototype.unique = function()
{
	for(var i = 0, result = new Array(); i < this.length; i++)
	{
		if(!result.exists(this[i]))
		{
			result.push(this[i]);
		};
	};

	return(result);
};

String.prototype.compare = function(data)
{
	return(this.toString() === data.toString());
};

String.prototype.replace = function(search, replace)
{
	return(this.split(search).join(replace));
};

var UCMS = {

	ToolbarList: {},

	Element: {

		hasClass: function(className)
		{
			return(this.className.split(' ').exists(className));
		},

		addClass: function(className)
		{
			if(!this.className.split(' ').exists(className))
			{
				this.className += ' ' + className;
			};

			return(this);
		},

		removeClass: function(className)
		{
			this.className = this.className.split(' ').diff(className).join(' ');

			return(this);
		},

		toggleClass: function(className)
		{
			return(this.hasClass(className) ? this.removeClass(className) : this.addClass(className))
		},

		getRect: function()
		{
			var obj = this, result = {'left' : 0, 'top' : 0, 'width' : this.offsetWidth, 'height' : this.offsetHeight};

			while(obj !== null)
			{
				result['left'] += obj.offsetLeft;
				result['top'] += obj.offsetTop;

				obj = obj.offsetParent;
			};

			return(result);
		},

		isVisible: function()
		{
			return(this.style.display !== 'none');
		},

		show: function()
		{
			this.style.display = '';

			return(this);
		},

		hide: function()
		{
			this.style.display = 'none';

			return(this);
		},

		toggle: function()
		{
			return(this.isVisible ? this.hide() : this.show());
		}
	},

	addComboValue: function(sSelectId, sPrompt, sDefaultValue, sClassName)
	{
		var oSelect = null;

		if(oSelect = document.getElementById(sSelectId))
		{
			var sValue = null;
			var bError = false;

			if(sValue = window.prompt(sPrompt, sDefaultValue))
			{
				for(var i=0; i<oSelect.options.length; i++)
				{
					if(oSelect.options[i].value.toLowerCase() == sValue.toLowerCase())
					{
						bError = true;

						break;
					};
				};

				if(bError == false)
				{
					var oOption = new Option(sValue, sValue, false, true);

					if(sClassName)
					{
						oOption.className = sClassName;
					};

					oSelect.options[oSelect.options.length] = oOption;

					if(oSelect.onchange)
					{
						oSelect.onchange();
					};
				}
				else
				{
					alert('Der Wert "' + sValue + '" ist bereits in der Liste vorhanden!');
				};
			}
			else if(sValue === '')
			{
				alert('Du hast keinen Wert angegeben!');
			};
		};
	},

	base64Chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',

	base64Decode: function(data)
	{
		var result = null, i = 0, chr1, chr2, chr3, enc1, enc2, enc3, enc4;

		if(data.match('^([A-Za-z0-9\\+\\/]{4})*([A-Za-z0-9\\+\\/]{2}==|[A-Za-z0-9\\+\\/]{3}=)?$'))
		{
			result = '';

			do
			{
				enc1 = this.base64Chars.indexOf(data.charAt(i++));
				enc2 = this.base64Chars.indexOf(data.charAt(i++));
				enc3 = this.base64Chars.indexOf(data.charAt(i++));
				enc4 = this.base64Chars.indexOf(data.charAt(i++));

				chr1 = (enc1 << 2) | (enc2 >> 4);
				chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
				chr3 = ((enc3 & 3) << 6) | enc4;

				result += String.fromCharCode(chr1);

				if(enc3 != 64)
				{
					result += String.fromCharCode(chr2);
				};

				if(enc4 != 64)
				{
					result += String.fromCharCode(chr3);
				};

			}
			while(i < data.length);
		};

		return(result);
	},

	base64Encode: function(data)
	{
		var result = '', i = 0, chr1, chr2, chr3, enc1, enc2, enc3, enc4;

		do
		{
			chr1 = data.charCodeAt(i++);
			chr2 = data.charCodeAt(i++);
			chr3 = data.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if(isNaN(chr2))
			{
				enc3 = enc4 = 64;
			}
			else if(isNaN(chr3))
			{
				enc4 = 64;
			};

			result += this.base64Chars.charAt(enc1) + this.base64Chars.charAt(enc2) + this.base64Chars.charAt(enc3) + this.base64Chars.charAt(enc4);

		}
		while(i < data.length);

		return(result);
	},

	lzwEncode: function(s)
	{
		var dict = {};
		var data = (s + "").split("");
		var out = [];
		var currChar;
		var phrase = data[0];
		var code = 256;

		for(var i=1; i<data.length; i++)
		{
			currChar=data[i];

			if(dict[phrase + currChar] != null)
			{
				phrase += currChar;
			}
			else
			{
				out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));
				dict[phrase + currChar] = code;
				code++;
				phrase=currChar;
			};
		};

		out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));

		for(var i=0; i<out.length; i++)
		{
			out[i] = String.fromCharCode(out[i]);
		};

		return(out.join(''));
	},


	lzwDecode: function(s)
	{
		var dict = {};
		var data = (s + "").split("");
		var currChar = data[0];
		var oldPhrase = currChar;
		var out = [currChar];
		var code = 256;
		var phrase;

		for(var i=1; i<data.length; i++)
		{
			var currCode = data[i].charCodeAt(0);

			if(currCode < 256)
			{
				phrase = data[i];
			}
			else
			{
				phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar);
			};

			out.push(phrase);
			currChar = phrase.charAt(0);
			dict[code] = oldPhrase + currChar;
			code++;
			oldPhrase = phrase;
		};

		return(out.join(''));
	},

	utf8Encode: function(data)
	{
		for(var i = 0, c = 0, result = ''; i < data.length; i++)
		{
			if((c = data.charCodeAt(i)) < 128)
			{
				result += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048))
			{
				result += String.fromCharCode((c >> 6) | 192, (c & 63) | 128);
			}
			else
			{
				result += String.fromCharCode((c >> 12) | 224, ((c >> 6) & 63) | 128, (c & 63) | 128);
			};
		};

		return(result);
	},

	utf8Decode: function(utftext)
	{
		var result = '';
		var i = 0;
		var c, c1, c2;

		while(i < utftext.length)
		{
 			c = utftext.charCodeAt(i);

			if(c < 128)
			{
				result += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224))
			{
				c2 = utftext.charCodeAt(i + 1);
				result += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else
			{
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				result += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			};
 		};

		return(result);
	},

	changeCheckboxSelection: function(vForm, sName, bChecked, bRegExp)
	{
		for(var i = 0, form = $(vForm), regexp	= (bRegExp ? new RegExp(sName) : null); i < form.elements.length; i++)
		{
			if(form.elements[i].type == 'checkbox')
			{
				if(regexp ? form.elements[i].name.match(regexp) : form.elements[i].name.compare(sName))
				{
					form.elements[i].checked = bChecked;
				};
			};
		};

		return(true);
	},

	changeListboxSelection: function(vElement, bSelected)
	{
		var oElement = null;

		if(oElement = $(vElement))
		{
			if(!oElement.disabled)
			{
				for(var i = 0; i < oElement.options.length; i++)
				{
					oElement.options[i].selected = bSelected;
				};

				return(true);
			};
		};

		return(false);
	},

	sendHttpRequest: function(sUrl, sTarget, sMethod, objParams)
	{
		if(typeof(sTarget) !== 'string')
		{
			sTarget = '';
		};

		if(typeof(sMethod) !== 'string')
		{
			sMethod = 'GET';
		};

		var objForm = document.createElement('form');
			objForm.setAttribute('action', sUrl);
			objForm.setAttribute('method', sMethod);
			objForm.setAttribute('target', sTarget);
			objForm.style.display = 'none';

		if(typeof(objParams) === 'object')
		{
			for(var sKey in objParams)
			{
				var objField = document.createElement('input');
					objField.setAttribute('type', 'hidden');
					objField.setAttribute('name', sKey);
					objField.setAttribute('value', objParams[sKey]);

				objForm.appendChild(objField);
			};
		};

		document.body.appendChild(objForm);

		objForm.submit();

		document.body.removeChild(objForm);
	},

	getCookie: function(name)
	{
		for(var i = 0, pos = 0, cookie = document.cookie.split('; '); i < cookie.length; i++)
		{
			if((pos = cookie[i].indexOf('=')) !== (-1))
			{
				if(unescape(cookie[i].substr(0, pos)) === name)
				{
					return(unescape(cookie[i].substr(pos + 1)));
				};
			};
		};

		return(null);
	},

	setCookie: function(name, value, expire, path, domain, secure)
	{
		if((typeof(name) !== 'undefined') && (typeof(value) !== 'undefined'))
		{
			var sCookie = name.toString() + '=' + escape(value.toString());

			if((typeof(expire) === 'number') || (typeof(expire) === 'string'))
			{
				sCookie += '; expires=' + (isNaN(expire) ? Date.parse(expire) : new Date(parseInt(expire) * 1000)).toGMTString();
			};

			if(typeof(path) === 'string')
			{
				sCookie += '; path=' + path;
			};

			if(typeof(domain) === 'string')
			{
				sCookie += '; domain=' + domain;
			};

			if((typeof(secure) === 'boolean') || (typeof(secure) === 'number') || (typeof(secure) === 'string'))
			{
				sCookie += '; secure=' + (secure ? '1' : '0');
			};

			document.cookie = sCookie;

			return(true);
		};

		return(false);
	},

	setElementHeight: function(vElement, nHeight, bAbsolute)
	{
		var oElement;

		if(oElement = $(vElement))
		{
			oElement.style.height = (oElement.clientHeight + nHeight).toString() + 'px';

			return(true);
		};

		return(false);
	},

	toggleFieldset: function(vFieldset, vStatus, sCookieName)
	{
		return(this.setCookie(sCookieName, ($(vStatus).value = ($(vFieldset).toggleClass('hidden').hasClass('hidden') ? '0' : '1')), 0x7FFFFFFF, window.location.pathname));
	},

	toggleTextarea: function(vTextarea, bAddToolbar)
	{
		var oTextarea;

		if(oTextarea = $(vTextarea))
		{
			if(bAddToolbar)
			{
				if(typeof(this.ToolbarList[oTextarea.id]) !== 'object')
				{
					this.ToolbarList[oTextarea.id] = new ToolbarClass();
				};
			};

			if(oTextarea.hasClass('expanded'))
			{
				if(bAddToolbar)
				{
					this.ToolbarList[oTextarea.id].Remove();
				};

				oTextarea.removeClass('expanded');
			}
			else
			{
				oTextarea.addClass('expanded');

				if(bAddToolbar)
				{
					this.ToolbarList[oTextarea.id].Add(oTextarea, 'toolbar');
				};
			};

			return(true);
		};

		return(false);
	},

	toggleFullScreen: function()
	{
		if(element = $(document.body))
		{
			return(this.setCookie('fullscreen', (element.toggleClass('fullscreen').hasClass('fullscreen') ? 'fullscreen' : ''), 0x7FFFFFFF));
		};

		return(false);
	}
};

function AjaxClass()
{
	this.xmlhttp = false;

	this.Abort = function()
	{
		if(this.xmlhttp)
		{
			this.xmlhttp.abort();
		};
	};

	this.SendRequest = function(url, method, postdata, callback, args)
	{
		this.xmlhttp = new _XMLHttpRequest();

		var xmlhttp = this.xmlhttp;
			xmlhttp.open(method, url, true);

			xmlhttp.onreadystatechange = function()
			{
				if(xmlhttp.readyState == 4)
				{
					if(typeof callback === 'function')
					{
						callback(xmlhttp.responseText, xmlhttp.status, xmlhttp.statusText, args);
					};
				};
			};

		if(typeof(postdata) === 'string')
		{
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

			xmlhttp.send(postdata);
		};
	};

	function _XMLHttpRequest()
	{
		var obj;

		try
		{
			obj = new XMLHttpRequest();
		}
		catch(error)
		{
			try
			{
				obj = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch(error)
			{
				return(null);
			};
		};

		return(obj);
	};
};

