$(document).ready(function() {
	$('ul.sf-menu').superfish({
		animation: {height:'show'},
		delay: 1600,
		autoArrows : false
	});
	
	$('ul.sf-menu a.nav-first').click(function(){
	  return false;
	});

	swapValue = [];
	$("input.txt, textarea").each(function(i){
	   swapValue[i] = $(this).val();
   		$(this).focus(function(){
      	if ($(this).val() == swapValue[i]) {
         	$(this).val("");
      	}
      	$(this).addClass("focus");
   	}).blur(function(){
      		if ($.trim($(this).val()) == "") {
         		$(this).val(swapValue[i]);
	 			$(this).removeClass("focus");
      		}
   		});
	});
	

	// shows the title bar
	$('#subHeader h2').animate({opacity: '+=0'}, 100).slideToggle('slow');
	$('#subHeader h1').animate({opacity: '+=0'}, 1000).fadeIn('slow');
	
	var open = false;
     
    // NEU FÜR TABS:
	var hidetimer;

    hidetimer=window.setTimeout("animateTabSlideIn()",2000);

    $('#tabButton1').click(
    	function() { 
		expandTabs(1)	
    	}, function() {	});

    $('#tabButton2').click(
    	function() { 
		expandTabs(2)	
    	}, function() {	});

    $('#tabButton3').click(
    	function() { 
		expandTabs(3)	
    	}, function() {	});

    $('#bar-bottom').hover(
    	function() {
		window.clearTimeout(hidetimer);		
    	}, function() {
		hidetimer=window.setTimeout("animateTabSlideIn()",1000);
    	});

	// ENDE FÜR TABS


    // Animate bg on hover nav
    $('ul.sf-menu').hover(function() {
	    $('#homeTeaser-bg').stop(false,true).fadeIn(200);
	},
	function() {
		$('#homeTeaser-bg').stop(false,true).fadeOut(200);
	});
	

    // Animate nav images
    $('ul.sf-menu ul li').hover(function() {
		$(this).children('a.zoom').children('img').stop(false,true).animate({ height: '81', left: '-1px', top: '-1px', width: '125'}, 1200);
        $(this).children('a.slide').children('img').stop(false,true).animate({ left: '0px', top: '-10px'}, 1200);
        $(this).children('a.zoom-out').children('img').stop(false,true).animate({ height: '148', width: '220', left: '-20px', top: '-40px'}, 1200);
	},
	function() {
		$(this).children('a.zoom').children('img').stop(false,true).animate({ height: '148', left: '-20px', bottom: '0', width: '220'}, 600);
        $(this).children('a.slide').children('img').stop(false,true).animate({ left: '-35px', top: '-10px'}, 600);
        $(this).children('a.zoom-out').children('img').stop(false,true).animate({ height: '81', left: '0', top: '0', width: '125'}, 600);
	});
	
	$('a.op50 img').animate({ opacity: 0.5 }, 500);
	
	// Animate Rollover
	$('a.op50 img').each(function() {
       $(this).hoverIntent(function() {
          $(this).animate({ opacity: 1 }, 500);
       },
       function() {
          $(this).animate({ opacity: 0.5 }, 500);
       });
    });
	
});

function animateTabSlideIn(){
	var tabCont=document.getElementById('tabcontent');
	 if (tabCont.offsetHeight>1) {
	  var newHeight=(tabCont.offsetHeight-5)
		if (newHeight<=0) newHeight="1";
	  tabCont.style.height=newHeight+'px';
		if (newHeight>0) 
				window.setTimeout(" animateTabSlideIn();",15);
	 }
}
function animateTabSlideOut(){
	var tabCont=document.getElementById('tabcontent');
	 if (tabCont.offsetHeight<100) {
	  var newHeight=(tabCont.offsetHeight+5)
		if (newHeight>=100) newHeight="100";
	  tabCont.style.height=newHeight+'px';
		if (newHeight>0) 
				window.setTimeout(" animateTabSlideOut();",10);
	 }
}

function expandTabs(id){
		for (i=1;i<=3;i++)
				document.getElementById("tabInhalt" + i).style.display="none";

		document.getElementById("tabInhalt" + id).style.display="block";						
//		document.getElementById("tabcontent").style.height="100px";
		animateTabSlideOut();
}