// JavaScript Document

// Alles für JQuery und meine eigenen Skripte
function preloadImages() {
		preload( "images/ajax-loader.gif" );
		preload_fertig = true;
	}
	
	preloadImages;
 
$(document).ready(function(){
	
// Weiche für die Navigation
	
	// iPhone, etc.
	if(mobile){
		$("#navi ul li#magazin").click(function(){
			$(".zweite_ebene").hide();
			$("#magazin-sub a").show();
		});	
		$("#navi ul li#idee").click(function(){
			$(".zweite_ebene").hide();
			$("#idee-sub a").show();
		});	
		$("#navi ul li#veranstaltungen").click(function(){
			$(".zweite_ebene").hide();
			$("#veranstaltungen-sub a").show();
		});	
		$("#navi ul li#themen").click(function(){
			$(".zweite_ebene").hide();
			$("#themen-sub a").show();
		});	
		$("#navi ul li#service").click(function(){
			$(".zweite_ebene").hide();
			$("#service-sub a").show();
		});		
		
		$(".link-galerie").click(function(){
			$("#bildbox").css({height:"auto"});
			return false;
		});	
	}
		
		
	//Tablets
	else if(tablet){
		$("#balken").delay(2000).animate({height:'19px'},{queue:true, duration:400, easing: 'easeOutQuart'});
		$("#open").delay(3000).fadeIn("fast");
		$("#close").hide();
		$(".aktiv").delay(1800).fadeOut("fast");
	
		$("#trigger").click(
		function(){
			$("#balken").stop().animate({height:'245px'},{queue:false, duration:400, easing: 'easeInQuart'});
			$("#close").delay(500).fadeIn("fast");
			$("#open").fadeOut("fast");
			$(".aktiv").delay(500).fadeIn("fast");
		});
	
		$("#close").click(
			function(){
				$("#balken").stop().animate({height:'19px'},{queue:true, duration:400, easing: 'easeOutQuart'});
				$("#close").fadeOut("fast");
				$("#open").delay(500).fadeIn("fast")
				$(".aktiv").fadeOut("fast");
		});	
	
		$("#navi ul li").mouseenter(function(){
			$(this).children().children().fadeIn("fast");
		});
	
		$("#navi ul li").mouseleave(function(){
			$(this).children().children().fadeOut("fast", function(){$(".active").show();});
		});
	}
		
	//Alle Standard-Browser
	else{
		$("#balken").delay(2000).animate({height:'15px'},{queue:true, duration:200, easing: 'easeOutQuart'});
		$("#open").show();
		$(".aktiv").delay(1800).fadeOut("fast");
		
		$("#balken").mouseenter(function(){
        	$(this).stop().animate({height:'220px'},{queue:false, duration:200, easing: 'easeInQuart', complete: function(){$(".aktiv").fadeIn("fast");}});
			$("#open").stop().hide();
			
    	});	
		
		$("#balken").mouseleave(function(){
        	$(this).stop().delay(600).animate({height:'15px'},{queue:true, duration:200, easing: 'easeOutQuart', complete: function(){$(".aktiv").fadeOut("fast");}});	
			$("#open").stop().show();
		});	
		
		$("#navi ul li").mouseenter(function(){
			$(this).children().children().fadeIn("fast");
		});
		
		$("#navi ul li").mouseleave(function(){
			$(this).children().children().fadeOut("fast", function(){$(".active").show();});
			
		});
	// Navigation Ende	
	};
	
	
	// Scroll Effekt für Beitragsseiten
	//ausblenden für Endgeräte
	
	
	
	
	if(mobile){
		$(".scrollable").scrollable();
	}
	else if(tablet){
		//nix
	}
	else{			
		$('#bildbox').serialScroll({
			items:'img',
			prev:'#scrollTo-links',
			next:'#scrollTo-rechts',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:1200,
			force:true,
			stop:true,
			lock:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart', //use this easing equation for a funny effect
		});
		$('.archiv-wrap').serialScroll({
			target:'.slider-wrap',
			items:'img',
			prev:'.archiv-zurueck',
			next:'.archiv-weiter',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:1200,
			force:true,
			stop:true,
			lock:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart', //use this easing equation for a funny effect
		});	
	}
	
	$("table.toggle").click(function(){
		$(".archiv-wrap").slideUp("middle");
		$(this).next().slideToggle("middle");
	});
	
	// Balkenfarbe erkennen und für iPhone BG nutzen
	var balkenfarbe = $('#balken').css('background-color');
	if(mobile){
		$('body').css('background-color', balkenfarbe);
		}
	
	
	// Anpassung des Textfelds der Colorbox
	$("a[rel]").colorbox({current: "Bild {current} von {total}"});
	
	
	// Overlay für Magazinübersicht
	if(mobile){
		$(".magazin").click(function(){
            	$(".overlay").hide();
				$(this).children().show();
        	});
	}
	else if(tablet){
		$(".magazin").click(function(){
            	$(".overlay").hide();
				$(this).children().show();
        	});
		}
	else{
		$(".magazin").mouseover(function(){
            $(this).children().show();
        });
        
        $(".magazin").mouseout(function(){
            $(".overlay").hide();
    	});
		}
	
	
// Ende JQuery
});

// Preloader ausblenden
	$(window).load(function(){
		$('.preloader').hide();
		$('#ipad-pfeil').delay(1500).fadeOut(600);
	});
