$(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");
      		}
   		});
	});
	
		
	// move the world.
	//$('#earth').effect("pulsate", { times:1 }, 400).fadeOut();
	
	// shows the title bar
	$('#subHeader h2').animate({opacity: '+=0'}, 100).slideToggle('slow');
	$('#subHeader h1').animate({opacity: '+=0'}, 1000).fadeIn('slow');
	
	var open = false;
     
    if($('#bar-bottom').length > 0){
    	//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
         

	$("#btn-slide, .vrtr").click(function(){
		$("#panel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	$("#btn-close").click(function(){
		$("#panel").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
    
	$("#doform43 #el_3, #call-back #eventdate").datepicker({
		showOn: 'button',
		buttonImage: './templates/img/icons/calendar.gif',
		buttonText: 'Kalender',
		buttonImageOnly: true
	});
	
	$.datepicker.regional['de'] = {
			clearText: 'Löschen',
			clearStatus: 'aktuelles Datum löschen',
			closeText: 'Schlie&szlig;en',
			closeStatus: 'ohne Änderungen schließen',
			prevText: '&lsaquo; zurück',
			prevStatus: 'letzten Monat zeigen',
			prevBigText: '&laquo;',
			prevBigStatus: '',
			nextText: 'vor &rsaquo;',
			nextStatus: 'nächsten Monat zeigen',
			nextBigText: '&raquo;',
			nextBigStatus: '',
			currentText: 'Heute',
			currentStatus: '',
			monthNames: ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
			monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'],
			monthStatus: 'anderen Monat anzeigen',
			changeMonth: false,
			yearStatus: 'anderes Jahr anzeigen',
			changeYear: false,
			weekHeader: 'Wo',
			weekStatus: 'Woche des Monats',
			dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
			dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
			dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
			dayStatus: 'Setze DD als ersten Wochentag',
			dateStatus: 'Wähle D, M d',
			dateFormat: 'dd.mm.yy',
			firstDay: 1,
			initStatus: 'Wähle ein Datum',
			isRTL: false,
			showButtonPanel: true,
			showMonthAfterYear: false,
			yearSuffix: ''
		};
		$.datepicker.setDefaults($.datepicker.regional['de']);


	// Facebox
	$('a[rel*=facebox]').facebox({
		loading_image : '/templates/js/facebox/loading.gif',
		close_image   : '/templates/facebox/closelabel.gif'
	}) 



    // 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'}, 800);
        $(this).children('a.slide').children('img').stop(false,true).animate({ left: '0px', top: '-10px'}, 800);
        $(this).children('a.zoom-out').children('img').stop(false,true).animate({ height: '148', width: '220', left: '-20px', top: '-40px'}, 800);
	},
	function() {
		$(this).children('a.zoom').children('img').stop(false,true).animate({ height: '148', left: '-20px', bottom: '0', width: '220'}, 400);
        $(this).children('a.slide').children('img').stop(false,true).animate({ left: '-35px', top: '-10px'}, 400);
        $(this).children('a.zoom-out').children('img').stop(false,true).animate({ height: '81', left: '0', top: '0', width: '125'}, 400);
	});
	
	$('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);
       });
    });
    
    
    $('#countries img').not('.current img').animate({ opacity: 0.4 }, 100);
    // Animate Rollover
	$('#countries img').not('.current img').each(function() {
       $(this).hover(function() {
          $(this).animate({ opacity: 1 }, 200);
       },
       function() {
          $(this).animate({ opacity: 0.4 }, 200);
       });
    });
    
   
	if($('#lenyards').length > 0){    
    	$('#lenyards').cycle({
			fx: 'fade'
		});
	}
		
});

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();
}
