/*
	animate.navigation by Stefan Bleilevens
	last edit: 4th Nov, 2009
	copyright by Euroweb Internet GmbH
*/
var animationActive;
var tabActive;
var timeout;
jQuery(document).ready(function(){
	jQuery('a[rel="noHREF"]').attr("href","#"); // replace all alternative href's
	
	init();
	jQuery(".tab.hideable").click(function(){
		if(!tabActive){
			jQuery(this).animate({
				top: 0
			}, 600, function(){ tabActive = jQuery(this).attr("id"); jQuery(this).attr("class","tab active"); });
		}
		else {
			if(!jQuery(".tab.active").attr("id") == tabActive){
				hideTabs(jQuery(this));
			}
			else {
				hideTabs();
			}
		}
	});
});

function hideTabs(viewAfterFinish){
	jQuery(".tab.active").animate({
		top: (jQuery(".tab.active").height() * -1) + 20
	}, 1000, function() {
		tabActive = false;
		jQuery(".tab.active").attr("class","tab"); 
	});
	
	if(viewAfterFinish){
		jQuery(viewAfterFinish).animate({
								  top: 0
								  }, 600, function(){tabActive = jQuery(viewAfterFinish).attr("id"); jQuery(viewAfterFinish).attr("class","tab active"); });
	}
}

function init(){
	jQuery(".tab").css("height", "auto");
	jQuery(".tab-content").css("height", "auto");
	jQuery(".tab#tiefbau").css("top", (jQuery(".tab#tiefbau").height() - 20) * -1);
	jQuery(".tab#kanalbau").css("top", (jQuery(".tab#kanalbau").height() - 20) * -1);
	jQuery(".tab#umweltbau").css("top", (jQuery(".tab#umweltbau").height() - 20) * -1);
	
	jQuery(".tab.fixed").css("top","0");
}
