window.addEvent('domready', function() {

			var ref_list = $$(document.getElementsByName('refbox_content'));
			var refinfo_list = $$(document.getElementsByName('ref_info'));
			var refpic_list = $$(document.getElementsByName('ref_pic'));
			var ref_topic_list = $$(document.getElementsByName('refbox_topic'));									

			var slide_object_list = new Array();
			var slide_topic_list = new Array();
			var ref_topic_open_border = 20;													// px-marker im ausgeklappen rebox header
			var ref_topic_open_right_spacing = 550;
			var contact_top_height = 280;

			ref_topic_list.each( function(ref_topic, i){

				var slide_object = new Fx.Slide(ref_list[i], {								// definition des main-slide-effekts
					duration: 500,
					transition: 'circ:out' 													// bounce:out/in , quad, circ, linear, elastic ...
				});			

				slide_object_list[i] = slide_object;
				
				ref_topic.onclick = function(){					
					 
					if ($('contact_top').getStyle("height") == "0px"){						// onclick auf referenz
											
						slide_object.toggle();												// referenz öffnen
					
						$('expand-all').morph({'color':'#ccc'});
						$('collapse-all').morph({'color':'#ccc'});
						
						// var status = ref_topic.getProperty("title");
											
						if (ref_topic.getProperty("title") == "closed"){						
							ref_topic.setProperty("title", "open");								// internen status setzen						
							ref_topic.morph({													// marker setzen
								'border-left-width':[1,ref_topic_open_border],
								'border-color':['#f30','#fff']
							});
						}
						else
						{
							ref_topic.setProperty("title", "closed");
							ref_topic.morph({
								'border-left-width':[ref_topic_open_border,1],
								'width':600
							});
						};
					};
					return false;
				};
				

				   refpic_list[i].addEvents({													// rollover opacity changes
						mouseenter: function(){
							//this.fade(0.3);
							for(var j=0;j<slide_object_list.length; j++){
								if(j!=i){
									ref_topic_list[j].fade(0.3);
									refpic_list[j].fade(0.3);
									refinfo_list[i].morph({'opacity': 1});
								};
							};
						},
						mouseleave: function(){		
							//this.fade(1);
							for(var j=0;j<slide_object_list.length; j++){
								if(j!=i){							
									ref_topic_list[j].fade(1);
									refpic_list[j].fade(1);
									refinfo_list[i].morph({'opacity': 0});
								};
							};
						}						
					});
				   
					$('header_right').addEvents({													// rollover logo changes
						mouseenter: function(){
							$('header_right').morph({'background-image': 'url(http://v4.l-rac.de/_inc/header_logo_orange.jpg)'});							
						},
						mouseleave:function(){
							$('header_right').morph({'background-image': 'url(http://v4.l-rac.de/_inc/header_logo.jpg)'});							
						},
						'click': function(){
							window.location = 'http://v4.l-rac.de'
						}
					});

																							//----------------------------------
																							//		ONLOAD 
																							//----------------------------------
				slide_object.hide();														
				//$('show_category_all').morph({'color':'#F30'});
				//$('open_references').morph({'color':'#F30'});
				$('open_references').morph({'border-left-width':'10px'});
				refinfo_list.set({'opacity': 0});
											
				if (ref_topic.getProperty("title") == "open"){								//initial klapp-status herstellen
					slide_object.toggle();
					ref_topic.morph({
						'border-left-width':[1,ref_topic_open_border],
						'border-color':['#f30','#fff']
					});
				}
				else
				{
					ref_topic.morph({
						'border-color':['#f30','#f30']
					});
				};
			});

			$('collapse-all').addEvent('click', function() {								// collapse - all
				$('expand-all').morph({'color':'#ccc'});
				$('collapse-all').morph({'color':'#F30'});
				$('expand-all').morph({'border-left-width':'1px'});
				$('collapse-all').morph({'border-left-width':'10px'});
				
				ref_topic_list.each( function(ref_topic, i){
					slide_object_list[i].slideOut();
					
					if (ref_topic_list[i].getProperty("title") != "closed"){
						ref_topic_list[i].setProperty("title", "closed");
						ref_topic_list[i].morph({
							'border-left-width':[ref_topic_open_border,1]
						});
					};
					
				});
				return false;
			});

			$('expand-all').addEvent('click', function() {									// expand - all
				$('expand-all').morph({'color':'#F30'});
				$('collapse-all').morph({'color':'#CCC'});
				$('expand-all').morph({'border-left-width':'10px'});
				$('collapse-all').morph({'border-left-width':'1px'});
				
				ref_topic_list.each( function(ref_topic, i){
					if (ref_topic_list[i].getProperty("visible") == "true"){
						slide_object_list[i].slideIn();	
					
						if (ref_topic_list[i].getProperty("title") != "open"){
							ref_topic_list[i].setProperty("title", "open");
							ref_topic_list[i].morph({
								'border-left-width':[1,ref_topic_open_border],
								'border-color':['#f30','#fff']
							});
						};
					};
				});
				return false;
			});	
						
			$('show_category_2').addEvent('click', function() {								// kategorie 2...
				ref_topic_list.each( function(ref_topic, i){
					
					var slide_object = new Fx.Slide(ref_list[i], {							// definition des main-slide-effekts
						duration: 500,
						transition: 'circ:out' 												// bounce:out/in , quad, circ, linear, elastic ...
					});
					
					var slide_topic = new Fx.Slide(ref_topic_list[i],{
						duration: 500,
						transition: 'circ:out'
					});

					slide_object_list[i] = slide_object;
					slide_topic_list[i] = slide_topic;
					
					$('show_category_2').morph({'color':'#F30'});
					$('show_category_1').morph({'color':'#CCC'});
					$('show_category_all').morph({'color':'#CCC'});
					$('expand-all').morph({'color':'#ccc'});
					$('collapse-all').morph({'color':'#ccc'});
					
					$('show_category_2').morph({'border-left-width':'10px'});
					$('show_category_1').morph({'border-left-width':'1px'});
					$('show_category_all').morph({'border-left-width':'1px'});
					$('expand-all').morph({'border-left-width':'1px'});
					$('collapse-all').morph({'border-left-width':'1px'});
					
					if (ref_topic_list[i].getProperty("category") != "2"){
						slide_object_list[i].slideOut();
						slide_topic_list[i].slideOut();
						ref_topic_list[i].setProperty("visible", "false");
						if (ref_topic_list[i].getProperty("title") == "open"){				// initial klapp-status herstellen							
							ref_topic_list[i].setProperty("title", "closed");
							ref_topic_list[i].morph({
								'border-left-width':[ref_topic_open_border,1]//,
								//'width':800
							});
						};
					}
					else
					{
						slide_topic_list[i].slideIn();
						ref_topic_list[i].setProperty("visible", "true");
					};
				});			
				return false;				
			});
			$('show_category_1').addEvent('click', function() {								// kategorie 1...
				ref_topic_list.each( function(ref_topic, i){
					
					var slide_object = new Fx.Slide(ref_list[i], {							// definition des main-slide-effekts
						duration: 500,
						transition: 'circ:out' 												// bounce:out/in , quad, circ, linear, elastic ...
					});
					
					var slide_topic = new Fx.Slide(ref_topic_list[i],{
						duration: 500,
						transition: 'circ:out'
					});

					slide_object_list[i] = slide_object;
					slide_topic_list[i] = slide_topic;
					
					$('show_category_1').morph({'color':'#F30'});
					$('show_category_2').morph({'color':'#CCC'});
					$('show_category_all').morph({'color':'#CCC'});
					$('expand-all').morph({'color':'#ccc'});
					$('collapse-all').morph({'color':'#ccc'});
					
					$('show_category_1').morph({'border-left-width':'10px'});
					$('show_category_all').morph({'border-left-width':'1px'});
					$('show_category_2').morph({'border-left-width':'1px'});
					$('expand-all').morph({'border-left-width':'1px'});
					$('collapse-all').morph({'border-left-width':'1px'});
					
					if (ref_topic_list[i].getProperty("category") != "1"){
						slide_object_list[i].slideOut();
						slide_topic_list[i].slideOut();
						ref_topic_list[i].setProperty("visible", "false");
						if (ref_topic_list[i].getProperty("title") == "open"){					
							ref_topic_list[i].setProperty("title", "closed");
							ref_topic_list[i].morph({
								'border-left-width':[ref_topic_open_border,1]//,
								// 'width':800
							});
						};
					}
					else
					{
						slide_topic_list[i].slideIn();
						ref_topic_list[i].setProperty("visible", "true");
					};
				});			
				return false;				
			});
			$('show_category_all').addEvent('click', function() {								// kategorie all 
				ref_topic_list.each( function(ref_topic, i){
					
					var slide_topic = new Fx.Slide(ref_topic_list[i],{
						duration: 500,
						transition: 'circ:out'
					});
					
					slide_topic_list[i] = slide_topic;					
					
					$('show_category_all').morph({'color':'#F30'});
					$('show_category_1').morph({'color':'#CCC'});
					$('show_category_2').morph({'color':'#CCC'});
					$('expand-all').morph({'color':'#ccc'});
					$('collapse-all').morph({'color':'#ccc'});
					
					$('show_category_all').morph({'border-left-width':'10px'});
					$('show_category_1').morph({'border-left-width':'1px'});
					$('show_category_2').morph({'border-left-width':'1px'});
					$('expand-all').morph({'border-left-width':'1px'});
					$('collapse-all').morph({'border-left-width':'1px'});
					
					ref_topic_list[i].setProperty("visible", "true");
					slide_topic_list[i].slideIn();
					
				});			
				return false;				
			});	
			
			$('open_contact').addEvent('click', function(){
			//	window.location.href = "projects/johnnywannabe/index.php".addAttribute + "?rel='shadowbox;width=780;height=780'"
			});
			
			var menu_reference_options_slide = new Fx.Slide('menu_reference_options',{duration: 2000, transition: 'circ:out'});							//// der marker zum, undo!!
			var mailform_response = new Fx('form_response_box',{duration: 1000, transition: 'circ:out'});
			
			$('open_profil').addEvent('click', function(){
				
				ref_topic_list.each( function(ref_topic, i){

					var slide_object = new Fx.Slide(ref_list[i], {								// definition des main-slide-effekts
						duration: 500,
						transition: 'circ:out'
					});																			// bounce:out/in , quad, circ, linear, elastic ...
					
					if (ref_topic_list[i].getProperty("visible") == "true"){
						slide_object_list[i].slideOut();	
						
					//	if (ref_topic_list[i].getProperty("title") != "close"){
					//		ref_topic_list[i].setProperty("title", "close");
					//		ref_topic_list[i].morph({
					//			'border-left-width':[ref_topic_open_border,1]
					//		});
					//	};
					};
				});			
				$('contact_top').morph({
					'height': contact_top_height
				});	
				$('reference').morph({
					'opacity': 0.3
				});
				
				//slide_object_list[i] = slide_object;
				
				//var ref2contact = new Fx.Morph('reference', {duration: 1000, transition: 'circ:in'}).addEvent(
				//	'onComplete', function() {
				//		$('contact').morph({'width':'800px'});
				//	}
				//);	
				//ref2contact.start({width:'0px'});
				menu_reference_options_slide.slideOut();
				$('open_profil').morph({'color':'#F30'});
				$('open_profil').morph({'border-left-width':'10px'});
				$('open_references').morph({'color':'#ccc'});
				$('open_references').morph({'border-left-width':'1px'});
				return false;	
											 
			});
			$('open_references').addEvent('click', function(){	
				
				ref_topic_list.each( function(ref_topic, i){

					var slide_object = new Fx.Slide(ref_list[i], {								// definition des main-slide-effekts
						duration: 500,
						transition: 'circ:out'
					});																			// bounce:out/in , quad, circ, linear, elastic ...
					
					if (ref_topic_list[i].getProperty("visible") == "true"){
						if (ref_topic_list[i].getProperty("title") == "open"){
							slide_object_list[i].slideIn();
						};						
					};
				});
				//var mailform_response = new Fx.Morph('form_response_box',{duration: 1000, transition: 'circ:out'}).addEvent(
				//	'onComplete', function() {						
				//		$('form_response_box').morph({'opacity':'0'});
				//		$('form_response_box').setStyles({
				//			'display':'none',
				//			'opacity':'0'
				//		});
				//		contact2ref.start({width:'0px'});
				//	}
				//);
				
				$('contact_top').morph({
					'height': 0
				});	
				$('reference').morph({
					'opacity': 1
				});
				
				//var contact2ref = new Fx.Morph('contact', {duration: 1000, transition: 'circ:in'}).addEvent(
				//	'onComplete', function() {
				//		$('reference').morph({width:'800px'});						
				//	}
				//);
				
				//mailform_response.start({opacity:'0'});
				menu_reference_options_slide.slideIn();		
				$('open_profil').morph({'color':'#ccc'});
				$('open_profil').morph({'border-left-width':'1px'});
				$('open_references').morph({'color':'#F30'});
				$('open_references').morph({'border-left-width':'10px'});
				return false;				
			});		
			
			//$('test_btn').addEvent('click', function() {								// test button
			//	alert('testbutton');													 
			//	return false;				
			//});		

});
