window.addEvent('domready', function() {
	var originalWidth = 260;
	var originalHeight = 400;
	var fullWidth = 830;
	var fxDuration = 500;
	
	var medFx = new Fx.Styles('medReha', {duration:fxDuration, wait:false});
	var sozFx = new Fx.Styles('sozReha', {duration:fxDuration, wait:false});
	var berFx = new Fx.Styles('berReha', {duration:fxDuration, wait:false});
	
	var clicked = 0;

	var theHeight = 0;
	var topDistance = $('medReha').getPosition();
	if (window.innerHeight) {
		theHeight=window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		theHeight=document.documentElement.clientHeight;
	} else if (document.body) {
		theHeight=document.body.clientHeight;
	} 
	theHeight = theHeight-1-topDistance["y"];
	

	$('medReha').addEvents({
		'click': function(){
			if (!clicked) {
				clicked = 1;
				$('sozReha').style.display = 'none';
				$('berReha').style.display = 'none';
				
				$('medRehaMore').style.display = 'none';
				$('medReha').style.color = '#fff';
				$('medReha').style.background = '#777';
				
				medFx.start({
					'width': fullWidth,
					'height': theHeight
				}).chain(function(){ setAutoHeight('medReha'); }); 
			} else {
				clicked = 0;
				medFx.start({
					'width': originalWidth,
					'height': originalHeight
				}).chain(function(){ setAllDisplayBlock(); }); 
				$('medReha').style.color = '#ccc';
				$('medReha').style.background = '#666';
			}	
		}
	});
		
	$('sozReha').addEvents({
		'click': function(){
			if (!clicked) {
				clicked = 1;
				$('medReha').style.display = 'none';
				$('berReha').style.display = 'none';
				
				$('sozReha').setStyle('margin-left',282)
				$('sozRehaMore').style.display = 'none';
				$('sozReha').style.color = '#fff';
				$('sozReha').style.background = '#777';
				
				sozFx.start({
					'width': fullWidth,
					'height': theHeight,
					'margin-left': 0
				}).chain(function(){ setAutoHeight('sozReha'); });
			} else {
				clicked = 0;
				sozFx.start({
					'width': originalWidth,
					'height': originalHeight,
					'margin-left': originalWidth+6+16
				}).chain(function(){ setAllDisplayBlock(); });
				$('sozReha').style.color = '#ccc';
				$('sozReha').style.background = '#666';
			}	
		}
	});
	
	$('berReha').addEvents({
		'click': function(){
			if (!clicked) {
				clicked = 1;
				$('medReha').style.display = 'none';
				$('sozReha').style.display = 'none';
				
				$('berRehaMore').style.display = 'none';
				$('berReha').style.color = '#fff';
				$('berReha').style.background = '#777';
				
				berFx.start({
					'width': fullWidth-6,
					'height': theHeight
				}).chain(function(){ setAutoHeight('berReha'); });
			} else {
				clicked = 0;
				berFx.start({
					'width': originalWidth,
					'height': originalHeight
				}).chain(function(){ setAllDisplayBlock(); });
				$('berReha').style.color = '#ccc';
				$('berReha').style.background = '#666';
			}	
		}
	});
});

function setAllDisplayBlock ( )
{
  $('medReha').style.display = 'block';
  $('medRehaMore').style.display = 'block';
  $('sozReha').style.display = 'block';
  $('sozRehaMore').style.display = 'block';
  $('sozReha').style.margin  = 0;
  $('berReha').style.display = 'block';
  $('berRehaMore').style.display = 'block';
}

function setAutoHeight (element)
{
  switch(element) {
  	case "medReha":
  		$('medReha').style.height = 'auto';
  		break;
  	case "sozReha":
  		$('sozReha').style.height = 'auto';
  		break;
  	case "berReha":
  		$('berReha').style.height = 'auto';
  		break;
  }
}

