navigation = {};
navigation.init = function() {
	
	/*
	var landfunkerlogo = $('landfunker_logo').down('img');
	var landfunkerimage = landfunkerlogo.src;
	//landfunker.de Logo
	Event.observe($('landfunker_logo'), "mouseover", function(event){
		landfunkerlogo.src = '../_gfx/landfunker/landfunker_logo3.gif';
	});
	
	Event.observe($('landfunker_logo'), "mouseout", function(event){ 
		landfunkerlogo.src = landfunkerimage;
	});		
	*/
	
	navigation.csspath = '#navigation .bottom ul li a';
	
	navigation.duration = 500;
	
	navigation.isOpened = function() {
		var opend=0;
		$$('#header #hover .menu').each(function(navItem) {
			if (navItem.style.display=='') {
				opend++;
			}
		});
		if (opend>0) return true;
		else return false;		
	}
	
	/*
	var nav = navigator;
	var agent = nav.userAgent;
	var isIE = -1 != agent.indexOf('MSIE');
	var isFF = -1 != agent.indexOf('Firefox');
	var ver = parseFloat(nav.appVersion);
	alert(Prototype.Browser.IE);
	*/
	navigation.toggle = function(obj, v) {
		
		if (v) {
			//Öffnen
			Event.observe($(obj), "mouseover", function(event){ 
				clearTimeout(navigation.menuTimer);
			});
			
			Event.observe($(obj).down('div'), "mouseover", function(event){
				//für mouseover subitems
				clearTimeout(navigation.menuTimer);
			});
			
			Event.observe($(obj), "mouseout", function(event){ 
				clearTimeout(navigation.menuTimer);
				navigation.menuTimer = setTimeout("navigation.toggle('" + obj + "', false );", navigation.duration );
			});				
			
			$$('.menu').each(function(menu) {menu.hide()});
			var left = 0;
			$$(navigation.csspath).each(function(navItem) {
				if (left>450) left = 450;
				
				
				navItem.left = left-7;
				left+= navItem.offsetWidth;
				
				
				navItem.removeClassName('active');
			});
			
			
			$$(navigation.csspath+'[rel='+obj+']').each(function(navItem) {
				navItem.addClassName('active');
				left = navItem.left;
			});
			
			//Menu Content Abstand
			if (left<0) left=0;
			$(obj).down('div.naviUL').setStyle({marginLeft: left+'px'});
			$(obj).show();
		} else {
			//Schließen
			$$(navigation.csspath).each(function(navItem) {navItem.removeClassName('active');});
			$(obj).hide();
		}
	}
	
	
	
	
	$$(navigation.csspath).each(function(navItem) {
		
		//if ($(navItem).rel!=undefined) {
		if ($(navItem).rel!=undefined && $(navItem).rel!=null && $(navItem).rel!='') {
			
			var menu = $($(navItem).rel);
			
			menu.hide();
						
			Event.observe(navItem, "mouseover", function(event){ 
				
				if (!navigation.isOpened()) {
					clearTimeout(navigation.menuTimer);
					navigation.menuTimer = setTimeout("navigation.toggle('" + this.rel + "', true );", navigation.duration );
				} else {				
					if (!navItem.hasClassName('active')) navigation.toggle(this.rel, true);
					else clearTimeout(navigation.menuTimer);
				}
			});
			
			Event.observe(navItem, "click", function(event){ 
				clearTimeout(navigation.menuTimer);
				if (!navItem.hasClassName('active')) navigation.toggle(this.rel, true);
			});
			
			Event.observe(navItem, "mouseout", function(event){
				clearTimeout(navigation.menuTimer);
				navigation.menuTimer = setTimeout("navigation.toggle('" + this.rel + "', false );", navigation.duration );
			});
			
		}		
	});
	

	$$('.top a').each(function(mainnavItem) {
		Event.observe(mainnavItem, "mouseover", function(event){ 
			$$(navigation.csspath+'.active').each(function(navItem) {
				navigation.toggle(navItem.rel, false);
			});
		});
	});
	
	$('hover').show();
}
