/* >> jQuery $ recover */
	$ = jQuery.noConflict();
/* << */

/* >> jQuery extensions */
;(function($){
	$.fn.extend({
		allAttrs: function(){
			var set = this;
			var attrsObjsList = [];
			set.each(
				function(n){
					var obj = {};
					for (var i = 0; i < this.attributes.length; ++i){
						var a = this.attributes[i];
						obj[a.nodeName] = a.nodeValue;
					}
					attrsObjsList.push(obj);
				}
			);
			return attrsObjsList;
		}
	});

	// get iso date and get iso time
	$.extend({
		getISODate: function(gmtDateStr, lang){
			var dateBox = {
				'de': {'month': ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], 'separator': '.'},
				'en': {'month': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 'separator': '/'}
			}
			if (arguments.length == 0){
				var date = new Date();
				var lang = 'en';
			}else if (arguments.length == 1){
				var arg = arguments[0];
				if (typeof arg == 'string' && arg.length == 2){
					var lang = arg;
					var date = new Date();
				}else{
					var lang = 'en';
					var date = new Date(gmtDateStr);
				}
			}else{
				var date = new Date(gmtDateStr);
			}
			var sep = dateBox[lang].separator;
			var y = date.getYear() - 100;
			var fy = date.getFullYear();
			var m = date.getMonth();
			var d = date.getDate();
			var md = d < 10 ? '0' + d : d;
			var mm = m + 1 < 10 ? '0' + (m + 1) : m + 1;
			var my = y < 10 ? '0' + y : y;
			if (lang == 'de'){
				return {
					'short': d + sep + (m + 1) + sep + y,
					'middle': md + sep + mm + sep + my,
					'long': md + sep + dateBox[lang].month[m] + sep + fy
				}
			}
			return {
				'short': (m + 1) + sep + d + sep + y,
				'middle': mm + sep + md + sep + my,
				'long': dateBox[lang].month[m] + sep + md + sep + fy
			}
		},
		getISOTime: function(gmtDateStr){
			if (gmtDateStr) var date = new Date(gmtDateStr);
			var date = new Date();
			var h = date.getHours();
			if (h < 10) h = '0' + h;
			var m = date.getMinutes();
			if (m < 10) m = '0' + m;
			var s = date.getSeconds();
			if (s < 10) s = '0' + s;
			return h + ':' + m + ':' + s;
		}
	});

	// setter and getter for language resources
	$.extend({
		lang: function(name, lang){
			if (arguments.length > 1){
				if (typeof lang == 'object'){
					if (! $.lang._res) $.lang._res = {};
					$.lang._res[name] = lang;
					return lang;
				}else{
					if ($.lang._res && $.lang._res[name] && $.lang._res[name][lang]){
						return $.lang._res[name][lang];
					}
				}
				return '?-invalid-language-resource-?';
			}else if (arguments.length == 1){
				lang = $('html').attr('lang');
				if (!lang) lang = 'en';
				if ($.lang._res) return $.lang._res[name][lang];
				return '?-invalid-language-resource-?';
			}
			return $('html').attr('lang');
		}
	})
})(jQuery);
/* << */


/* >> XIST4C Globals */
	XIST4C_GLOBALS = {};
/* << */


/* >> LivingLogic DropDown Node (requires jQuery 1.2.6) Version: rel-1-0-0 */
	Node = function(Args){
		for (var name in Args){
			this[name] = Args[name];
		}
		this.children = [];
	}
	
	Node.prototype.childrenLayer = function(level){
		var layerId = ['childrenLevelContainer_',this.level].join('');
		if (level) layerId = ['childrenLevelContainer_',level].join('');
		return layer = $('<div></div>').css(
			{
				'position': 'absolute',
				'right': ['-',LL_DropDownNavi.layerWidth,'px'].join(''),
				'top': 0,
				'z-index': this.level * 10,
				'width': [LL_DropDownNavi.layerWidth,'px'].join('')
			}
		).attr({'id': layerId}).hide();
	}

	Node.prototype.nodeChildrenShell = function(){
		var cs = $('<div></div>').attr({'class': ['navCHS_',this.level+1].join('')});
		var self = this;
		if (this.styName){
			var sty = ['co_',this.styName].join('');
			var d = $('<div></div>').attr({'class': sty});
			if (this.children.length > 0){
				$(this.children).each(function(i){
					var Args = {};
					if (i == 0) Args.first = true;
					if (i == self.children.length -1) Args.last = true;
					d.append(this.nodeShell(Args));
				});
			}
			cs.append(d);
			return cs;
		}
		if (this.children.length > 0){
			$(this.children).each(function(i){
				var Args = {};
				if (i == 0) Args.first = true;
				if (i == self.children.length -1) Args.last = true;
				cs.append(this.nodeShell(Args));
			});
		}
		return cs;
	}
	
	Node.prototype.nodeFirstLevelShell = function(){
		var ns = $('<div></div>').attr({'class': ['navNS_',this.level].join(''), 'id': this.id})
		var node = this.node();
		ns.append(this.childrenLayer(1));
		if (this.styName){
			var sty = ['co_',this.styName].join('');
			var d = $('<div></div>').attr({'class': sty});
			d.append(node);
			if (this.children.length > 0){
				var cs = this.nodeChildrenShell();
				d.append(cs);
			}
			ns.append(d);
			return ns;
		}
		ns.append(node);
		if (this.children.length > 0){
			var cs = this.nodeChildrenShell();
			ns.append(cs);
		}
		return ns;
	}

	Node.prototype.nodeShell = function(Args){
		var ns = $('<div></div>').attr({'class': ['navNS_',this.level].join(''), 'id': this.id})
		var csOffset = $('<div></div>').css({'position': 'relative'}).attr({'id': [this.id,'_layerOffset'].join('')});
		ns.append(csOffset);
		var node = this.node();
		if (Args){
			var origClassName = node.attr('class');
			var newClassName = '';
			if (Args.first) newClassName += [' ',origClassName,'_first'].join('');
			if (Args.last) newClassName += [' ',origClassName,'_last'].join('');
			node.attr('class', origClassName + ' ' + newClassName);
		}
		if (this.styName){
			var sty = ['co_',this.styName].join('');
			var d = $('<div></div>').attr({'class': sty});
			d.append(node);
			ns.append(d);
			return ns;
		}
		ns.append(node);
		return ns;
	}

	Node.prototype.node = function(){
		var outer = $('<div></div>')
			.attr({'class': ['navEl_',this.level,'_',this.type].join('')});
		var n = $('<div></div>')
			.attr({'class': 'outer'});
		var text = $('<span></span>').attr({'class': 'inner'}).text(this.title);
		if (this.href){
			if (this.type == 'here'){
				text = $('<div></div>').attr({'class': 'noLink'}).append(text).css('cursor', 'hand');
			}else if(this.type == 'inPath'){
				text = $('<a></a>').attr({'href': this.href}).append(text).css('cursor', 'hand');
			}else if(this.type == 'normal'){
				text = $('<a></a>').attr({'href': this.href}).append(text).css('cursor', 'hand');
			}
		}
		n.append(text);
		outer.append(n);
		outer.css('cursor', 'hand');
		var self = this;
		if (this.children.length > 0 && this.level > 0){
			outer.bind('mouseover', function(e){
				var levelCont = ['#childrenLevelContainer_',self.level].join('');
				if ($(levelCont).size() == 0) $('body').append(self.childrenLayer());
				var layerOffset = ['#',self.id,'_layerOffset'].join('');
				$(levelCont).empty().append(self.nodeChildrenShell()).hide();
				$(layerOffset).append($(levelCont));
				$(levelCont).fadeIn(200);
			});
		}else{
			var level = self.level == 0 ? self.level + 1 : self.level;
			outer.bind('mouseover', function(e){
				 $('#childrenLevelContainer_' + level).fadeOut(200);
			});
		}
		return outer;
	}
	
/* << */


/* >> LivingLogic DropDown Navigation (requires jQuery 1.2.6) Version: rel-1-0-0 */
	LL_DropDownNavi = {
		path: [],
		layerWidth: 160,
		lay: {
			pixel: function(){
				return $('<img />').attr({'src': '../../px/spc.gif', 'width': 1, 'height': 1, 'alt': ''});
			},
			nodesOuterShell: function(content){
				var nos = $(
					'<div class="navOuterShell">' +
						'<div class="noDes1">' +
							'<div class="noDes2">' +
								'<div class="topImg">' +
									'<div class="bottomImg">' +
									'</div>' +
								'</div>' +
							'</div>' +
						'</div>' +
					'</div>'
				);
				nos.find('div.topImg').append(LL_DropDownNavi.lay.pixel())
				nos.find('div.bottomImg').append(content);
				nos.find('div.bottomImg').append(LL_DropDownNavi.lay.pixel());
				nos.bind('mouseleave', function(){
					$('div[id^=childrenLevelContainer_]').fadeOut(500);
				});
				return nos;
			}
		},
		sitemap: null,
		init: function(Args){
			this.sitemap = this.buildTreeFromArray(XIST4C_GLOBALS.sitemap);
			lay = LL_DropDownNavi.lay;
			var homeNode = this.sitemap[0].nodeFirstLevelShell();
			if (Args && Args.target){
				var target = $(['#',Args.target].join(''));
				target.append(lay.nodesOuterShell(homeNode));
			}else{
				$('div.navOuterShell').find('div.navNS_0').remove().end().find('div.noDes2').append(homeNode).bind('mouseleave', function(){
					$('div[id^=childrenLevelContainer_]').fadeOut(500);
				});
			}
		},
		renderFirstLevel: function(){
			var lay = LL_DropDownNavi.lay;
			var nodes = [];
			$(this.sitemap[1]).each(function(i){
				var node = this;
				if (typeof node == 'object' && typeof node.length != 'number'){
					var node = lay.nodeShell(node, lay.node(node))
					nodes.push(node);
				}
			});
			return lay.nodeChildrenShell(this.sitemap[0], nodes);
		},
		getChildren: function(id, level){
		},
		renderChildrenLayer: function(id, level){
			for (var i = 0; i < this.sitemap[1].length; i++){
				var node = this.sitemap[1][i];
				if (node.id == id){
					//if (i)
				}
			}
		},
		buildTreeFromArray: function(arr){
			var newArr = [];
			for (var i = 0; i < arr.length; i++){
				var data = arr[i];
				if (typeof data == 'object' && typeof data.length != 'number'){
					newArr.push(new Node(data));
				}else{
					newArr[newArr.length-1].children = this.buildTreeFromArray(data);
				}
			}
			return newArr;
		}
	}
/* << */


/* >> LivingLogic Logging (requires Mochikit 1.4) Version: rel-1-0-0*/
	LL_Logger = {
		loggingPane: null,
		llog: function(){
			var logStr = '';
			for (var i = 0; i < arguments[0].length; ++i){
				var arg = arguments[0][i];
				logStr += arg + ' ';
			}
			var item = DIV({'style': {'border-bottom': '1px solid #e1e1e1', 'padding': '3px 0'}}, repr(logStr));
			var self = this;
			if (!getElement('logging_pane')) self.makeLoggingPane();
			setTimeout(
				function(){
					getElement('logging_pane').appendChild(item);
				},
				500
			);
		},
		makeLoggingPane: function(){
			if (!this.loggingPane){
				var b = getElementsByTagAndClassName('body', null)[0];
				var content = DIV({'style': {'border': '1px solid #999'}});
				var inner = DIV(
					{
						'style': {
							'background-color': '#e1e1e1',
							'padding': '2px 10px',
							'border-bottom': '1px solid #999',
							'color': '#356798',
							'font-weight': 'bold',
							'font-size': '15px'
						}
					},
					"LIVINGLOGIC LOG"
				);
				var scroller = DIV(
					{
						'style': {
							'background-color': '#fff',
							'padding': '10px',
							'height': '180px',
							'overflow': 'auto'
						},
						'id': 'logging_pane'
					}
				);
				content.appendChild(inner);
				content.appendChild(scroller);
				setTimeout(function(){b.appendChild(content)}, 500);
				this.loggingPane = content;
			}
		}
	}
	llog = function(){
		LL_Logger.llog(arguments);
	}
/* << */


	function hideInputBg(field)
	{
		ipField = document.getElementById(field);
		ipField.style.background = "#fff";
	}
	
	
	function IE_Refresh(){
		if (document.all) location.reload();
	}
	window.onresize = IE_Refresh;
	
	
/* >> Standard Popup functions */
	function StandardPopup(Attrs){
		// @params IE and Gecko-Browser compatible window parameter attributes.
		this.params = ['left', 'top', 'location', 'menubar', 'resizable', 'scrollbars', 'status', 'toolbar', 'height', 'width'];
		this.href = Attrs.href ? Attrs.href : 'http://www.google.de'; // url to the popup content
		this.name = Attrs.name ? Attrs.name : 'standardPopup'; // standard window name
		this.height = Attrs.height ? Attrs.height : '550'; // standard height opened window
		this.width = Attrs.width ? Attrs.width : '650'; // standard width opened window
		this.left = Attrs.left ? Attrs.left : null; // window left position from the upper left corner of the client screen
		this.top = Attrs.top ? Attrs.top : null; // window top position from the top of the client screen
		this.locationbar = Attrs.location ? Attrs.location : 'no'; // ['yes', 'no'] display the locationbar
		this.menubar = Attrs.menubar ? Attrs.menubar : 'no'; // ['yes', 'no'] display the menubar
		this.resizable = Attrs.resizable ? Attrs.resizable : 'yes'; // ['yes', 'no'] allows the user to change the window size
		this.scrollbars = Attrs.scrollbars ? Attrs.scrollbars : 'yes'; // ['yes', 'no'] show scrollbars if necessary
		this.status = Attrs.status ? Attrs.status : 'no'; // ['yes', 'no'] show statusbar
		this.toolbar = Attrs.toolbar ? Attrs.toolbar : 'no'; // ['yes', 'no'] show toolbar
		this.blank = Attrs.blank ? Attrs.blank : 'false'; // ['true', 'false'] show window as popup or blank window
		this.wRef = null // window reference to make changes on the opened windowe
	}
	
	StandardPopup.prototype._formatParams = function()
	{
		var str = '\'';
		var objParam;
		for (var i = 0; i < this.params.length; ++i){
			objParam = this.params[i] == 'location' ? 'locationbar' : this.params[i];
			p = eval("this." + objParam);
			if (p){
				str += this.params[i] + '=' + p + ',';
			}
		}
		str = str.substring(0, str.length -1);
		str += '\'';
		return str;
	}
	
	StandardPopup.prototype.open = function(){
		if (this.blank){
			this.wRef = window.open(this.href);
		}else{
			var paraStr = this._formatParams();
			this.wRef = window.open(this.href, this.name, paraStr);
		}
		if (this.wRef)
			this.wRef.focus();
		return false;
	}
/* << */


/* >> rss publisher, (requires jQuery 1.2.6) Version: rel-2-0-0 */
	RSSPublisher = {
		publishers: false,
		register: function(args){
			this.append(args);
		},
		append: function(args){
			var RSSObj = new RSS();
			RSSObj.target = args.target;
			RSSObj.source = args.source;
			RSSObj.tags = args.tags;
			RSSObj.descLength = args.descLength;
			RSSObj.descLengthEnding = args.descLengthEnding
			RSSObj.pubDateFormat = args.pubDateFormat;
			RSSObj.refresh = args.refresh;
			RSSObj.itemsCount = args.itemsCount ? args.itemsCount : 5;
			RSSObj.staticTest = args.staticTest;
			if (args.acceptMimeTypes && typeof args.acceptMimeTypes == 'object'){
				RSSObj.acceptMimeTypesCgiStr = this.createMimeTypeCgiStr(args.acceptMimeTypes);
			}
			if (typeof this.publishers != 'boolean'){
				this.publishers.push(RSSObj);
			}else{
				this.publishers = [RSSObj];
			}
			RSSObj.getSource();
		},
		createMimeTypeCgiStr: function(mtList){
			var str = '&mimetypes=';
			for (var i = 0; i < mtList.length; ++i){
				str += encodeURIComponent(this.strTrim(mtList[i])) + ',';
			}
			return str.substring(0, str.length -1);
		},
		strTrim: function(str){
			var ccSpace = 32;
			var ps = 0;
			var pe = 0;
			var psLock = false;
			var peLock = false;
			for (var i = 0; i < str.length; ++i){
				if (str.charCodeAt(i) == ccSpace){
					if (! psLock) ps++;
					if (str.charCodeAt(str.length - 1 - i) == ccSpace){
						if (! peLock) pe++;
					}else{
						peLock = true;
					}
				}else{
					psLock = true;
					if (str.charCodeAt(str.length - 1 - i) == ccSpace){
						if (! peLock) pe++;
					}else{
						peLock = true;
					}
				}
			}
			var string = str.substring(ps, str.length);
			return string.substring(0, str.length - pe - ps);
		}
	}


	function RSS(){
		this.root = $('<div></div>');
		this.target = null;
		this.source = null;
		this.tags = ['title', 'description'];
		this.descLength = null;
		this.descLengthEnding = 32;
		this.pubDateFormat = 2;
		this.refresh = null;
		this.itemsCount = null;
		this.staticTest = false;
		this.acceptMimeTypesCgiStr = null;
		this.charCount = 0;
		this.stop = false;
	}
	
	RSS.prototype.getSource = function(){
		this.charCount = 0;
		this.stop = false;
		this.root.empty();
		if (this.staticTest){
			var url = this.source;
		}else{
			var url = '/urlfetcher/?url=' + encodeURIComponent(this.source);
		}
		if (this.acceptMimeTypesCgiStr && ! this.staticTest) url += this.acceptMimeTypesCgiStr;
		var self = this;
		$.ajax({
			type: 'GET',
			url: url,
			success: function(data, msg){self.handleSource(data, msg)},
			error: function(req, status, error){self.handleSourceError(req, status, error)}
		});
		if (this.refresh) setTimeout(function(){self.getSource();}, this.refresh * 1000);
	}
	
	RSS.prototype.handleSource = function(data, msg){
		var xmlElements = data;
		var items = $('item', xmlElements);
		var count = items.size();
		if (this.itemsCount <= items.size()) count = this.itemsCount;
		var tags = this.tags;
		var self = this;
		items.each(function(i){
			var href = self.getLink(items.get(i));
			self.appendElement(self.getItem(items.get(i), tags, href, i), self.root);
		});
		this.publish();
	}
	
	RSS.prototype.handleSourceError = function(def){
		console.log(def.message);
		$('#' + this.target).html('<div>Service ist voruebergehend nicht verfuegbar.</div>');
	}
	
	RSS.prototype.appendElement = function(elm, root){
		if (elm){
			$(root).append(elm);
			return true;
		}
		return false;
	}

	RSS.prototype.cloneXML2DOM = function(src, tar, igRoot, len, correctHyphen){
		for (var i = 0; i < src.childNodes.length; i++){
			var node = src.childNodes[i];
			switch (node.nodeType){
				case 1:
					if (! igRoot){
						var newNode = tar.appendChild(document.createElement(node.nodeName));
						for (var j = 0; j < node.attributes.length; j++){
							newNode.setAttribute(node.attributes[j].nodeName, node.attributes[j].nodeValue);
						}
						this.cloneXML2DOM(node, newNode, false, correctHyphen);
						break;
					}else{
						this.cloneXML2DOM(node, tar, false, correctHyphen);
						break;
					}
				case 3:
					if (len){
						var text = node.nodeValue;
						if (this.charCount + text.length < len){
							this.charCount += text.length;
						}else{
							var pos = 0;
							var t = '';
							while(1){
								t += text.substr(pos, 1);
								if (t.length + this.charCount >= len){
									var cCode = t.charCodeAt(t.length -1);
									if (cCode == this.descLengthEnding || pos == t.length){
										this.charCount += t.length;
										if (cCode == this.descLengthEnding){
											t += cCode == 32 ? '....' : ' ....';
											this.stop = true;
										}else{
											this.stop = false;
										}
										text = t;
										break;
									}
								}else if(text.length + this.charCount < len){
									var cCode = text.charCodeAt(text.length -1);
									this.charCount += text.length;
									text += cCode == 32 ? '....' : ' ....';
									this.stop = true;
									break;
								}
								pos++;
							}
						}
					}else{
						text = node.nodeValue;
					}
					if (correctHyphen) text = this.correctHyphenatedText(text);
					subNode = document.createTextNode(text);
				tar.appendChild(subNode);
			}
			if (this.stop){
				this.charCount = 0;
				break;
			}
		}
	}
	
	RSS.prototype.correctHyphenatedText = function(text){
		return text.replace(/-/g, '- ');
	}
	
	RSS.prototype.cloneContent = function(src, len, correctHyphen){
		var root = $('<div></div>').get(0);
		if (len){
			this.charCount = 0;
			this.stop = false;
		}
		this.cloneXML2DOM(src, root, false, len, correctHyphen);
		return root.childNodes;
	}

	RSS.prototype.getFirstNodeMatch = function(nName, parent, type){
		var n = parent.childNodes;
		var nName = nName.toLowerCase();
		type = type ? type : 1;
		for (var i = 0; i < n.length; ++i){
			if (n[i].nodeType == type && n[i].nodeName.toLowerCase() == nName){
				return n[i];
			}
		}
		return false;
	}
	
	RSS.prototype.getLink = function(item){
		return $('link', item).text();
	}
	
	RSS.prototype.getItem = function(item, tags, href, count){
		var sty = count % 2 == 0 ? 'item' : 'item odd';
		var itemShell = $('<div></div>').attr({'class': sty}).get(0);
		for (var j = 0; j < tags.length; ++j){
			switch (tags[j]){
				case 'title':
					this.appendElement(this.getTitle(item, href), itemShell);
					break;
				case 'description':
					this.appendElement(this.getDescription(item), itemShell);
					break;
				case 'pubDate':
					this.appendElement(this.getPubDate(item), itemShell);
					break;
			}
		}
		return itemShell;
	}

	RSS.prototype.getTitle = function(item, href){
		var title = $('title', item).get(0);
		if (title && title.childNodes.length > 0){
			return Layout.getTitle(this.cloneContent(title, false, true), href);
		}
		return false;
	}
	
	RSS.prototype.getDescription = function(item){
		var description = $('description', item).get(0);
		if (description && description.childNodes.length > 0) {
			return Layout.getDescription(this.cloneContent(description, this.descLength, true));
		}
		return false;
	}
	
	RSS.prototype.getPubDate = function(item){
		var pubDate = $('pubDate', item).get(0);
		if (pubDate && pubDate.childNodes.length > 0) {
			var dateGMT = pubDate.childNodes[0].nodeValue;
			pubDate.childNodes[0].nodeValue = this.formatDate(dateGMT);
			return Layout.getPubDate(this.cloneContent(pubDate, false, false));
		}
		return false;
	}
	
	RSS.prototype.formatDate = function(dateStr){
		var lang = $('html').attr('lang');
		var date = $.getISODate(new Date(dateStr), lang);
		var time = $.getISOTime(new Date(dateStr));
		if (this.pubDateFormat == 1){
			return date.short;
		}else if (this.pubDateFormat == 2){
			return date.middle;
		}else if (this.pubDateFormat == 3){
			return date.long;
		}else if (this.pubDateFormat == 4){
			return date.long + ' ' + time;
		}
	}
	
	RSS.prototype.publish = function(){
		$('#' + this.target).empty().html($(this.root).html());
	}
	
	Layout = {
		getTitle: function(t, href){
			if (href) t = $('<a></a>').attr({'href': href, 'target': '_blank'}).append(t);
			return $('<div></div>').attr({'class': 'rssElementTitle'}).append(
				$('<h3></h3>').append($('<span></span>').append(t))
			).get(0);
		},
		getDescription: function(desc){
			return $('<div></div>').attr({'class': 'rssElementDesc'}).append(
				$('<div></div>').attr({'class': 'inner'}).append(desc)
			).get(0);
		},
		getPubDate: function(d){
			return $('<div></div>').attr({'class': 'rssElementPubDate'}).append(
				$('<span></span>').append(d)
			).get(0);
		}
	}
/* << */


/* >> Generic Multimedia CMS tool, (requires jQuery 1.2.6) Version: rel-2-0-0 */
	function GenericMultimedia(args){
		this.lang = this.getLang();
		this.altText = args.altText;
		this.altImg = args.altImg;
		this.data = args.data;
		this.htmlSrcDom = this.getHtmlSrcDom(args.htmlSrc);
		this.javaApplet = this.isJavaApplet();
		this.modifyAndWriteDocumentElements();
	}
	
	GenericMultimedia.prototype.getLang = function(){
		var htmlEl = $('html');
		if (htmlEl.attr('lang')){
			return this.formatLang(htmlEl.attr('lang'));
		}else if(htmlEl.attr('xml:lang')){
			return this.formatLang(htmlEl.attr('xml:lang'));
		}
		return 'en';
	}
	
	GenericMultimedia.prototype.formatLang = function (lang){
		if (lang.search(/-/) > -1) return lang.substring(0, lang.search(/-/));
		return lang;
	}
	
	GenericMultimedia.prototype.getHtmlSrcDom = function(htmlSrc){
		if (typeof htmlSrc == 'string' && htmlSrc.length > 0){
			return $('<div><xml>' + htmlSrc + '</xml></div>').get(0);
		}
		return null;
	}
	
	GenericMultimedia.prototype.isJavaApplet = function(){
		var isJavaApp = false;
		$('xml > *', this.htmlSrcDom).each(
			function(n){
				if (this.nodeType == 1 && this.nodeName.toLowerCase() == 'object'){
					if($(this).attr('classid')){
						isJavaApp = $(this).attr('classid').search('java:') > -1;
					}
				}
			}
		);
		return isJavaApp;
	}
	
	GenericMultimedia.prototype.modifyAndWriteDocumentElements = function(){
		var output = '';
		var onlyEmbed = false;
		var model;
		var self = this;
		$('xml > *', this.htmlSrcDom).each(
			function(n){
				if (self.javaApplet || (! self.useEmbed() && ! self.javaApplet)){
					if (this.nodeType == 1 && this.nodeName.toLowerCase() == 'object'){
						model = false;
						output += self.startElement('object', self.getNodeAttributes(this), model);
						$('*', this).each(
							function(n){
								if (this.nodeType == 1 && this.nodeName.toLowerCase() == 'param'){
									model = true;
									output += self.startElement('param', self.getNodeAttributes(this), model);
								}
								if (this.nodeType == 1 && this.nodeName.toLowerCase() == 'embed'){
									model = true;
									output += self.startElement('embed', self.getNodeAttributes(this), model);
								}
							}
						);
					}
				}else{
					onlyEmbed = true;
					$('param, embed', this).each(
						function(n){
							if (this.nodeType == 1 && this.nodeName.toLowerCase() == 'embed'){
								model = true;
								output += self.startElement('embed', self.getNodeAttributes(this), model);
							}
						}
					);
				}
				if (self.altText || self.altImg){
					var text = '';
					var img = '';
					if (self.altText) var text = '<p>' + self.altText + '</p>';
					if (self.altImg) var img = '<img src="' + self.altImg + '" alt="" title="" />';
					if (!$.browser.safari){ //Workarround for safari 3.2.1 which interpreted the standard wrong.
						if (self.useEmbed() && ! self.javaApplet){
							output += '<noembed>' + text + img + '</noembed>';
						}else{
							output += text + img;
						}
					}
				}
				if (! onlyEmbed) output += self.endElement('object');
			}
		);
		document.write(output);
		
		
		
		/*var elms = this.htmlSrcDom.childNodes[0].childNodes;
		var onlyEmbed = false;
		var model;
		if (elms.length > 0){
			for (var i = 0; i < elms.length; ++i){
				var node = elms[i];
				var name = elms[i].nodeName.toLowerCase();
				var type = elms[i].nodeType;
				if (this.javaApplet || (! this.useEmbed() && ! this.javaApplet)){
					if (type == 1 && name == 'object'){
						model = false;
						output += this.startElement('object', this.getNodeAttributes(node), model);
						var objChilds = node.childNodes;
						for (var j = 0; j < objChilds.length; ++j){
							node = objChilds[j];
							name = objChilds[j].nodeName.toLowerCase();
							type = objChilds[j].nodeType;
							if (type == 1 && name == 'param'){
								model = true;
								output += this.startElement('param', this.getNodeAttributes(node), model);
							}
							if (type == 1 && name == 'embed'){
								model = true;
								output += this.startElement('embed', this.getNodeAttributes(node), model);
							}
						}
					}
				}else{
					onlyEmbed = true;
					var objChilds = node.childNodes;
					for (var j = 0; j < objChilds.length; ++j){
						node = objChilds[j];
						name = objChilds[j].nodeName.toLowerCase();
						type = objChilds[j].nodeType;
						if (type == 1 && name == 'embed'){
							model = true;
							output += this.startElement('embed', this.getNodeAttributes(node), model);
						}
					}
				}
			}
			if (this.altText || this.altImg){
				if (this.altText) var text = '<p>' + this.altText + '</p>';
				if (this.altImg) var img = '<img src="' + this.altImg + '" alt="" title="" />';
				if (this.useEmbed() && ! this.javaApplet){
					output += '<noembed>' + text + img + '</noembed>';
				}else{
					output += text + img;
				}
			}
			if (! onlyEmbed) output += this.endElement('object');
		}
		document.write(output);*/
	}
	
	GenericMultimedia.prototype.useEmbed = function(){
		var agent = navigator.userAgent;
		if (agent.search(/MSIE | Safari/) > -1) return false;
		return true;
	}
	
	GenericMultimedia.prototype.getNodeAttributes = function(node){
		var name = node.nodeName.toLowerCase();
		var codebase = false;
		if (node.attributes.length > 0){
			var attrs = {};
			var attrValue = '';
			for (var i = 0; i < node.attributes.length; ++i){
				var attrName = node.attributes[i].nodeName.toLowerCase();
				var attrValue = node.attributes[i].nodeValue;
				if (name == 'object' && (attrName == 'classid' || attrName == 'movie' || attrName == 'data')){
					if (attrName == 'classid'){
						attrs[attrName] = this.makeClassidAttribute(attrValue);
					}else if (this.javaApplet && attrName == 'codebase'){
						codebase = true;
						attrs[attrName] = this. makeJavaAppletCodebaseAttribute();
					}else{
						if (attrName == 'codebase') codebase = true;
						attrs[attrName] = this.data + this.copyCgiArgs(attrValue);
					}
				}else if (name == 'embed' && attrName == 'src'){
					attrs[attrName] = this.data + this.copyCgiArgs(attrValue);
				}else{
					attrs[attrName] = attrValue;
				}
			}
			if (this.javaApplet && ! codebase){
						codebase = true;
						attrs['codebase'] = this. makeJavaAppletCodebaseAttribute();
			}
			if (name == 'param'){
				attrNameValue = attrs.name.toLowerCase();
				attrValueValue = attrs.value;
				if (attrNameValue == 'filename' || attrNameValue == 'movie' || attrNameValue == 'src'){
					attrs.value = this.data + this.copyCgiArgs(attrValueValue);
				}
			}
			return attrs;
		}
		return null;
	}
	
	GenericMultimedia.prototype.copyCgiArgs = function(value){
		if (value.lastIndexOf('?') > -1){
			return value.substring(value.lastIndexOf('?'), value.length);
		}
		return '';
	}
	
	GenericMultimedia.prototype.startElement = function(name, attrs, single){
		var element = '<' + name;
		for (var attrName in attrs){
			element += ' ' + attrName + '="' + attrs[attrName] + '"';
		}
		if (single) return element += '/>';
		return element += '>';
	}

	GenericMultimedia.prototype.endElement = function(name){
		return '</' + name + '>';
	}

	GenericMultimedia.prototype.makeClassidAttribute = function(value){
		var data = this.data;
		if (value.search('java:') > -1){
			return 'java:' + data.substring(data.lastIndexOf('/') +1, data.length) + this.copyCgiArgs(value);
		}
		return value;
	}
	
	GenericMultimedia.prototype.makeJavaAppletCodebaseAttribute = function(){
		var data = this.data;
		return data.substring(0, data.lastIndexOf('/') +1);
	}
/* << */


/* >> bookmarking tool (requires jQuery 1.2.6 and ll StandardPopup) Version: rel-2-0-0 */
	function BookmarkStoreAt(args){
		this.targetName = null;
		this.container = null;
		this.titleHTML = null;
		this.textHTML = null;
		this.descSliceStandard = ' ...';
		this.imgPath = null;
		this.bmItems = ['delicious', 'mrwong', 'blinklist', 'yahoo', 'yigg', 'furl', 'oneview', 'folkd', 'linkarena', 'google', 'webnews'];
		this.bmURL = null;
		this.bmTitle = null;
		this.bmTargets = {};
		this.init(args);
	}
	
	BookmarkStoreAt.prototype.init = function(args){
		this.targetName = args.targetName;
		if ($('#' + args.targetName).size() > 0) this.container = $('#' + args.targetName).get(0);
		if (args.bmItems) this.bmItems = args.bmItems;
		this.imgPath = args.imgPath;
		this.titleHTML = args.titleHTML;
		this.textHTML = args.textHTML;
		this.bmURL = encodeURIComponent(location.href);
		this.bmTitle = encodeURIComponent(document.title);
		this.bmTargets['delicious'] = {'title': 'del.icio.us', 'desc': 'del.icio.us', 'url': 'http://del.icio.us/post?url=' + this.bmURL + '&title=' + this.bmTitle};
		this.bmTargets['mrwong'] = {'title': 'Mister Wong', 'desc': 'Mister Wong', 'url': 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' + this.bmURL + '&bm_description=' + this.bmTitle};
		this.bmTargets['blinklist'] = {'title': 'BlinkList', 'desc': 'BlinkList', 'url': 'http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=' + this.bmURL + '&Title=' + this.bmTitle};
		this.bmTargets['yahoo'] = {'title': 'Yahoo MyWeb', 'desc': 'Yahoo MyWeb', 'url': 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + this.bmURL + '&t=' + this.bmTitle};
		this.bmTargets['yigg'] = {'title': 'YiGG', 'desc': 'YiGG', 'url': 'http://yigg.de/neu?exturl=' + this.bmURL + '&exttitle=' + this.bmTitle};
		this.bmTargets['furl'] = {'title': 'Furl', 'desc': 'Furl', 'url': 'http://www.furl.net/storeIt.jsp?u=' + this.bmURL + '&t=' + this.bmTitle};
		this.bmTargets['oneview'] = {'title': 'OneView', 'desc': 'OneView', 'url': 'http://beta.oneview.de:80/quickadd/neu/addBookmark.jsf?URL=' + this.bmURL + '&title=' + this.bmTitle};
		this.bmTargets['folkd'] = {'title': 'Folkd', 'desc': 'Folkd', 'url': 'http://www.folkd.com/submit/page/' + this.bmURL};
		this.bmTargets['linkarena'] = {'title': 'Linkarena', 'desc': 'Linkarena', 'url': 'http://linkarena.com/bookmarks/addlink/?url=' + this.bmURL + '&title=' + this.bmTitle + '&desc=&tags='};
		this.bmTargets['google'] = {'title': 'Google', 'desc': 'Google', 'url': 'http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk=' + this.bmURL + '&title=' + this.bmTitle};
		this.bmTargets['webnews'] = {'title': 'Webnews', 'desc': 'Webnews', 'url': 'http://www.webnews.de/einstellen?url=' + this.bmURL + '&title=' + this.bmTitle};
		this._createLayout();
	}

	BookmarkStoreAt.prototype.store = function(target){
		this.open(this.bmTargets[target].url);
	}
	
	BookmarkStoreAt.prototype.open = function(url){
		if (typeof StandardPopup == 'function'){
			var p = new StandardPopup({'href': url, 'blank': true})
			p.open();
		}else{
			window.open(url);
		}
	}
	
	BookmarkStoreAt.prototype.changeDescSlice = function(key){
		var el = '#bmDescSlice_' + this.targetName;
		var slice = this.descSliceStandard;
		if (key) slice = '<span>' + this.bmTargets[key].desc + '</span>';
		$(el).html(slice);
	}
	
	BookmarkStoreAt.prototype._getTitle = function(){
		return $('<div class="bookmarkTitleOuter"><h3>' + this.titleHTML + '</h3></div>').get(0);
	}

	BookmarkStoreAt.prototype._getText = function(){
		return $(
			'<div class="bookmarkTextOuter"><p>' +
			this.textHTML + '<span id="bmDescSlice_' +
			this.targetName + '" class="bmDescSlice">' +
			this.descSliceStandard + '</span></p></div>'
		).get(0);
	}

	BookmarkStoreAt.prototype._getImageItems = function(){
		var bmi = this.bmItems;
		var imgOuter = $('<div class="imgOuter"></div>');
		var img;
		var self = this;
		for (var i = 0; i < bmi.length; ++i){
			function x(bmImgId){
				img = $('<img/>').attr({
						'src': self.imgPath + '/' + bmImgId + '.gif',
						'alt': self.bmTargets[bmImgId].title,
						'title': self.bmTargets[bmImgId].title
				}).click(
					function(e){self.store(bmImgId)}
				);
				if (self.textHTML.length > 0){
					img.mouseover(
						function(e){self.changeDescSlice(bmImgId)}
					).mouseout(
						function(e){self.changeDescSlice(false)}
					);
				}
				return img;
			};
			imgOuter.append(x(bmi[i]));
		}
		return imgOuter.get(0);
	}

	BookmarkStoreAt.prototype._createLayout = function(){
		var outer = DIV({'id': 'bookmarksOuter'});
		if (this.titleHTML.length > 0) outer.appendChild(this._getTitle());
		if (this.textHTML.length > 0) outer.appendChild(this._getText());
		outer.appendChild(this._getImageItems());
		this.container.appendChild(outer);
	}
/* << */


/* >> login teaser (requires jQuery 1.2.6) Version: rel-2-0-0 */
	function handleFieldPrompt(fieldList){
		$(function(){
			for (var i = 0; i < fieldList.length; ++i){
				function x(f){
					var elm = $('#' + f);
					elm.focus(
						function(){hidePrompt(f)}
					).blur(
						function(){showPrompt(f)}
					)
					if (elm.val() != '') hidePrompt(f);
				}
				x(fieldList[i]);
			}
		});
	}
	
	function hidePrompt(field, e){
		setNodeAttribute(field, 'style', {'background-image': 'none'});
	}

	function showPrompt(field, e){
		setNodeAttribute(field, 'style', null);
	}
/* << */


/* >> client current date (requires jQuery 1.2.6) Version: rel-2-0-0 */
	function getCurrentDate(id){
		$(function(){
			//getElement(id).innerHTML = '';
			var week = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
			var month = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];
			var date = new Date();
			var d = week[date.getDay()];
			var dom = date.getDate();
			var m = month[date.getMonth()];
			var y = date.getFullYear();
			var std = date.getHours();
			var min = date.getMinutes();
			var sec = date.getSeconds();
			if (dom < 10) dom = '0' + dom;
			if (min < 10) min = '0' + min;
			if (sec < 10) sec = '0' + sec;
			var timeSection = $('<span class="timeSection"><span class="inner"></span></span>');
			var timeSectionInner = timeSection.find('.inner');
			timeSectionInner.append('<span class="sepYT">,</span>')
				.append('<span class="hour">' + std + '</span>')
				.append('<span class="sepHM">:</span>')
				.append('<span class="min">' + min + '</span>')
				.append('<span class="sepHM">:</span>')
				.append('<span class="sec">' + sec + '</span>')
				.append('<span class="clock">Uhr</span>')
			$('#' + id).empty().append(
				$('<div></div>')
					.append('<span class="weekday">' + d + '</span>')
					.append('<span class="sepWD">,</span>')
					.append('<span class="text">den </span>')
					.append('<span class="day">' + dom + '.</span>')
					.append('<span class="month">' + m + '</span>')
					.append('<span class="year">' + y + '</span>')
					.append(timeSection)
			)
			setTimeout(function(){getCurrentDate(id)}, 1000);
		});
	}
/* << */


/* >> LL_TableColumnEnhancer (require jQuery 1.2.6) Version: rel-2-0-0 */
	LL_TableColumnEnhancer = function(){
		this.table = null;
		this.colConfig = [0,1,2,-3,-2,-1];
		this.tableFullWidth = 0;
		this.tableFullHeight = 0;
		this.tableCurrentWidth = 0;
		this.tableCurrentHeight = 0;
		this.variantsWidth = 0;
		this.variantsHeight = 0;
		this.moved = false;
		this.columns = []; // holds to hide columns with there cells
		this.idOuter = null;
		$('#variants').hide();
	}
	
	LL_TableColumnEnhancer.prototype.setColumnConfig = function(){
		if (arguments.length > 0){
			var conf = [];
			for (var i = 0; i < arguments.length; ++i){
				if (! isNaN(parseInt(arguments[i]))) conf.push(arguments[i]);
			}
			if (conf.length > 0) this.colConfig = conf;
			return this.colConfig;
		}
		return null;
	}
	
	LL_TableColumnEnhancer.prototype.init = function(id, idOuter, display){
		var t = $('#' + id).get(0);
		this.idOuter = idOuter;
		var columnsIndex = [];
		var self = this;
		if (t.nodeName.toLowerCase() == 'table'){
			this.table = t;
			this.tableFullWidth = t.offsetWidth;
			this.tableFullHeight = t.offsetHeight;
			var tbody = this.getElementChildNodeWithName(t, 'tbody', null);
			for (var i = 0; i < this.getElementChildNodesCount(tbody, 1); ++i){
				var row = this.getElementChildNodeWithName(tbody, 'tr', i);
				for (var j = 0; j < this.getElementChildNodesCount(row, 1); ++j){
					columnsIndex = this.getColumnsIndex(this.getElementChildNodesCount(row, 1), this.colConfig);
					var cell = this.getElementChildNodeWithName(row, 'td', j);
					if (! this._inArray(j, columnsIndex)){
						if (this.columns[j] instanceof DefaultTableColumn){
							this.columns[j].addCell(cell);
						}else{
							this.columns[j] = new DefaultTableColumn(j);
							this.columns[j].addCell(cell);
						}
					}
				}
			}
		}
		$('#variantsButtons').show();
		this.updateDisplay(display);
		$('#variantsViewAllButton').click(function(e){self.openInlinePopup()});
		$('#variantsViewLessButton').click(function(e){self.closeInlinePopup()});
		$('#variants').show();
		this.tableCurrentWidth = this.getContentAreaDimensions().w;
		this.tableCurrentHeight = t.offsetHeight;
		this.variantsWidth = $('#' + this.idOuter).width();
		this.variantsHeight = $('#' + this.idOuter).height();
	}

	LL_TableColumnEnhancer.prototype.getContentAreaDimensions = function(){
		var ca, dims;
		ca = $('td.contentColumn');
		return {'w': ca.width(), 'h': ca.height()};
	}
	
	LL_TableColumnEnhancer.prototype.openInlinePopup = function(){
		var contOrig = $('#variantsOuterShell');
		var cont = $('#variantsPopupContainer');
		var elm = $('#' + this.idOuter);
		if (elm){
			cont.empty().append(elm);
			contOrig.empty().append(
				$('<img/>').attr({
					'src': '../px/spc.gif',
					'height': this.variantsHeight + 32,
					'width': 1,
					'class': 'variantsDvShellDummy'
				})
			);
			this.updateDisplay(true);
			$('#variantsInlinePopupOuter').show();
			this.tableFullWidth = this.table.offsetWidth;
			if (this.tableFullWidth <= this.tableCurrentWidth){
				this.tableFullWidth = this.tableCurrentWidth;
				setNodeAttribute(this.table, 'style', {'width': this.tableCurrentWidth + 'px'});
			}
			var distance = ((this.tableFullWidth - this.tableCurrentWidth) / 2) + 12;
			$('#variantsPopupShell').css('left', '-' + distance + 'px');
			this.moved = true;
			var self = this;
			$('#variantsViewLessButton').click(function(e){self.closeInlinePopup()});
		}
	}
	
	LL_TableColumnEnhancer.prototype.closeInlinePopup = function(){
		var cont = $('#variantsOuterShell').get(0);
		$('#variantsInlinePopupOuter').hide();
		var elm = $('#' + this.idOuter);
		if (elm.size() > 0){
			this.updateDisplay(false);
			cont.replaceChild(elm.get(0), this.getElementChildNodeWithName(cont, 'img', null));
		}
		var self = this;
		$('#variantsViewAllButton').click(function(e){self.openInlinePopup()});
	}

	LL_TableColumnEnhancer.prototype.updateDisplay = function(display, e){
		if (e) e.stop();
		this.hidden = true;
		if (display) this.hidden = false;
		for (var i = 0; i < this.columns.length; ++i){
			var col = this.columns[i];
			if (col instanceof DefaultTableColumn) col.setDisplay(display);
		}
		if (this.hidden){
			$('#variantsViewAllButton').css({'display': 'inline'});
			$('#variantsViewLessButton').css({'display': 'none'});
		}else{
			$('#variantsViewAllButton').css({'display': 'none'});
			$('#variantsViewLessButton').css({'display': 'inline'});
		}
	}
	
	LL_TableColumnEnhancer.prototype._inArray = function(needle, arr){
		for (var i = 0; i < arr.length; ++i){
			if (needle == arr[i]) return true;
		}
		return false;
	}
	
	LL_TableColumnEnhancer.prototype.getElementChildNodeWithName = function(parent, name, pos){
		var pos = pos ? pos : 0;
		var count = 0;
		var childs = parent.childNodes;
		if (childs){
			for (var i = 0; i < childs.length; ++i){
				var c = childs[i];
				if (c.nodeType == 1){
					var nname = c.nodeName.toLowerCase();
					var n = name.toLowerCase();
					if (n = nname && count == pos) return c;
					++count;
				}
			}
		}
		return null;
	}
	
	LL_TableColumnEnhancer.prototype.getElementChildNodesCount = function(parent, type){
		var childs = parent.childNodes;
		var count = 0;
		if (childs){
			for (var i = 0; i < childs.length; ++i){
				var c = childs[i];
				if (c.nodeType == type) ++count;
			}
		}
		return count;
	}

	LL_TableColumnEnhancer.prototype.getColumnsIndex = function(colCount, permCols){
		for (var i = 0; i < permCols.length; ++i){
			if (permCols[i] < 0) permCols[i] += colCount;
		}
		return permCols;
	}


	DefaultTableColumn = function(cid){
		this.cid = cid;
		this.cells = [];
		this.hidden = false;
	}
	
	DefaultTableColumn.prototype.addCell = function(Cell){
		if (Cell.nodeName.toLowerCase() == 'td' || Cell.nodeName.toLowerCase() == 'th'){
			this.cells.push(new DefaultTableCell(Cell));
		}
	}
	
	DefaultTableColumn.prototype.setDisplay = function(display){
		this.hidden = true;
		if (display) this.hidden = false;
		for (var i = 0; i < this.cells.length; ++i){
			this.cells[i].setDisplay(display);
		}
	}


	DefaultTableCell = function(domel){
		this.domel = domel;
		this.hidden = false;
		this.attrs = {};
		this.children = null;
		this.content = null;
		this._backupAttrsAndChildren();
		this._backupContent();
	}
	
	DefaultTableCell.prototype._backupAttrsAndChildren = function(){
		var elm = this.domel;
		this.children = elm.childNodes;
		for (var i = 0; i < elm.attributes.length; ++i){
			var attr = elm.attributes[i];
			var name = attr.nodeName;
			var value = attr.nodeValue;
			this.attrs[name] = value;
		}
	}
	
	DefaultTableCell.prototype._backupContent = function(){
		var node = this.domel;
		while (node.nodeType == 1){
			node = node.childNodes[0];
			if (node && node.nodeType == 3){
				this.content = node.nodeValue;
				break;
			}else{
				if (! node) break;
			}
		}
	}
	
	DefaultTableCell.prototype.setDisplay = function(display){
		if (display){
			this.hidden = false;
			$(this.domel).css({'display': ''});
			return true;
		}
		this.hidden = true;
		$(this.domel).css({'display': 'none'});
		return true;
	}
/* << */


/* >> LL_CookieTool Version: rel-1-1-0  **-Deprecated-** use jquery cookie plugin instead */
	LL_CookieTool = {
		isCookieEnabled: function(){
			if (navigator.cookieEnabled == true) return true;
			return false;
		},
		setCookies: function(cObjs){
			for (var i = 0; i < arguments.length; ++i){
				var c = arguments[i];
				c.setCookie();
			}
		},
		getCookie: function(name){
			var cstr = document.cookie;
			if (cstr.length > 0){
				cookies = cstr.split('; ');
				for (var i = 0; i < cookies.length; ++i){
					var cook = cookies[i];
					if (cook.substring(0, cook.lastIndexOf('=')) == name){
						return cook.substring(cook.lastIndexOf('=') + 1 , cook.length);
					}
				}
			}
			return null;
		},
		eraseCookie: function(name, domain, path){
			var c = new CookieData(name, null, domain, path, null, null);
			c.eraseCookie();
		}
	}
	
	CookieData = function(name, value, domain, path, expires, secure){
		this.name = name;
		this.value = value;
		this.domain = domain;
		this.path = path;
		this.expires = expires;
		this.secure = secure;
	}
	
	CookieData.prototype.setCookie = function(){
		var cook = this.name + '=' + unescape(this.value);
		cook += this.domain ? '; domain=' + this.domain : '';
		cook += this.expires ? '; expires=' + this.expires : '';
		cook += this.path ? '; path=' + this.path : '/';
		cook += this.secure ? '; secure' : '';
		document.cookie = cook;
	}
	
	CookieData.prototype.eraseCookie = function(){
		var cook = this.name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT';
		cook += this.domain ? '; domain=' + this.domain : '';
		cook += this.path ? '; path=' + this.path : '/';
		document.cookie = cook;
	}
/* << */


/* >> LL_FontSizeAdjust (require jQuery 1.2.6, plugins: cookie 1.0) Version: rel-2-0-0 */
	LL_FontSizeAdjust = {
		symbols: [],
		currentFS: 0,
		domain: location.hostname,
		customerPath: 'standard/xx/',
		coId: -1,
		init: function(path, coId){
			// path: Specifies the image and css path
			// coId: The content object id of a special startpage with different css rules.
			if (coId) this.coId = coId;
			this.connectAndGetSymbols();
			this.setCustomerPath(path);
			this.handleFontSize(this.getFontSize());
		},
		connectAndGetSymbols: function(){
			var self = this;
			$('div[id*=font_adjust_symbol_]').each(
				function(n){
					self.symbols.push(this);
					$(this).click(function(){self.handleFontSize(n)});
				}
			);
		},
		setCustomerPath: function(path){
			var p = path ? path : this.customerPath;
			this.customerPath = p;
		},
		getFontSize: function(){
			var size = $.cookie('FontSizeAdjust');
			if (size) return size;
			return this.currentFS;
		},
		setFontSize: function(size){
			$.cookie('FontSizeAdjust', size, {path: '/', expires: 100});
			return size;
		},
		isStartpage: function(){
			var ps = location.href.search(/_id_/);
			if (ps > -1){
				var url = location.href;
				var slice1 = url.substring(ps + 4, url.length);
				var coId = slice1.substring(0, slice1.indexOf('_'));
				if (this.coId == coId) return true;
				return false;
			}
			return false;
		},
		handleFontSize: function(size, e){
			if (navigator.cookieEnabled){
				this.currentFS = this.setFontSize(size);
				var head = $('head').get(0);
				$('#fontSizeAdjustCssLink').remove();
				$('#fontSizeAdjustCssLink_startpage').remove();
				var l1 = document.createElement('link');
				l1.href = this.customerPath + 'layout_fontSize' + this.currentFS + '.css';
				l1.type = 'text/css';
				l1.rel = 'stylesheet';
				l1.id = 'fontSizeAdjustCssLink';
				head.appendChild(l1);
				if(this.isStartpage()){
					var l2 = document.createElement('link');
					l2.href = this.customerPath + 'layout_fontSizeStartpage' + this.currentFS + '.css';
					l2.type = 'text/css';
					l2.rel = 'stylesheet';
					l2.id = 'fontSizeAdjustCssLink_startpage';
					head.appendChild(l2);
				}
			}
			this.switchStyleSheet(this.currentFS);
		},
		switchStyleSheet: function(size){
			// change the stylesheet element at the head element.
			if (this.symbols.length > 0){
				for (var i = 0; i < this.symbols.length; ++i){
					var s = this.symbols[i];
					if (i == size){
						this.updateSymbol(s, 'act');
					}else{
						this.updateSymbol(s, 'pass');
					}
				}
			}
		},
		updateSymbol: function(sym, status){
			var className = sym.className;
			var pref = className.substring(0, className.lastIndexOf('_') + 1);
			var suff = className.substring(className.lastIndexOf('_') + 1, className.length).toLowerCase();
			if (status){
				sym.className = pref + status;
				return sym;
			}else{
				if (suff == 'pass'){
					sym.className = pref + 'act';
					return sym;
				}
				sym.className = pref + 'pass';
				return sym;
			}
			return null;
		},
		handleSymbolStyle: function(){
			// switch the symbol css rules to get an active or passive symbol.
		}
	}
/* << */


/* >> LL_RelationshipManager (require mochikit 1.4) Version: rel-2-0-0 */
	LL_RelationshipManager = function(){
		this.relHandler = [];
	}
	
	LL_RelationshipManager.prototype.addRelHandler = function(Handler){
		if (Handler instanceof DefaultRelationHandler){
			this.relHandler.push(Handler);
			if (Handler.elms.length > 0 && Handler.autoAction) Handler.action();
		}
	}

	// abstract relation handler
	DefaultRelationHandler = function(){
		this.name = 'testDefaultHandler';
		this.links = document.links;
		this.autoAction = false;
		this.filter(this.name);
		this.elms = []; // holds the elements and the rel attrs as a json object
	}
	
	// filter links wih rels with a given name and allocates the attributes.
	DefaultRelationHandler.prototype.filter = function(name){
		var links = this.links;
		for (var i = 0; i < links.length; ++i){
			this.addElementAndGetRelAttrs(links[i]);
		}
	}
	
	DefaultRelationHandler.prototype.addElementAndGetRelAttrs = function(elm){
		var attr = $(elm).attr('rel');
		if (attr){
			if (attr.toLowerCase() == this.name || attr.substring(0, attr.indexOf('[')).toLowerCase() == this.name){
				var relAttrs = null;
				if (attr.search(/\[/) > -1 && attr.search(/\]/) > -1){
					relAttrs = attr.substring(attr.indexOf('[') + 1, attr.lastIndexOf(']'));
					relAttrs = relAttrs.split(',');
				}
				var obj = {'elm': elm, 'relAttrs': relAttrs};
				this.elms.push(obj);
				return obj;
			}
		}
		return null;
	}
	
	DefaultRelationHandler.prototype.action = function(){} // do something with the rels


	// Use the xpopup functionality to display detail information
	XPopupHandler = function(){
		this.name = 'xpopup';
		this.autoAction = true;
		this.filter(this.name);
	}
	XPopupHandler.prototype = new DefaultRelationHandler();
	
	XPopupHandler.prototype.action = function(){
		var self = this;
		setTimeout(
			function(){
				for (var i = 0; i < self.elms.length; ++i){
					var TAttrs = {};
					var TAttrsArr = [];
					var elm = self.elms[i].elm;
					var eAttrs = self.elms[i].relAttrs;
					if (eAttrs && eAttrs.length == 6){
						TAttrs.url = elm.href;
						TAttrs.height = 'auto';
						TAttrs.width = 'auto';
					}else{
						var TAttrsRaw = eAttrs.slice(6);
						for (var j = 0; j < TAttrsRaw.length; ++j){
							var TAttrRawSplitted = TAttrsRaw[j].split(',');
							for (var k = 0; k < TAttrRawSplitted.length; ++k){
								var tAttrRaw = TAttrRawSplitted[k];
								var key = tAttrRaw.substring(0, tAttrRaw.indexOf(':'));
								var value = tAttrRaw.substring(tAttrRaw.indexOf(':') + 1, tAttrRaw.length);
								TAttrs[key] = value;
							}
						}
						if (! TAttrs.url) TAttrs.url = elm.href;
					}
					LL_XPopup.registerPopup(
						elm,
						eAttrs[0],
						eAttrs[1],
						eAttrs[2],
						eAttrs[3],
						eAttrs[4],
						eAttrs[5],
						TAttrs
					);
				}
			},
			10
		);
	}
	
	// use the xpopup to display lightbox photogalleries
	LightboxHandler = function(){
		this.name = 'lightbox';
		this.autoAction = true;
		this.filter(this.name);
	}
	LightboxHandler.prototype = new DefaultRelationHandler();
	
	LightboxHandler.prototype.action = function(){
		var self = this;
		setTimeout(
			function(){
				for (var i = 0; i < self.elms.length; ++i){
					var TAttrs = {};
					var TAttrsArr = [];
					var elm = self.elms[i].elm;
					var eAttrs = self.elms[i].relAttrs;
					if (eAttrs && eAttrs.length == 1){
						TAttrs.group = eAttrs[0];
					}
					TAttrs.url = elm.href;
					TAttrs.background = 'true';
					TAttrs.fixedPosition = 'true';

					LL_XPopup.registerPopup(
						elm,
						'click',
						'IMAGE',
						'p_c',
						'c',
						0,
						0,
						TAttrs
					);
				}
			},
			10
		);
	}
/* << */


/* >> LL_XPopup (require jQuery 1.2.6 and LL_RelationshipManager with XPopupHandler) Version: rel-2-0-0 */
	/*
		Possible positions for the source and popup element:
		nw, w, sw, n, c, s, ne, e, se, p_nw, p_w, p_sw, p_n, p_c, p_s, p_ne, p_e, p_se, cursor (only for the source element)
		
		possible types: IMAGE, WEBPAGE, AJAX
			IMAGE: Display images in a special gallery mode.
			WEBPAGE: Sisplay a web page in an iframe.
			AJAX: Load ajax-content into a div container with a given url.
		
		Example for rel-Attributes: xpopup[onmouseenter,WEBPAGE,ne,nw,10,10,height:300,width:200]
			identfier[event, type, source position, popup position, popup margin width, popup margin height,--mode attributes--]
			--mode attributes--:
				A commata separated list with key:value items.
				Note: Each mode can have different attributes.
	*/
	LL_XPopup = {
		xpopups: [],
		popup: null,
		initScrollPos: 0,
		preparedGallery: [],
		currentGalleryIdx: -1,
		galleryOverall: -1,
		slideshowBusy: 0,
		slideshowInterval: null,
		nextConnect: null,
		previousConnect: null,
		closeConnect: null,
		registerPopup: function(elm, event, type, spos, ppos, margin_w, margin_h, TypeAttrs){
			//type = 'AJAX';
			var self = this;
			setTimeout(function(){self.makePopup()}, 1);
			switch (type){
				case 'IMAGE':
					this.xpopups.push(new ImageXPopup(elm, event, spos, ppos, margin_w, margin_h, TypeAttrs));
					break;
				case 'WEBPAGE':
					this.xpopups.push(new WebpageXPopup(elm, event, spos, ppos, margin_w, margin_h, TypeAttrs));
					break;
				case 'AJAX':
					this.xpopups.push(new AjaxXPopup(elm, event, spos, ppos, margin_w, margin_h, TypeAttrs));
					break;
			}
		},
		makePopup: function(){
			if (! this.popup){
				this.popup = $('<div></div>').append(
						this.makeCloseButton()
					).append(
						$('<div>').attr(
							{'id': 'xpopupContent'}
						)
					).append(
						$('<div>').attr(
							{'id': 'xpopupAddOns'}
						)
					).attr(
						{'id': 'xpopup', 'class': 'xpopup'}
					).css(
						{'display': 'none'}
					).get(0);
				$('body').append(this.popup);
			}
			return this.popup;
		},
		makeCloseButton: function(){
			var self = this;
			$(document).keydown(function(e){self.destruct(e)});
			return $('<div>').append(
				$('<div>').append(
					$('<img>').attr(
						{'src': '../px/spc.gif', 'alt': '', 'id': 'xpopupCloseGfx'}
					).click(
						function(e){self.destruct(e)}
					)
				).attr(
					{'class': 'inner'}
				)
			).attr(
				{'id': 'xpopupCloseButton'}
			).get(0)
		},
		showBodyScrollbars: function(){
			$('body').css('overflow', 'auto');
		},
		cleanUp: function(){
			var self = this;
			var bg = $('#xpopup_background');
			if (bg.size() > 0){
				bg.fadeOut(
					function(){
						bg.remove();
						self.showBodyScrollbars();
					}
				)
			}else{
				this.showBodyScrollbars();
			}
			$('#xpopupGalleryOverview').remove();
			$('#xpopup').unbind('.specials');
			with(this){
				initScrollPos = 0;
				preparedGallery = [];
				currentGalleryIdx = -1;
				galleryOverall = -1;
				slideshowBusy = 0;
				if (slideshowInterval) clearTimeout(slideshowInterval);
			}
		},
		destruct: function(e){
			if (this.popup){
				if(e){
					if (e.type == 'keydown'){
						if (e.keyCode == 27){
							$(this.popup).fadeOut();
							this.cleanUp();
						}
					}else if (e.type == 'click' || e.type == 'mouseleave' || e.type == 'mouseout'){
						if (e.type == 'click'){
							$(this.popup).fadeOut();
							this.cleanUp();
						}else{
							$(this.popup).hide();
							this.cleanUp();
						}
					}
				}else{
					$(this.popup).fadeOut();
					this.cleanUp();
				}
			}
		}
	}
	
	DefaultXPopup = function(src, event, spos, ppos, margin_w, margin_h, TypeAttrs){
		this.src = src;
		this.event = event;
		this.spos = spos; // layer position on the connected source element
		this.ppos = ppos; // position of the popup layer relative to the layer position of the source element
		this.mw = margin_w; // margin width of the popup from the connected source element (negative integer values allowed)
		this.mh = margin_h; // margin height of the popup from the connected source element (negative integer values allowed)
		this.Attrs = TypeAttrs;
		this.srcDeferred = null;
		this.srcOutDeferred = null;
		if (arguments.length >= 6){
			this.connectSrcElement();
		}
	}

	DefaultXPopup.prototype.connectSrcElement = function(){
		var self = this;
		$(this.src).bind(this.event, function(e){self.show(e)});
	}

	DefaultXPopup.prototype.pushContentIntoPopup = function(){
		$('#xpopupContent').empty().append(this.getContent());
	}
	
	DefaultXPopup.prototype.getContent = function(){
		return $('<span>Test Content of the default xpopup!</span>').get(0);
	}

	DefaultXPopup.prototype.getAttr = function(name){
		if (this.Attrs){
			for (var k in this.Attrs){
				if (k.toLowerCase() == name.toLowerCase()) return this.Attrs[name];
			}
		}
		return null;
	}

	DefaultXPopup.prototype.setPopupPosition = function(src, mousePos){
		var self = this;
		var p = LL_XPopup.popup;
		var srcDims = {'w': $(src).outerWidth(), 'h': $(src).outerHeight()};
		var srcPos = {'x': $(src).offset().left, 'y': $(src).offset().top}
		var mCords = mousePos;
		var pDims = {'w': $(p).width(), 'h': $(p).height()};
		var vpDims = {'w': $(window).width(), 'h': $(window).height()};
		var vpPos = {'x': $(document).scrollLeft(), 'y': $(document).scrollTop()}
		var pWidth = pDims.w;
		var pHeight = pDims.h;
		var buffer = 0;
		var xPos, yPos, x, y;

		LL_XPopup.initScrollPos = vpPos;
		if (this.spos.substring(0, 2) == 'p_'){
			srcDims = vpDims;
			if(! this.isIE()){
				if (this.isFixedPosition()) vpPos = {'x': 0, 'y': 0};
			}
			srcPos = vpPos;
		}else{
			if(! this.isIE()){
				if (this.isFixedPosition()){
					srcPos.x = srcPos.x - vpPos.x;
					srcPos.y = srcPos.y - vpPos.y;
					vpPos = {'x': 0, 'y': 0};
				}
			}
		}
		if (this.spos == 'nw' || this.spos == 'w' || this.spos == 'sw' || this.spos == 'p_nw' || this.spos == 'p_w' || this.spos == 'p_sw'){
			x = srcPos.x;
		}else if (this.spos == 'n' || this.spos == 'c' || this.spos == 's' || this.spos == 'p_n' || this.spos == 'p_c' || this.spos == 'p_s'){
			x = srcPos.x + (srcDims.w / 2);
		}else if (this.spos == 'ne' || this.spos == 'e' || this.spos == 'se' || this.spos == 'p_ne' || this.spos == 'p_e' || this.spos == 'p_se'){
			x = srcPos.x + srcDims.w;
		}else if (this.spos == 'cursor'){
			x = mCords.x;
		}else{
			x = 0;
		}
		
		if (this.spos == 'nw' || this.spos == 'n' || this.spos == 'ne' || this.spos == 'p_nw' || this.spos == 'p_n' || this.spos == 'p_ne'){
			y = srcPos.y;
		}else if (this.spos == 'w' || this.spos == 'c' || this.spos == 'e' || this.spos == 'p_w' || this.spos == 'p_c' || this.spos == 'p_e'){
			y = srcPos.y + (srcDims.h / 2);
		}else if (this.spos == 'sw' || this.spos == 's' || this.spos == 'se' || this.spos == 'p_sw' || this.spos == 'p_s' || this.spos == 'p_se'){
			y = srcPos.y + srcDims.h;
		}else if (this.spos == 'cursor'){
			y = mCords.y;
		}else{
			y = 0;
		}
		
		relPopPos = this.getRelativePopupPosition(x, y, srcDims, pDims, this.ppos);
		xPos = relPopPos.x;
		yPos = relPopPos.y;
		if (xPos + pWidth > vpDims.w + vpPos.x) xPos = vpDims.w + vpPos.x - (pWidth + buffer);
		if (yPos + pHeight > vpDims.h + vpPos.y) yPos = vpDims.h + vpPos.y - (pHeight + buffer);
		if (xPos <= vpPos.x) xPos = vpPos.x + buffer;
		if (yPos <= vpPos.y) yPos = vpPos.y + buffer;

		$(LL_XPopup.popup).animate({'left': xPos, 'top': yPos}, 'fast', 'swing', function(){
				self.handlePopupPositionMode();
		});
	}
	
	DefaultXPopup.prototype.setPopupWidth = function(){
		$('#xpopup, #xpopupContent').css({'width': null});
	}
	
	DefaultXPopup.prototype.isIE = function(){
		if(window.clientInformation){
			if (window.clientInformation.appName == 'Microsoft Internet Explorer') return true;
		}
		return false;
	}
	
	DefaultXPopup.prototype.isFixedPosition = function(){
		var fp = this.getAttr('fixedPosition');
		if (fp){
			if (fp.toLowerCase() == 'true' || fp == 1) return true;
		}
		return false;
	}
	
	DefaultXPopup.prototype.handlePopupPositionMode = function(e){
		if (! this.isIE()){
			if (this.isFixedPosition()){
				return $(LL_XPopup.popup).attr('class', 'xpopup_fixed');
			}
		}
		return $(LL_XPopup.popup).attr('class', 'xpopup');
	}
	
	DefaultXPopup.prototype.getRelativePopupPosition = function(xPos, yPos, srcDims, pDims, ppos){
		if (!ppos || ppos == 'nw'){
			xPos += this.mw / 1;
			yPos += this.mh / 1;
			return {'x': xPos, 'y': yPos};
		}else if(ppos == 'w'){
			xPos += this.mw / 1;
			return {'x': xPos, 'y': yPos - (pDims.h / 2)};
		}else if(ppos == 'sw'){
			xPos += this.mw / 1;
			yPos -= this.mh / 1;
			return {'x': xPos, 'y': yPos - pDims.h};
		}else if(ppos == 'n'){
			yPos += this.mh / 1;
			return {'x': xPos - (pDims.w / 2), 'y': yPos};
		}else if(ppos == 'c'){
			return {'x': xPos - (pDims.w / 2), 'y': yPos - (pDims.h / 2)};
		}else if(ppos == 's'){
			yPos -= this.mh / 1;
			return {'x': xPos - (pDims.w / 2), 'y': yPos - pDims.h};
		}else if(ppos == 'ne'){
			xPos -= this.mw / 1;
			yPos += this.mh / 1;
			return {'x': xPos - pDims.w, 'y': yPos};
		}else if(ppos == 'e'){
			xPos -= this.mw / 1;
			return {'x': xPos - pDims.w, 'y': yPos - (pDims.h / 2)};
		}else if(ppos == 'se'){
			xPos -= this.mw / 1;
			yPos -= this.mh / 1;
			return {'x': xPos - pDims.w, 'y': yPos - pDims.h};
		}
	}
	
	DefaultXPopup.prototype.handleSrcAndPopupConnect = function(){
		if (this.event != 'click' && this.spos != this.ppos){
			$(this.src).bind('mouseleave', function(e){LL_XPopup.destruct(e)});
		}else if (this.event != 'click' && this.spos == this.ppos){
			$(LL_XPopup.popup).bind('mouseleave', function(e){LL_XPopup.destruct(e)});
		}
	}
	
	DefaultXPopup.prototype.makeAddOns = function(e){
		$('#xpopupAddOns').empty();
	}
	
	DefaultXPopup.prototype.makeBackground = function(r,g,b){
		var red, green, blue;
		rv = r ? r : 0;
		gv = g ? g : 0;
		bv = b ? b : 0;
		var bg = $('<div> </div>').attr(
			'id', 'xpopup_background'
		).css(
			{
				'display': 'none',
				'position': 'absolute',
				'z-index': 500000,
				'left': 0,
				'top': 0,
				'background-color': 'rgb(' + rv + ',' + gv + ',' + bv + ')',
				'width': $('body').get(0).scrollWidth + 'px',
				'height': $('body').get(0).scrollHeight + 'px'
			}
		);
		if ($('#xpopup_background').size() == 0){
			var bg = $(bg).click(function(e){LL_XPopup.destruct(e)})
			$('body').append(bg);
			bg.css({'display': 'block', 'opacity': 0}).fadeTo('fast', 0.9);
		}
	}
	
	DefaultXPopup.prototype.hideBodyScrollbars = function(){}

	DefaultXPopup.prototype.show = function(e){
		var mousePos = {'x': 0, 'y': 0};
		if (e){
			e.preventDefault();
			mousePos = {'x': e.pageX, 'y': e.pageY};
		}
		var aos = $('#xpopupAddOns');
		aos.hide();
		src = this.src;
		this.hideBodyScrollbars();
		this.pushContentIntoPopup();
		this.handleSrcAndPopupConnect();
		this.makeAddOns();
		aos.show();
		var self = this;
		setTimeout(
			function(){
				self.setPopupPosition(src, mousePos);
				$(LL_XPopup.popup).fadeIn();
			},
			1
		);
	}

	// Image xpopup
	ImageXPopup = function(src, event, spos, ppos, margin_w, margin_h, TypeAttrs){
		/* TypeAttrs: url, href, jsFunc, height, width, background
		 * url: Source of the image to display.
		 * group: An identifier for group related images.
		 * href: Link reference for the image.
		 * jsFunc: Mochikit bind or partial functions.
		 * height: Popup height.
		 * width: Popup width.
		 * background: The popup stay on a dark background
		 * fixedPosition: The popup is position fixed and has no response on scroll events.
		 */
		this.constructor(src, event, spos, ppos, margin_w, margin_h, TypeAttrs);
		this.image = this.makeImage(this.getAttr('url'), {'border': 0, 'alt': '', 'title': ''});
		this.appearingHud = null;
	}
	ImageXPopup.prototype = new DefaultXPopup();
	
	ImageXPopup.prototype.setPopupWidth = function(w){
		var p = $('#xpopup');
		var pc = $('#xpopupContent');
		var imgWidth = w.substring(0, w.length -2) / 1;
		var pl = pc.css('padding-left');
		pl = pl.substring(0, pl.length -2) / 1;
		var pr = pc.css('padding-right');
		pr = pr.substring(0, pr.length -2) / 1;
		p.css({'width': (imgWidth + pl + pr) + 'px'});
	}
	
	ImageXPopup.prototype.getSrcImage = function(){
		nodes = $('img', this.src);
		if (nodes.size() > 0) return nodes.get(0);
		return null;
	}
	
	ImageXPopup.prototype.getSrcImageTitle = function(){
		var elm = this.getSrcImage();
		if (elm && elm.title && elm.title != '') return elm.title;
		return null;
	}

	ImageXPopup.prototype.prepareGalleryByGroup = function(){
		LL_XPopup.preparedGallery = [];
		LL_XPopup.currentGalleryIdx = -1;
		LL_XPopup.galleryOverall = -1;
		var grp = this.getAttr('group');
		if (grp){
			var xpopups = LL_XPopup.xpopups;
			var idx = -1;
			for (var i = 0; i < xpopups.length; ++i){
				var xp = xpopups[i];
				if (xp instanceof ImageXPopup){
					if (xp.getAttr('group') == grp){
						idx++;
						if (xp === this) LL_XPopup.currentGalleryIdx = idx;
						LL_XPopup.preparedGallery.push(xp);
					}
				}
			}
			if(LL_XPopup.preparedGallery.length > 0) LL_XPopup.galleryOverall = LL_XPopup.preparedGallery.length;
		}
	}
	
	ImageXPopup.prototype.makeImage = function(src, attrs){
		var img = new Image();
		img.src = src;
		for (var k in attrs){
			if (k == 'class'){
				img.className = attrs[k];
			}else{
				img[k] = attrs[k];
			}
		}
		return img;
	}
	
	ImageXPopup.prototype.resizeImgOnOverflow = function(img, maxHeight, maxWidth){
		var h = img.height;
		var w = img.width;
		var ah = maxHeight;
		var aw = maxWidth;
		if (ah && aw){
			if (h > ah){
				w = Math.floor(w * ah / h);
				h = ah;
			}
			if (w > aw){
				h = Math.floor(h * aw / w);
				w = aw;
			}
			img.height = h;
			img.width = w;
		}
		return img;
	}
	
	ImageXPopup.prototype.makeImageTitleIfAny = function(){
		var t = this.getSrcImageTitle();
		if (t){
			return $('<div>').append(
				$('<span>' + t + '</span>')
			).attr(
				{'id': 'xpopupImgTitle', 'class': 'xpopupImgTitle'}
			).get(0);
		}
		return null;
	}
	
	ImageXPopup.prototype.activateHud = function(e){
		if (! this.appearingHud){
			this.appearingHud = 1;
			var self = this;
			$('#xpopupHoverMenuOuter').fadeIn('fast', function(){self.appearingHud = null});
		}
	}
	
	ImageXPopup.prototype.deactivateHud = function(e){
		$('#xpopupHoverMenuOuter').fadeOut('slow');
	}

	ImageXPopup.prototype.makeHudAndPrepareGallery = function(){
		var self = this;
		$(LL_XPopup.popup).bind('mousemove.specials', function(e){self.activateHud(e)});
		$(LL_XPopup.popup).bind('mouseleave.specials', function(e){self.deactivateHud(e)});
		this.prepareGalleryByGroup();
		var hm = $('<div>').append(
			$('<div>').append(
				$('<div>').append(
					this.getPlayPauseButton(),
					this.getPreviousButton(),
					this.getNextButton(),
					this.getThumbsButton(),
					this.getCloseButton()
				).attr(
					{'id': 'xpopupHoverMenu'}
				)
			).attr(
				{'id': 'xpopupHoverMenuPos'}
			)
		).attr(
			{'id': 'xpopupHoverMenuOuter'}
		).get(0);
		return hm;
	}
	
	ImageXPopup.prototype.buttonsStateController = function(){
		var buttons = [
			'xpopupHoverMenuPlayPauseButton',
			'xpopupHoverMenuPreviousButton',
			'xpopupHoverMenuNextButton',
			'xpopupHoverMenuThumbsButton',
			'xpopupHoverMenuCloseButton'
		];
	
		if (LL_XPopup.galleryOverall > 1){
			this.updateButton(buttons[0], 'act');
			if (LL_XPopup.slideshowBusy){
				this.updateButton(buttons[0], 'act', 'pauseButton');
			}
			this.updateButton(buttons[3], 'act'); // Thumb not connected now.
		}else{
			this.updateButton(buttons[0], 'pass');
			this.updateButton(buttons[3], 'pass');
		}

		if (LL_XPopup.galleryOverall > 1 && LL_XPopup.currentGalleryIdx > 0){
			this.updateButton(buttons[1], 'act');
		}else{
			this.updateButton(buttons[1], 'pass');
		}
		
		if (LL_XPopup.galleryOverall > 1 && LL_XPopup.currentGalleryIdx < LL_XPopup.preparedGallery.length - 1){
			this.updateButton(buttons[2], 'act');
		}else{
			this.updateButton(buttons[2], 'pass');
		}
		this.updateButton(buttons[4], 'act');
	}
	
	ImageXPopup.prototype.getPlayPauseButton = function(){
		var self = this;
		return $('<div>').attr(
			{'class': 'playButton_pass', 'id': 'xpopupHoverMenuPlayPauseButton'}
		).click(
			function(e){self.handleSlideshow(e)}
		).get(0);
	}
	
	ImageXPopup.prototype.getPreviousButton = function(){
		var self = this;
		return $('<div>').attr(
			{'class': 'previousButton_pass', 'id': 'xpopupHoverMenuPreviousButton'}
		).click(
			function(e){self.changeImage(-1, 'pager', e)}
		).get(0);
	}
	
	ImageXPopup.prototype.getNextButton = function(){
		var self = this;
		return $('<div>').attr(
			{'class': 'nextButton_pass', 'id': 'xpopupHoverMenuNextButton'}
		).click(
			function(e){self.changeImage(1, 'pager', e)}
		).get(0);
	}

	ImageXPopup.prototype.getThumbsButton = function(){
		var self = this;
		return $('<div>').attr(
			{'class': 'thumbsButton_pass', 'id': 'xpopupHoverMenuThumbsButton'}
		).click(
			function(e){self.handleGalleryOverview(e)}
		).get(0);
	}

	ImageXPopup.prototype.getCloseButton = function(){
		return $('<div>').attr(
			{'class': 'closeButton_pass', 'id': 'xpopupHoverMenuCloseButton'}
		).click(
			function(e){LL_XPopup.destruct(e)}
		).get(0);
	}

	ImageXPopup.prototype.updateButton = function(id, state, cnPrefix){
		var button = $('#' + id);
		if (arguments.length < 3){
			var cn = button.attr('class');
			cnPrefix = cn.substring(0, cn.lastIndexOf('_'));
		}
		button.attr({'class': cnPrefix + '_' + state});
	}
	
	ImageXPopup.prototype.isButtonActive = function(e, className){
		var cn = e.target.className;
		if (className) cn = className;
		var state = cn.substring(cn.lastIndexOf('_') + 1, cn.length).toLowerCase();
		if (state == 'act') return true;
		return false;
	}

	ImageXPopup.prototype.makeAddOns = function(e){
		var aos = $('#xpopupAddOns');
		aos.empty();
		aos.append(this.makeHudAndPrepareGallery());
		$('#xpopupHoverMenu').css({'left': (this.image.width / 2 - 132) + 'px'});
		var title = this.makeImageTitleIfAny();
		aos.append(title);
		this.buttonsStateController();
	}
	
	ImageXPopup.prototype.changeImage = function(idx, modeStr, e){
		if (LL_XPopup.slideshowBusy > 0){
			if (e && this.isButtonActive(e) && modeStr == 'pager'){
				var idx = LL_XPopup.currentGalleryIdx += idx;
				var xpopup = LL_XPopup.preparedGallery[idx];
				xpopup.show();
			}else if (modeStr == 'slideshow'){
				var idx = LL_XPopup.currentGalleryIdx += idx;
				if (idx == LL_XPopup.preparedGallery.length) idx = LL_XPopup.currentGalleryIdx = 0;
				var xpopup = LL_XPopup.preparedGallery[idx];
				var self = this;
				$('#xpopup').fadeOut(
					'fast',
					function(){
						xpopup.pushContentIntoPopup();
						xpopup.makeAddOns();
						setTimeout(
							function(){
								var mousePos = {'x': 0, 'y': 0};
								xpopup.setPopupPosition(xpopup.src, mousePos);
								$('#xpopup').fadeIn();
							},
							500
						);
					}
				);
			}
			if (LL_XPopup.slideshowInterval) clearTimeout(LL_XPopup.slideshowInterval);
			var self = this;
			LL_XPopup.slideshowInterval = setTimeout(function(){self.changeImage(1, 'slideshow')}, 7000);
		}else{
			if (e && this.isButtonActive(e) && modeStr == 'pager'){
				var idx = LL_XPopup.currentGalleryIdx += idx;
				var xpopup = LL_XPopup.preparedGallery[idx];
				xpopup.show();
			}else if(modeStr == 'gallery'){
				var idx = LL_XPopup.currentGalleryIdx = idx;
				var xpopup = LL_XPopup.preparedGallery[idx];
				xpopup.show();
			}
		}
	}
	
	ImageXPopup.prototype.getContent = function(){
		var img = null;
		var href, jsFunc;
		if (this.Attrs){
			var Attrs = this.Attrs;
			img = this.resizeImgOnOverflow(this.image, this.getAttr('height'), this.getAttr('width'));
			height = Attrs.height ? Attrs.height + 'px' : img.height + 'px' ;
			width = Attrs.width ? Attrs.width + 'px' : img.width + 'px';
			if (Attrs.href && ! Attrs.jsFunc){
				href = Attrs.href;
				img = $('<a>').append(img).attr({'href': Attrs.href}, img);
			}
			if (Attrs.jsFunc){
				$(img).css({'cursor': 'pointer'}).click(Attrs.jsFunc)
			}
			if (this.Attrs.background){
				if (this.Attrs.background.toLowerCase() == 'true' || this.Attrs.background == 1) this.makeBackground();
			}
		}
		this.setPopupWidth(width);
		return $('<div>').append(img).css({'height': height, 'width': width, 'overflow': 'auto', 'text-align': 'center'})
	}
	
	ImageXPopup.prototype.changeSlideshowPopupCSS = function(){
		if (LL_XPopup.slideshowBusy){
			var xPopupClass = 'xpopup_slideshow';
			var xPopupTitleClass = 'xpopupImgTitle_slideshow';
			if (! this.isIE() && this.isFixedPosition()) xPopupClass = 'xpopup_slideshow_fixed';
		}else{
			var xPopupClass = 'xpopup';
			var xPopupTitleClass = 'xpopupImgTitle';
			if (! this.isIE() && this.isFixedPosition()) xPopupClass = 'xpopup_fixed';
		}
		$('#xpopup').attr({'class': xPopupClass});
		if($('#xpopupImgTitle').size() > 0) $('#xpopupImgTitle').attr({'class': xPopupTitleClass});
	}

	ImageXPopup.prototype.hideBodyScrollbars = function(){
		$('body').css({'overflow': 'hidden'});
	}
	
	ImageXPopup.prototype.handleSlideshow = function(e){
		if (this.isButtonActive(e)){
			if (LL_XPopup.slideshowBusy){
				var buttonClass = 'playButton';
				LL_XPopup.slideshowBusy = 0;
				clearTimeout(LL_XPopup.slideshowInterval);
			}else{
				var buttonClass = 'pauseButton';
				LL_XPopup.slideshowBusy = 1;
				var self = this;
				LL_XPopup.slideshowInterval = setTimeout(function(){self.changeImage(1, 'slideshow')}, 7000);
			}
			this.updateButton('xpopupHoverMenuPlayPauseButton', 'act', buttonClass);
		}
	}
	
	ImageXPopup.prototype.handleGalleryImgClick = function(idx, e){
		e.preventDefault();
		e.stopPropagation();
		var self = this;
		$('#xpopupGalleryOverview').fadeOut('fast', function(){$('#xpopupGalleryOverview').remove()});
		this.changeImage(idx, 'gallery');
	}
	
	ImageXPopup.prototype.handleGalleryOverview = function(e){
		if (LL_XPopup.slideshowBusy) this.handleSlideshow({'target': $('#xpopupHoverMenuPlayPauseButton').get(0)});
		$('#xpopup').hide();
		var images = this.getOverviewImagesWithDeco();
		var vpDims = {'w': $(window).width(), 'h': $(window).height()};
		var vpPos = {'x': $(document).scrollLeft(), 'y': $(document).scrollTop()}
		var px = null;
		var py = null;
		var h = vpDims.h;
		var w = vpDims.w;
		var position = 'fixed';
		if (this.isIE()){
			px = vpPos.x;
			py = vpPos.y;
			var position = 'absolute';
		}
		var container = $('<div>').attr(
			{'id': 'xpopupGalleryOverview', 'class': 'xpopupGalleryOverview'}
		).css(
		{'height': '100%', 'width': '100%', 'position': position, 'left': px, 'top': py}
		).click(
			function(e){LL_XPopup.destruct(e)}
		);
		for (var i = 0; i < images.length; ++i){
			container.append(images[i]);
		}
		$('body').append(container);
		$('#xpopupGalleryOverview').fadeIn('fast');
	}

	ImageXPopup.prototype.getOverviewImagesWithDeco = function(){
		var pg = LL_XPopup.preparedGallery;
		var images = [];
		var mw= 135;
		var mh = 90;
		for (var i = 0; i < pg.length; ++i){
			function x(self, idx){
				var srcImg = pg[idx].getSrcImage();
				var paddingTop = '0';
				if (srcImg.height < mh) paddingTop = parseInt((mh - srcImg.height) / 2) + 'px';
				var img = self.makeImage(srcImg.src, {'width': srcImg.width, 'height': srcImg.height, 'border': 0, 'alt': srcImg.alt, 'title': srcImg.title});
				var img = self.resizeImgOnOverflow(img, mh, mw);
				var imgWrapped = $('<span></span>').append(img).css({'padding-top': paddingTop});
				images.push(
					$('<div>').append(
						$('<a></a>').append(
							$('<span></span>').append(imgWrapped).attr({'class': 'image'})
						).attr({'class': 'inner1', 'href': '#'})
					).attr({'class': 'xpopupGalleryImageDeco'}).click(
						function(e){self.handleGalleryImgClick(idx, e)}
					).get(0)
				);
				return images;
			}
			images = x(this, i);
		}
		return images;
	}


	// Webpage xpopup
	WebpageXPopup = function(src, event, spos, ppos, margin_w, margin_h, TypeAttrs){
		/* TypeAttrs: url, href, jsFunc, height, width, background
		 * url: Source of the image to display.
		 * height: Popup height.
		 * width: Popup width.
		 * background: The xpopup stay on a dark background
		 * fixedPosition: The popup is position fixed and has no response on scroll events.
		 */
		this.constructor(src, event, spos, ppos, margin_w, margin_h, TypeAttrs);
	}
	WebpageXPopup.prototype = new DefaultXPopup();

	WebpageXPopup.prototype.getContent = function(){
		this.setPopupWidth();
		var height = parseInt($(window).height() / 1.5);
		var width = parseInt($(window).width() / 1.5);
		var url = 'http://www.example.com';
		if (this.Attrs){
			height = this.Attrs.height == 'auto'? height : this.Attrs.height;
			width = this.Attrs.width == 'auto'? width : this.Attrs.width;
			url = this.Attrs.url ? this.Attrs.url : url;
			if (this.Attrs.background){
				if (this.Attrs.background.toLowerCase() == 'true' || this.Attrs.background == 1) this.makeBackground();
			}
		}
		return $('<iframe>').attr({'src': url, 'frameborder': 0, 'height': height, 'width': width}).get(0);
	}

	// Ajax xpopup
	AjaxXPopup = function(src, event, spos, ppos, margin_w, margin_h, TypeAttrs){
		/* TypeAttrs: url, href, jsFunc, height, width, background
		 * url: Source of the image to display.
		 * height: Popup height.
		 * width: Popup width.
		 * background: The popup stay on a dark background
		 * fixedPosition: The popup is position fixed and has no response on scroll events.
		 */
		this.constructor(src, event, spos, ppos, margin_w, margin_h, TypeAttrs);
		this.def = null;
	}
	AjaxXPopup.prototype = new DefaultXPopup();

	AjaxXPopup.prototype.getContent = function(){
		this.setPopupWidth();
		var height = parseInt($(window).height() / 3);
		var width = parseInt($(window).width() / 2);
		var url = '/';
		if (this.Attrs){
			height = this.Attrs.height == 'auto'? height : this.Attrs.height + 'px';
			width = this.Attrs.width == 'auto'? width : this.Attrs.width + 'px';
			url = this.Attrs.url ? this.Attrs.url : url;
			if (this.Attrs.background){
				if (this.Attrs.background.toLowerCase() == 'true' || this.Attrs.background == 1) this.makeBackground();
			}
		}
		var container = $('<div>').css({ 'height': height, 'width': width, 'overflow': 'auto'}).load(url);
		return container.get(0);
	}
	
	AjaxXPopup.prototype.loadContent = function(container, def){
		container.innerHTML = def.responseText;
	}

	AjaxXPopup.prototype.loadContentError = function(def){
		console.log('Fehler beim Abruf von AJAX content:', def.message);
	}
/* << */


