function NavData(){
	this.length = 0;
	this.mnav = new Array();
	
	this.add = function (navid, title, path){
		if (!this.mnav[navid]){
			this.mnav[navid] = new Array(0, new Array(), new Array());
		}
		this.mnav[navid][1][this.mnav[navid][0]] = title;
		this.mnav[navid][2][this.mnav[navid][0]] = path;
		this.mnav[navid][0]++;		
	}
	
	this.getLength = function (navid){
		return this.mnav[navid] ? this.mnav[navid][0] : 0;
	}
	
	this.getTitle = function (navid, index){
		return this.mnav[navid][1][index] ? this.mnav[navid][1][index] : null;
	}
	this.getPath = function (navid, index){
		return this.mnav[navid][2][index] ? this.mnav[navid][2][index] : null;
	}
}

var navFloatActive 	= '';
var navFloat2Show 	= null;
var navFloatTimer 	= null;


Event.observe(window, 'load', function(){	
	for(i=1; i<10; i++){			
		if ($('mnav'+i) && navData){			
			if (navData.getLength(i)>0){			
				Event.observe('mnav'+i, 'mouseover', 	startNavFloatShowTimer);					
				Event.observe('mnav'+i, 'mouseout',  	startNavFloatTimer);
				Event.observe('mnav'+i, 'focus', 		showNavFloatNow);
				Event.observe('mnav'+i, 'blur',  		startNavFloatTimer);
			} else {
				Event.observe('mnav'+i, 'mouseover', 	closeNavFloat);									
				Event.observe('mnav'+i, 'focus', 		closeNavFloat);				
			}
		}
	}
	// deaktiviert, da nicht mehr benoetigt
	//Event.observe('search', 'focus', 		showSearchFilter);
});		


function showNavFloat(e){		
	if ( (navFloatActive.length>0) && (navFloatActive!=navFloat2Show) ){
		if ($('mnavr2-floater')){
			closeNavFloat();					
		}		
	}
	if ( (navFloatActive!=navFloat2Show) && (navData) && (navData.getLength(navFloat2Show)>0) ){							
	
		toinsert = '<div id="mnavr2-floater">';
		toinsert+= '<ul>';							
		
		elemcount = navData.getLength(navFloat2Show);
			
		for(i=0; i<elemcount; i++){			
			toinsert+= '<li'+(  (i==0) ? ' class="sub-first"': ((i==elemcount-1) ? ' class="sub-last"' : ''))+'><a href="' + rel2rootweb + navData.getPath(navFloat2Show, i) + addSID + '" class="floatlink" onfocus="javascript:stopNavFloatTimer();" onblur="javascript:startNavFloatTimer();" onmouseover="javascript:stopNavFloatTimer();" onmouseout="javascript:startNavFloatTimer();">'+navData.getTitle(navFloat2Show, i)+'</a></li>';
		}				
		toinsert+= '</ul>';
		toinsert+= '</div>';
		new Insertion.After('mnav'+navFloat2Show, toinsert);
		$('mnav'+navFloat2Show).up().addClassName('tmpactive');
	}			
	navFloatActive = navFloat2Show;														
}			

function showNavFloatNow(e){
	if (navFloatTimer){
		window.clearTimeout(navFloatTimer);				
	}
				
	s = Event.element(e);
	do {
		n = s.id;
		s = s.parentNode;
	} while (n.substr(0, 4)!='mnav')		
	navFloat2Show = n.substr(n.length-1,1);
		
	showNavFloat();
}

function startNavFloatShowTimer(e){		
	if (navFloatTimer){
		window.clearTimeout(navFloatTimer);				
	}
				
	s = Event.element(e);
	do {
		n = s.id;
		s = s.parentNode;
	} while (n.substr(0, 4)!='mnav')		
	navFloat2Show = n.substr(n.length-1,1);
		
	navFloatTimer = window.setTimeout("showNavFloat()", 300);
}

function startNavFloatTimer(e){
	if (navFloatTimer){
		window.clearTimeout(navFloatTimer);				
	}	
	navFloatTimer = window.setTimeout("closeNavFloat()", 1000);
}


function stopNavFloatTimer(e){			
	if (navFloatTimer){
		window.clearTimeout(navFloatTimer);				
	}
}		


function closeNavFloat(){
	if ($('mnavr2-floater')){
		$('mnavr2-floater').up('li').removeClassName('tmpactive');
		
		/*
		if ($('mnav'+navFloatActive+'-active')){	
			$('mnav'+navFloatActive+'-active').toggleClassName('sub-active');
		}	
		*/
		$('mnavr2-floater').remove();			
		navFloatActive = '';			
	}
}


function showSearchFilter(e){	
	$('sub-searchfilter').show();
}	
