document.observe("dom:loaded", function() {

	//MENUE
	
		show_active_menue();
    	
    	function show_active_menue() {
   		
    		var ms = $$('#mainmenue a.active'); 		
			ms.each(function(m) {
				if( m.up("li").down("ul")) {
    				 m.up("li").down("ul").setStyle({display:'block'});
    			 }
    			 
    		});
    	}
    	
    	$$('#mainmenue a.first').invoke('observe', 'mouseover', show_sub_menue);
    	
    	
    	$$('#mainmenue a.first').invoke('observe', "click", function(event) {
        	$$('#mainmenue a.first').invoke('stopObserving');
      	 });
      	 
      	$('mainmenue').observe('mouseleave', show_page_menue);  
    	
    	 function show_sub_menue(event) {
        	event.stop();
        	_show_sub_menue(this)
        	
        	return; 

          }
          
       function _show_sub_menue(element) {
    		 if(element) {
	    		var uls = element.up("ul").select("ul");
	         	var as = element.up("ul").select("a");
	
	         	as.each(function(a) {
	         		a.removeClassName("active");
	         	});
	
	         	uls.each(function(ul) {
	         		ul.setStyle({display:'none'});
	         	});
	
	         	var act_menue = element.up().childElements()[1];    	
	         	if(act_menue) { //aktuelle Liste einblenden
	 				if(act_menue.tagName == "UL") { 
	            			act_menue.setStyle({display:'block'});
	            		}
	 			}
	 			
	         	element.addClassName("active");
    		 }
    	 }
    	 
    	 function show_page_menue() {
        	var act_menu = $('act_men');
        	_show_sub_menue(act_menu);
        	      	
        	return; 

          }

	
	
	//Autoren
	if( $("authors")) {
	var boxes = $$("div.author_box_content");
	var article_boxes = $$("div.author_article");
	
	$$("div.author_box").each( function(box) {
			
			var h5 = box.down("h5");
		
			if (h5) {
				h5.setStyle( {
					cursor :'pointer'
				});
				
				box.observe("click", function(event) {
				
					content_box = box.down('div');
				
					content_box.blindDown({ duration:  0.5 });
				
					author_id =  content_box.getAttribute('id');
				
					author_article_box = $('article_box_'+author_id);
				
				
				
					
					article_boxes.each(function(d) {
					if(d != author_article_box) {
				  		d.hide();
				  	}
				  	
				  		if(author_article_box) {
							new Effect.BlindDown(author_article_box, { duration:  0.5 });
						}
				  	
				  	
				 });
				boxes.each(function(c) {
					if(c != content_box) {
				  		c.blindUp({ duration:  0.5 });
				  	}
				  	
				  	
				 });

				});
			}
		});
	//erste Autorbox aufklappen
	var first_box = boxes.first();	
	first_box.blindDown({ duration: 0.5 });
	
	//gibt es eine Artikelbox zum Autor?
	author_id =  first_box.getAttribute('id');
	author_article_box = $('article_box_'+author_id);
	
	if(author_article_box) {
		author_article_box.blindDown({ duration:  0.5 });
	}
	
	}
	
	
		
}
);

