// JS function for uncrypting spam-protected emails:
function UnCryptMailto(s) {
	var n=0;
	var r="";
	for(var i=0; i < s.length; i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(1));
	}
	return r;
}
// JS function for uncrypting spam-protected emails:
function linkTo_UnCryptMailto(s) {
	location.href=UnCryptMailto(s);
}

function goto(obj) {
	if (obj.selectedIndex > 0) {
		document.location.href="index.php?id="+obj[obj.selectedIndex].value;
	}
}

function swapImage(id, img) {
	$(id).src = 'fileadmin/template/images/'+img;
}

function setFontSize(value) {
	$('body').style.fontSize = (value*1)+'px';
	$('body').style.lineHeight = (value*1+6)+'px';
	createCookie("set_fontsize", value*1, 365);
}

function loadAccordions() {
	var myAccordion = new accordion('accordion', {
		classNames : {
			toggle : 'accordion_toggle',
			toggleActive : 'accordion_toggle_active',
			content : 'accordion_content'
		},
		direction : 'vertical',
		onEvent : 'mouseover'
	});
}

var lastTeaser = 0;
var thumb = new Array();
var thumb_on = new Array();
var autoScrollForward = null;
function showTeaser(nr, scroll, type) {
	if (lastTeaser != nr) {
		if (scroll)
			EvC.scrollToIndex(nr);
		if (thumb_on[nr] != '') {
			$('thumb-'+nr).className += " active";
			$('thumb-src-'+nr).src = thumb_on[nr];
			clearTimeout(autoScrollForward);
			autoScrollForward = setTimeout('EvC.scrollForward()', 10000);
		}
//		if (lastTeaser > 0) {
			if (scroll) {
				$('btnPrev').style.display = 'none';
				$('btnNext').style.display = 'none';
			}
			if (thumb[lastTeaser] != '') {
				$('thumb-'+lastTeaser).className = $('thumb-'+lastTeaser).className.replace(" active", "");
				$('thumb-src-'+lastTeaser).src = thumb[lastTeaser];
			}
//		}
		lastTeaser = nr;
	}
}
function toggleTeaserThumb(nr, type) {
	if (lastTeaser != nr) {
		if (type == 'on') {
			$('thumb-src-'+nr).src = thumb_on[nr];
		} else {
			$('thumb-src-'+nr).src = thumb[nr];
		}
	}
}

var CarouselItem = Class.create({
	initialize: function() {
		this.index = null;
		this.element = null;
	},
	setIndex: function(index) {
		this.index = index;
	},
	getIndex: function() {
		return this.index;
	},
	setElement: function(element) {
		this.element = element;
	},
	getElement: function() {
		return this.element;
	}
});

var Carousel = Class.create({
	initialize: function(key, carouselElement, itemWidth, itemHeight, options) {
		this.key = key;
		this.observer = this;
		this.items = $A([]);
		this.activeItem = null;
		this.activeIndex = 0;
		this.navScrollIndex = 0;

		this.duration = 1.0;
		if (options.duration) this.duration = options.duration;
	   
		this.options = options;       
		
		this.direction = 'horizontal';
		if (options.direction) this.direction = options.direction;
		
		this.itemHeight = itemHeight;
		this.itemWidth = itemWidth;
		this.moveOpacity = .6;
	   
		this.setSize = 4;
		if (options.setSize) this.setSize = options.setSize;
		
		// init carousel element
		this.carouselElement = $(carouselElement);
		if (!this.carouselElement) { alert('Warning: Invalid carousel element: ' + carouselElement); return; }
		
		// init first element
		this.itemsElement = this.carouselElement.down('.teasers');
		if (!this.itemsElement) { alert('Warning: Class \'teasers\' does not exist as a child element in carousel: ' + carouselElement); return; }
		
		// init navigation buttons
		this.backElement = this.carouselElement.down('.navButton.previous');
		this.forwardElement = this.carouselElement.down('.navButton.next');
	   
		// register button events
		this.backElement.observe('click', function() {
			this.scrollBack();
		}.bind(this));
		this.backElement.observe('mouseover', function() {
			clearTimeout(autoScrollForward);
		}.bind(this));
		this.backElement.observe('mouseout', function() {
			autoScrollForward = setTimeout('EvC.scrollForward()', 10000);
		}.bind(this));
		this.forwardElement.observe('click', function() {
			this.scrollForward();
		}.bind(this));
		this.forwardElement.observe('mouseover', function() {
			clearTimeout(autoScrollForward);
		}.bind(this));
		this.forwardElement.observe('mouseout', function() {
			autoScrollForward = setTimeout('EvC.scrollForward()', 10000);
		}.bind(this));
	},	
	load: function() {
		// empty the items array (e.g. if load is called twice)
		this.items.clear();
		
		var eList = this.itemsElement;
		// iterate over all teasers
		eList.select('.teaser').each(function(item) {      
			var oCarouselItem = new CarouselItem();
			oCarouselItem.setIndex(this.items.size());
			oCarouselItem.setElement(item);
			this.items.push(oCarouselItem);
			
			//Store default selection
			if (item.hasClassName('selected')) {
				this.activeItem = oCarouselItem;
				this.activeIndex = this.items.size() - 1;
			}

			if (this.options.setItemEvents) this.options.setItemEvents(this, item, oCarouselItem, this.observer);            
		}.bind(this));
		
		//Post processing        
		this.afterLoad();
	},
	afterLoad: function() {
		if (this.items.size() == 0) {
			console.log('Warning: No Carousel Items Exist');
			return;
		}
		
		//Change the following line to moveToIndex if you do 
		//not want the load animation on default selected items
		//this.moveToIndex(this.activeIndex);        
		this.scrollToIndex(this.activeIndex);        

		if (this.activeItem) this.activate(this.activeItem);
		if (this.observer.fireActiveCarouselLoaded) this.observer.fireActiveCarouselLoaded(this);
	},
	scrollForward: function() {    
		//setsize-1 at a time scrolling 
		//if (this.navScrollIndex > this.items.size() - (this.setSize + 1)) return;
		var iIndex = this.navScrollIndex + (this.setSize - 1);
		if (this.navScrollIndex > this.items.size() - this.setSize)
			iIndex = 0;
		this.scrollToIndex(iIndex);
		this.activeIndex = iIndex;
		showTeaser(iIndex);
	},
	scrollBack: function() {
		var iIndex = this.navScrollIndex - (this.setSize - 1);
		//if(iIndex < 0) iIndex  = 0;
		if(iIndex < 0)
			iIndex  = this.items.size() - (this.setSize + 1);
		this.scrollToIndex(iIndex);
		this.activeIndex = iIndex;
		showTeaser(iIndex);
	},
	getLeft: function(index) {
		return index * (-this.itemWidth);
	},
	getTop: function(index) {
		return index * (-this.itemHeight);
	},
	activate: function(carouselItem) {
		if (this.activeItem) this.observer.fireDeactiveCarouselItem(this, this.activeItem.element, this.activeItem);
		if (carouselItem == null) return; 
		this.activeItem = carouselItem;
		if (this.observer.fireActiveCarouselItem) this.observer.fireActiveCarouselItem(this, carouselItem.element, carouselItem);
	},
	next: function() {	
		if (this.activeItem == null) { this.activate(this.items[0]); return; }
		var iIndex = this.activeItem.index + 1;
		if (iIndex >= this.items.size()) iIndex = 0;
		this.activate(this.items[iIndex]);
		this.activeIndex = iIndex;
	},
	previous: function() {
		if (this.activeItem == null) { this.activate(this.items[0]); return; }
		var iIndex = this.activeItem.index - 1;
		if (iIndex < 0) iIndex = 0;
		this.activate(this.items[iIndex]);
		this.activeIndex = iIndex;
	},
	scrollToIndex: function(index) {        
		if (this.direction == 'vertical') {
			var iPreviousTop = this.getTop(this.navScrollIndex);
			var iTop = this.getTop(index);
			var iCurrentTop = parseInt(Element.getStyle(this.itemsElement, 'top')) || 0;
			var offset = iPreviousTop-iCurrentTop;
			var move = iTop - iPreviousTop;
			if (move > 0) {
				move = move + offset;
			} else {
				move = move - offset;
			}
			//Element.setOpacity(this.itemsElement, this.moveOpacity);
			var ef = new Effect.Move(this.itemsElement, {
				'duration': this.duration,
				'y': move, 
				'afterFinish': function() { 
					Element.setStyle(this.itemsElement, {'top': iTop + 'px'});
					//Element.setOpacity(this.itemsElement, 1.0);
				}.bind(this)
			});
			ef = null;
		} else {
			var iPreviousLeft = this.getLeft(this.navScrollIndex);
			var iLeft = this.getLeft(index);
			var iCurrentLeft = parseInt(Element.getStyle(this.itemsElement, 'left')) || 0;
			var offset = iPreviousLeft - iCurrentLeft;
			var move = iLeft - iCurrentLeft;
			if (move > 0) {
				move = move + offset;
			} else {
				move = move - offset;
			}
			//Element.setOpacity(this.itemsElement, this.moveOpacity);
			var ef = new Effect.Move(this.itemsElement, {
				'duration': this.duration,
				'x': move, 
				'afterFinish': function() { 
					Element.setStyle(this.itemsElement, {'left': iLeft + 'px'});
					//Element.setOpacity(this.itemsElement, 1.0);
				}.bind(this)
			});
			ef = null;
		}
		this.navScrollIndex = index;
		/*if (this.navScrollIndex <= this.items.size() - (this.setSize + 1)) {
			this.forwardElement.show();
		} else {
			this.forwardElement.hide();
		}
		if ((parseInt(this.navScrollIndex) || 0) != 0) {
			this.backElement.show();
		} else {
			this.backElement.hide();
		}*/
		if(this.observer.fireCarouselAtIndex) this.observer.fireCarouselAtIndex(this, index);
	},
	moveToIndex: function(index) {
		if (this.direction == 'vertical') {
			var iTop = this.getTop(index);
			Element.setStyle(this.itemsElement, {'top': iTop + 'px'});
			//Element.setOpacity(this.itemsElement, 1.0);
		} else {
			var iLeft = this.getLeft(index);
			Element.setStyle(this.itemsElement, {'left': iLeft + 'px'});
			//Element.setOpacity(this.itemsElement, 1.0);
		}

		this.navScrollIndex = index;
		if (this.navScrollIndex <= this.items.size() - (this.setSize + 1)) {
			this.forwardElement.show();
		} else {
			this.forwardElement.hide();
		}
		if ((parseInt(this.navScrollIndex) || 0) != 0) {
			this.backElement.show();
		} else {
			this.backElement.hide();
		}
	},
	fireDeactiveCarouselItem: function(carousel, element, item) {
		element.removeClassName('selected');		
	},
	fireActiveCarouselItem: function(carousel, element, item) {
		element.addClassName('selected');
	},
	fireActiveCarouselLoaded: function(carousel) {
	}
});
	
/*var lastEvent = 0;
function showEventInfo(id) {
	if (lastEvent != id) {
		if (($('event-info-'+id).offsetHeight + 47 + 5) > 227) {
			$('event-'+id).style.height = ($('event-info-'+id).offsetHeight + 47 + 5)+'px';
		} else {
			$('event-'+id).style.height = '227px';
		}
		$('event-text-'+id).style.borderTop = '2px solid #FF9900';
		if (lastEvent > 0) {
			hideEventInfo(lastEvent);
		}
	}
	lastEvent = id;
}
function hideEventInfo(id) {
	$('event-'+id).style.height = '47px';
	$('event-text-'+id).style.borderTop = '1px solid #999';
}*/

var lastItem = 0;
var activeItems = new Array();
var itemHeight = new Array();
function highlightItem(id, color, no_image) {
	//if (lastItem != id) {
	if (activeItems[id] != 1) {
		if (!no_image) {
			$('item-image-'+id).style.display = 'block';
		}
		$('item-text-'+id).style.paddingTop = '4px';
		$('item-text-'+id).style.borderTop = '2px solid '+color;
	}
		/*if (lastItem > 0 &&
			activeItems[lastItem] != 1) {
			$('item-image-'+lastItem).style.display = 'none';
			$('item-text-'+lastItem).style.paddingTop = '5px';
			$('item-text-'+lastItem).style.borderTop = '1px solid #999';
		}*/
	/*}
	lastItem = id;*/
}
function resetItem(id, no_image) {
	if (activeItems[id] != 1) {
		if (!no_image) {
			$('item-image-'+id).style.display = 'none';
		}
		$('item-text-'+id).style.paddingTop = '5px';
		$('item-text-'+id).style.borderTop = '1px solid #999';
	}
}
function toggleItem(id, color, no_image, defaultHeight) {
	if (activeItems[id] == 1) {
//	if ($('item-'+id).offsetHeight > 47) {
//		$('item-'+id).style.height = '47px';
		if (defaultHeight*1 > 0) {
			$('item-'+id).style.height = (defaultHeight*1)+'px';
		} else {
			$('item-'+id).style.height = itemHeight[id]+'px';
		}
		/*if (!no_image) {
			$('item-image-'+id).style.display = 'none';
		}*/
		activeItems[id] = 0;
	} else {
		itemHeight[id] = $('item-toggle-'+id).offsetHeight;
//		if (($('item-info-'+id).offsetHeight + 47 + 20) > 247) {
//			$('item-'+id).style.height = ($('item-info-'+id).offsetHeight + 47 + 20)+'px';
		if (!no_image) {
			if (($('item-info-'+id).offsetHeight + itemHeight[id] + 20) > ($('item-image-'+id).offsetHeight + 20)) {
				$('item-'+id).style.height = ($('item-info-'+id).offsetHeight + itemHeight[id] + 20)+'px';
			} else {
				$('item-'+id).style.height = ($('item-image-'+id).offsetHeight + 20)+'px';
			}
		} else {
			$('item-'+id).style.height = ($('item-info-'+id).offsetHeight + itemHeight[id] + 20)+'px';
		}
		$('item-text-'+id).style.paddingTop = '4px';
		$('item-text-'+id).style.borderTop = '2px solid '+color;
//		$('item-image-'+id).style.display = 'block';
		activeItems[id] = 1;
	}
}
function setMinHeightItem(id, height) {
	if ($('item-toggle-'+id).offsetHeight > height) {
		$('item-'+id).style.height = $('item-toggle-'+id).offsetHeight+'px';
	} else {
		$('item-'+id).style.height = height+'px';
	}
}


/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};

function openAllItems(color, no_image) {
	$A(getElementsByClassName('accordion_item', 'div')).each(function(obj) {
		id = obj.id.split("-");
		if (!activeItems[id[1]]) {
			highlightItem(id[1], color, no_image);
			toggleItem(id[1], color);
		}
	});
}
function closeAllItems(color, no_image, defaultHeight) {
	$A(document.getElementsByClassName('accordion_item')).each(function(obj) {
		id = obj.id.split("-");
		if (activeItems[id[1]]) {
			toggleItem(id[1], color, no_image, defaultHeight);
			resetItem(id[1], no_image);
		}
	});
}

var action = new Array;
function showAction(id) {
	action[id] = 0;
	$('action-'+id).style.display = 'block';
}
function hideAction(id) {
	action[id] = 1;
	//setTimeout('hA('+id+')', 1000);
	$('action-'+id).style.display = 'none';
}
function hA(id) {
	if (action[id] == 1) {
		$('action-'+id).style.display = 'none';
	}
}

function myOver(id) {
	obj = $(id);
	over(obj.childNodes[0].getAttribute('name'));
}

function myOut(id) {
	obj = $(id);
	out(obj.childNodes[0].getAttribute('name'));
}

var closeLayer = '0';
var showNavMain = '0';
var layer = 1;
function closeMenuLayer() {
	layer = 1;
	setTimeout('cML()', 1000);
}
function cML() {
	if (closeLayer == '1' &&
		layer == 1) {
		$('nav-layer').style.display = 'none';
		if (navMain > 0) {
			$('nav-main-'+navMain).style.display = 'block';
		}
	}
}
function showMenuLayer(id) {
	$('nav-layer').style.display = 'block';
	$('nav-main-'+id).style.display = 'none';
	navMain = id;
}

function getPositionLeft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x) curleft += obj.x;
	return curleft;
}

function getPositionTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) curtop += obj.y;
	return curtop;
}


var textFieldFocus = false;
var loginContainerActive = false;
var quicklinksContainerActive = false;
var displayContainerActive = false;
var loginContainerSema = false;
var quicklinksContainerSema = false;
var displayContainerSema = false;
var timer_monitor_lb = false;
var timer_monitor_ql = false;
var timer_monitor_dp = false;

Event.observe(window, 'load', function() {

	/* LOGIN */
	if ($('loginBoxInvoker') != null && $('loginFormContainer') != null && $('loginbox') != null) {
		$('loginBoxInvoker').observe('mouseover', function(event){
			var element = event.element();
			if (event.preventDefault) 
				event.preventDefault();
			
			if (typeof console != 'undefined') 
				console.log('Show login box');
			
			if ($('display') != null) {
				displayContainerActive = false;
				displayContainerSema = false;
				$('display').style.display = 'none';
			}
			
			if ($('quicklinks') != null) {
				quicklinksContainerActive = false;
				quicklinksContainerSema = false;
				$('quicklinks').style.display = 'none';
			}
			
			$('loginbox').style.display = 'block';
			loginContainerActive = true;
			
			if (!timer_monitor_lb)	{
				timer_monitor_lb = true;
				var lb = function() {
					if (!loginContainerSema) {				
						$('loginbox').style.display = 'none';
						loginContainerActive = false;
						if (typeof console != 'undefined') 
							console.log('Login box NOT activated in predetermined time... Close login box...');
					} else {
						if (typeof console != 'undefined') 
							console.log('Login box activated in predetermined time');
					}
					timer_monitor_lb = false;
				}.delay(2);
			}
			
			return false;
		});
		
		if ($('loginUser') != null && $('loginPass') != null) {
			[$('loginUser'), $('loginPass')].each(function(obj){
				obj.observe('click', function(event){
					var element = event.element();
					if (event.preventDefault) 
						event.preventDefault();
					
					textFieldFocus = true;
				});
				
				obj.observe('blur', function(event){
					var element = event.element();
					if (event.preventDefault) 
						event.preventDefault();
					
					textFieldFocus = false;
				});
			});
		}
		
		$('loginbox').observe('mouseover', function(event){
			if (typeof console != 'undefined') 
				console.log('Login box mouseover');			
			loginContainerActive = true;
			loginContainerSema = true;
		});
		
		$('loginbox').observe('mouseout', function(event){
			if (typeof console != 'undefined') 
				console.log('Login box mouseout');				
				
			if (!loginContainerActive || textFieldFocus) 
				return;
			
			var posTop = getPositionTop($('loginbox')) + 2;
			var posBottom = getPositionTop($('loginbox')) + $('loginbox').offsetHeight - 2;
			var posLeft = getPositionLeft($('loginbox')) + 2;
			var posRight = getPositionLeft($('loginbox')) + $('loginbox').offsetWidth - 2;
			var mouseX = Event.pointerX(event);
			var mouseY = Event.pointerY(event);
			
			if (!(mouseX >= posLeft && mouseX <= posRight &&
				  mouseY >= posTop  && mouseY <= posBottom)) {
				if (typeof console != 'undefined') 
					console.log('Mouse out of login box... Close quicklinks login box...');
			
				loginContainerActive = false;
				loginContainerSema = false;
				$('loginbox').style.display = 'none';
			}
		});
	}

	/* QUICKLINKS */
	
	if ($('quicklinksInvoker') != null && $('quicklinksContainer') != null && $('quicklinks') != null) {
		$('quicklinksInvoker').observe('mouseover', function(event){
			var element = event.element();
			if (event.preventDefault) 
				event.preventDefault();
			
			if (typeof console != 'undefined') 
				console.log('Show quicklinks box...');
			
			if ($('loginbox') != null) {
				loginContainerActive = false;
				loginContainerSema = false;
				$('loginbox').style.display = 'none';
			}
			
			if ($('display') != null) {
				displayContainerActive = false;
				displayContainerSema = false;
				$('display').style.display = 'none';
			}
			
			$('quicklinks').style.display = 'block';
			quicklinksContainerActive = true;			
			
			if (!timer_monitor_ql)	{
				timer_monitor_ql = true;
				var ql = function() {
					if (!quicklinksContainerSema) {				
						$('quicklinks').style.display = 'none';
						quicklinksContainerActive = false;
						if (typeof console != 'undefined') 
							console.log('Quicklinks box NOT activated in predetermined time... Close quicklinks box...');
					} else {
						if (typeof console != 'undefined') 
							console.log('Quicklinks box activated in predetermined time');
					}
					timer_monitor_ql = false;
				}.delay(2);
			}
			
			return false;
		});
		
		$('quicklinks').observe('mouseover', function(event){
			if (typeof console != 'undefined') 
				console.log('Quicklinks box mouseover');
				
			quicklinksContainerActive = true;
			quicklinksContainerSema = true;
		});
		
		$('quicklinks').observe('mouseout', function(event){
			if (typeof console != 'undefined') 
				console.log('Quicklinks box mouseout');
				
			if (!quicklinksContainerActive) 
				return;
			
			var posTop = getPositionTop($('quicklinks')) + 2;
			var posBottom = getPositionTop($('quicklinks')) + $('quicklinks').offsetHeight - 2;
			var posLeft = getPositionLeft($('quicklinks')) + 2;
			var posRight = getPositionLeft($('quicklinks')) + $('quicklinks').offsetWidth - 2;
			var mouseX = Event.pointerX(event);
			var mouseY = Event.pointerY(event);
			
			if (!(mouseX >= posLeft && mouseX <= posRight &&
				  mouseY >= posTop  && mouseY <= posBottom)) {
				if (typeof console != 'undefined') 
					console.log('Mouse out of quicklinks box... Close quicklinks box...');
			
				quicklinksContainerActive = false;
				quicklinksContainerSema = false;
				$('quicklinks').style.display = 'none';
			}
		});
	}
	
	/* DISPLAY */

	if ($('displayInvoker') != null && $('displayContainer') != null && $('display') != null) {
		$('displayInvoker').observe('mouseover', function(event){
			var element = event.element();
			if (event.preventDefault) 
				event.preventDefault();
			
			if ($('loginbox') != null) {
				loginContainerActive = false;
				loginContainerSema = false;			
				$('loginbox').style.display = 'none';
			}
			
			if ($('quicklinks') != null) {
				quicklinksContainerActive = false;
				quicklinksContainerSema = false;
				$('quicklinks').style.display = 'none';
			}
			
			if (typeof console != 'undefined') 
				console.log('Show display box');
			
			$('display').style.display = 'block';
			displayContainerActive = true;
			
			if (!timer_monitor_dp)	{
				timer_monitor_dp = true;
				var dp = function() {
					if (!displayContainerSema) {
						$('display').style.display = 'none';
						displayContainerActive = false;
						if (typeof console != 'undefined') 
							console.log('Display box NOT activated in predetermined time... Close display box...');
					} else {
						if (typeof console != 'undefined') 
							console.log('Display box activated in predetermined time');
					}
					timer_monitor_dp = false;
				}.delay(2);
			}
			
			return false;
		});
		
		$('display').observe('mouseover', function(event){
			if (typeof console != 'undefined') 
				console.log('Display box mouseover');
			displayContainerActive = true;
			displayContainerSema = true;
		});
		
		$('display').observe('mouseout', function(event){
			if (typeof console != 'undefined') 
				console.log('Display box mouseout');
				
			if (!displayContainerActive) 
				return;
			
			var posTop = getPositionTop($('display')) + 2;
			var posBottom = getPositionTop($('display')) + $('display').offsetHeight - 2;
			var posLeft = getPositionLeft($('display')) + 2;
			var posRight = getPositionLeft($('display')) + $('display').offsetWidth - 2;
			var mouseX = Event.pointerX(event);
			var mouseY = Event.pointerY(event);
			
			/*console.log('-------------------------');
			console.log('X: ' + mouseX);
			console.log('Y: ' + mouseY);			
			console.log('Links: ' + posLeft);
			console.log('Rechts: ' + posRight);
			console.log('Oben: ' + posTop);
			console.log('Unten: ' + posBottom);*/	
			
			if (!(mouseX >= posLeft && mouseX <= posRight &&
				  mouseY >= posTop  && mouseY <= posBottom)) {
				if (typeof console != 'undefined') 
					console.log('Mouse out of display box... Close display box...');
			
				displayContainerActive = false;
				displayContainerSema = false;
				$('display').style.display = 'none';
			}
		});
	}
});