$('.box1.unternehmen').click( function() {showItem('unternehmen');});
$('.box1.aktuell').click( function() {showItem('aktuell');});
$('.box3.industrie').click( function() {showItem('industrie');});
$('.box3.motoren').click( function() {showItem('motoren');});
$('.box3.heiz').click( function() {showItem('heiz');});
$('.box3.anlagen').click( function() {showItem('anlagen');});

$('.box1.angebote').click( function() {showItem('angebote');});
$('.box1.service').click( function() {showItem('service');});
$('.box1.vertrieb').click( function() {showItem('vertrieb');});
//$('.box1.news').click( function() {showItem('news');});

var opened = 0;


function showItem(test) {
	id = '#index-'+test;
	if($('.middle-content-item'+id).is(':visible')) {	
		$('.middle-content-item').slideUp(300);
		opened = 0;
	}
	else if(opened == 0) {
		
		//cr 21.09.2011 - jump down or up
		if(id=="#index-angebote" || id=="#index-service" || id=="#index-vertrieb" || id=="#index-news") {
			$('.middle-content-item'+id).delay(200).slideDown(200);
			$("html").delay(200).animate({ scrollTop: 60000 }, 200);
		}
		else {
			$('.middle-content-item'+id).delay(200).slideDown(200);	
		}
		
		opened = 1;
	}
	else {
		$('.middle-content-item').fadeOut(200);
		$('.middle-content-item'+id).delay(200).fadeToggle(200);
	}
}


$(document).ready( function() {
	
	$('.box1').mouseenter( function() {
		fadeAllOut();
		$(this).css( {"opacity": "1.0" });
	});
	
	$('.box1').mouseleave( function() {
		if(opened == 0) {
		 	fadeAllIn();
		}
	});
	
	$('.box3').mouseenter( function() { 
		fadeAllOut();
		//$('.box2').css( {"opacity": "1.0" });
		$(this).css( {"opacity": "1.0" });
	});
	
	$('.box3').mouseleave( function() {
		if(opened == 0) { 
			fadeAllIn();
		}
	});

});

function fadeAllOut() {
	$('.box1, .box2, .box3').css( {"opacity": "0.5" });	
}

function fadeAllIn() {
	$('.box1, .box2, .box3').css( {"opacity": "1.0" });
}

