function hasClass(c,e) {
	var rx = new RegExp("(^|\\s)" + c + "(\\s|$)");
	return ( e.className && rx.test(e.className) );
	return false;
}

function findElements(c,e) {
	var rv = [];
	var rx = new RegExp("(^|\\s)" + c + "(\\s|$)");
	var ln = e.childNodes.length;
	for( var i = 0; i < ln; i++ ) {
		var cn = e.childNodes[i];
		if( cn.nodeType == 1 ) {
			if( cn.className && rx.test(cn.className) )
				rv[rv.length] = e.childNodes[i];
			rv = rv.concat(findElements(c,cn));
		}
	}
	return rv;
}

function getAllNodes(o) {
	var rv = [o];
	var ln = o.childNodes.length;
	for( var i = 0; i < ln; i++ ) {
		var cn = o.childNodes[i];
		if( cn.nodeType == 1 )
			rv.concat(getAllNodes(cn));
	}
	return rv;
}

function showhide(e,show) { 
	if( e ) e.style.display = show?'block':'none'; 
}

function init() {
	var stillover = false;
	var S = findElements('submenu',document.body);
	for( var s in S ) {
		var es = S[s];
		if( es.id.indexOf('_') < 0 ) continue;
		var id = es.id.substr(es.id.indexOf('_')+1,es.id.length);
		var em = document.getElementById('menuimg_'+id);
		var emp= em.parentNode;

		var classes = em.className.split(' ');
		var level = 0;
		for( var i = 0; i < classes.length; i++ ) if(classes[i].indexOf('level')==0)
			level = classes[i].substr(6,classes[i].length);
	}
	for( s in S ) S[s].style.display = 'none';

	var M = findElements('mainmenu',document.body);
	for( var m in M ) {
		var em = M[m];
		if( em.id.indexOf('_') >= 0 ) (function() {
			var oov = em.onmouseover;
			var oot = em.onmouseout;

			em.onmouseover = function() {
				// show Submenu
				var id = this.id.substr(this.id.indexOf('_')+1,this.id.length);
				this.dohide = true;
				this.isover = true;
	
				var el = document.getElementById('subMenuContainer_'+id);
				showhide(el,true);
				var fs = document.getElementById('Fallschirm');
				showhide(fs,true);
		
				var p = this.parentNode
				var pid = p.id.substr(p.id.indexOf('_')+1,p.id.length);
				if(pid) {
					var pm = document.getElementById('menuimg_'+pid);
					if( pm ) pm.isover = true;
				}

				// keep submenu
				var self = this; 
				var C = getAllNodes(el);
				stillover = true;
				for( var elm in C ) {
					var e = C[elm];
					e.onmouseover = function() {
						self.dohide = false;
						stillover = true;
					}
					e.onmouseout = function() {
						var me = this;
						self.dohide = true;
						setTimeout(function() {
							self.onmouseout();
						},100);
					}
				}
				oov.apply(this,[]);
			}
			em.onmouseout = function() {
				// hide Sbmenu
				var id = this.id.substr(this.id.indexOf('_')+1,this.id.length);
				this.isover = false;

				var p = this.parentNode
				var pid = p.id.substr(p.id.indexOf('_')+1,p.id.length);
				if(pid) {
					var pm = document.getElementById('menuimg_'+pid);
					if( pm ) { pm.isover = false; }
				}

				var self = this;
				var e = document.getElementById('subMenuContainer_'+id);
				var fs = document.getElementById('Fallschirm');
				var p = this.parentNode;
				stillover = false;
				setTimeout(function() { 
					if(self.dohide) {
						showhide(e,false);
						if( !stillover ) showhide(fs,false);
					} if( hasClass('submenu',p) )
						p.onmouseout();
				}, 100);
				oot.apply(this,[]);
			}
		})();
	}
}

/*@cc_on
@if ( @_jscript )
	document.write('<script id="__ie_onload" defer src="javascript:void(0)"></script>');
	var script = document.getElementById('__ie_onload');
	script.onreadystatechange = function() {
	    if (this.readyState == 'complete') {
	        init();
	    }
	};
@else */

function mx(x,d){ 
	var a=arguments[2];
	var a2=arguments[3];
	if(!a)a=0;
	if(!a2)a2=a;
	return Math.max((x-d)/2+a,a2); 
}
function $(id){return document.getElementById(id);}
function l(o,n){return (o.style.left=n);}
function w(o,n){return (o.style.width=n);}
function t(o,n){return (o.style.top=n);}
function h(o,n){return (o.style.height=n);}

ap=new function(){
	this.h=0;
	this.w=0;

	this.a=function(ht,wt){
		var c=$('divContentBG');

		if(c){
			if(this.w!=wt){
				w(c,mx(wt,250));
				this.w = wt;
			}
			if(this.h!=ht){
				h(c,mx(ht,-220));
				this.h = ht;
			}
		}
       	}
}
window.onresize=function(){ap.a(window.innerHeight,window.innerWidth);}
function tmp(){
	ap.a(window.innerHeight,window.innerWidth);
	if(!$('divContentBG'))setTimeout(tmp,10);
	else init();
}
tmp();
function cn(p,i){return p.childNodes[i];}
function ec(p,c){for(var i=0;i<p.childNodes.length;i++)if(!c.call(cn(p,i),p))break;}
function spt(c){ec(this.parentNode.parentNode,function(p){
	if(this.nodeType==1){if(p.id.indexOf('Active')>=0)this.style.color=c;return false;}
	return true;
});}
/* @end
@*/

