$(document).ready(function(){
	var bg_bachelor = $('#content-bachelor').css('background-image');
	var bg_master = $('#content-master').css('background-image');
	var bg_wismar = $('#content-wismar').css('background-image');
	var bg_international = $('#content-international').css('background-image');
	$('#content-master').css('background-image', 'none');
	$('#content-wismar').css('background-image', 'none');
	$('#content-international').css('background-image', 'none');
	$("a.video-link").overlay({ effect: 'apple', top: '15%',  
					expose: { 
						color: '#ccc', 
						loadSpeed: 200, 
						opacity: 0.75
					},
					onBeforeClose: function(){
						document.getElementById("flash").SetVariable("player:jsStop", "");
					}
					});
	
	//�ffnen und Schlie�en des Accordions im Header-Bereich
	$('#content h2').toggle(function(){ 
         
        }, function () { 
         
    }); 
 
    $('#content h2').click(function(){
		var parent = $(this).parent('div.content-accordion').attr('id');
		$('#' + parent + ' h2').removeClass('active');
		
		$(this).addClass('active');
		$('#content h2').next('div.pane').removeClass('open');
		$(this).next('div.pane').addClass('open');
        $(this).next('div.pane').slideToggle('slow', function(){
			if( $(this).css('display') == 'none' ){
				$(this).prev('h2').removeClass('active');
			}
		});
		$('#content h2').next('div.pane:not(.open)').slideUp();
    }); 
	
	//BACHELOR
	$('#navi-cats-bachelor').click(function(){
		if( $('#content-bachelor-accordion').hasClass('inactive') ){
			var bFadeIn = true;
			$(this).addClass('active');
			$('#content-bachelor').css('background', bg_bachelor);
			$('#content-master').css('background-image', 'none');
			$('#content-wismar').css('background-image', 'none');
			$('#content-international').css('background-image', 'none');
			$('#content-welcome-accordion').fadeOut('fast');
		} else {
			var bFadeIn = false;
			$(this).removeClass('active');
			$('#content-bachelor').css('background', bg_bachelor);
			$('#content-master').css('background-image', 'none');
			$('#content-wismar').css('background-image', 'none');
			$('#content-international').css('background-image', 'none');
			//$('#content-welcome-accordion').fadeIn('fast');
		}
		if( $("div.content-accordion:not(.inactive)").length == 0 ){
			$("#content-bachelor-accordion").fadeIn('fast', function(){
				$("#content-bachelor-accordion").removeClass('inactive');
				$("#content-bachelor-accordion").tabs("#content-bachelor-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});														   
			})
		};
		$('#navi-cats-master').removeClass('active');
		$('#navi-cats-wismar').removeClass('active');
		$('#navi-cats-international').removeClass('active');
		$("div.content-accordion:not(.inactive)").fadeOut('fast', function(){
			$("#content-wismar-accordion").addClass('inactive');
			$("#content-master-accordion").addClass('inactive');
			$("#content-bachelor-accordion").addClass('inactive');
			$("#content-welcome-accordion").addClass('inactive');
			$("#content-international-accordion").addClass('inactive');
			if(bFadeIn == true){
				$("#content-bachelor-accordion").fadeIn('fast', function(){
					$("#content-bachelor-accordion").removeClass('inactive');
					$("#content-bachelor-accordion").tabs("#content-bachelor-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});														   
				})
			}
		})
	});
	
	//MASTER
	$('#navi-cats-master').click(function(){
		if( $('#content-master-accordion').hasClass('inactive') ){
			var bFadeIn = true;
			$(this).addClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-master').css('background-image', bg_master);
			$('#content-wismar').css('background-image', 'none');
			$('#content-international').css('background-image', 'none');
			$('#content-welcome-accordion').fadeOut('fast');
		} else {
			var bFadeIn = false;
			$(this).removeClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-master').css('background-image', bg_master);
			$('#content-wismar').css('background-image', 'none');
			$('#content-international').css('background-image', 'none');
			//$('#content-welcome-accordion').fadeIn('fast');
		}
		if( $("div.content-accordion:not(.inactive)").length == 0 && bFadeIn == true){
			$("#content-master-accordion").fadeIn('fast', function(){
				$("#content-master-accordion").removeClass('inactive');
				$("#content-master-accordion").tabs("#content-master-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});	
			})
		};
		
		$('#navi-cats-bachelor').removeClass('active');
		$('#navi-cats-wismar').removeClass('active');
		$('#navi-cats-international').removeClass('active');
		$("div.content-accordion:not(.inactive)").fadeOut('fast', function(){
			$("#content-welcome-accordion").addClass('inactive');
			$("#content-wismar-accordion").addClass('inactive');
			$("#content-bachelor-accordion").addClass('inactive');
			$("#content-master-accordion").addClass('inactive');
			$("#content-international-accordion").addClass('inactive');
			if(bFadeIn == true){
				$("#content-master-accordion").fadeIn('fast', function(){
					$("#content-master-accordion").removeClass('inactive');
					$("#content-master-accordion").tabs("#content-master-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});
				})
			}
		})
	});
	
	
	//INTERNATIONAL
	$('#navi-cats-international').click(function(){
		if( $('#content-international-accordion').hasClass('inactive') ){
			var bFadeIn = true;
			$(this).addClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-international').css('background-image', bg_international);
			$('#content-wismar').css('background-image', 'none');
			$('#content-welcome-accordion').fadeOut('fast');
		} else {
			var bFadeIn = false;
			$(this).removeClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-international').css('background-image', bg_international);
			$('#content-wismar').css('background-image', 'none');
			//$('#content-welcome-accordion').fadeIn('fast');
		}
		if( $("div.content-accordion:not(.inactive)").length == 0 && bFadeIn == true){
			$("#content-international-accordion").fadeIn('fast', function(){
				$("#content-international-accordion").removeClass('inactive');
				$("#content-international-accordion").tabs("#content-international-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});	
			})
		};
		
		$('#navi-cats-bachelor').removeClass('active');
		$('#navi-cats-wismar').removeClass('active');
		$('#navi-cats-master').removeClass('active');
		$("div.content-accordion:not(.inactive)").fadeOut('fast', function(){
			$("#content-welcome-accordion").addClass('inactive');
			$("#content-wismar-accordion").addClass('inactive');
			$("#content-bachelor-accordion").addClass('inactive');
			$("#content-master-accordion").addClass('inactive');
			$("#content-international-accordion").addClass('inactive');
			if(bFadeIn == true){
				$("#content-international-accordion").fadeIn('fast', function(){
					$("#content-international-accordion").removeClass('inactive');
					$("#content-international-accordion").tabs("#content-international-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: null});
				})
			}
		})
	});
	
	
	
	//WISMAR
	$('#navi-cats-wismar').click(function(event, otherIndex){
		
		if( $('#content-wismar-accordion').hasClass('inactive') ){
			var bFadeIn = true;
			$(this).addClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-master').css('background-image', 'none');
			$('#content-wismar').css('background-image', bg_wismar);
			$('#content-international').css('background-image', 'none');
			$('#content-welcome-accordion').fadeOut('fast');
		} else {
			var bFadeIn = false;
			$(this).removeClass('active');
			$('#content-bachelor').css('background', 'none');
			$('#content-master').css('background-image', 'none');
			$('#content-wismar').css('background-image', bg_wismar);
			$('#content-international').css('background-image', 'none');
			//$('#content-welcome-accordion').fadeIn('fast');
		}								  
		if( $("div.content-accordion:not(.inactive)").length == 0 ){
			$("#content-wismar-accordion").fadeIn('fast', function(){
				$("#content-wismar-accordion").removeClass('inactive');
				$("#content-wismar-accordion").tabs("#content-wismar-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: 0});														   
			})
		};								  
		$('#navi-cats-bachelor').removeClass('active');
		$('#navi-cats-master').removeClass('active');
		$('#navi-cats-international').removeClass('active');
		$("div.content-accordion:not(.inactive)").fadeOut('fast', function(){
			$("#content-welcome-accordion").addClass('inactive');
			$("#content-master-accordion").addClass('inactive');
			$("#content-bachelor-accordion").addClass('inactive');
			$("#content-wismar-accordion").addClass('inactive');
			$("#content-international-accordion").addClass('inactive');
			if(bFadeIn == true){
				$("#content-wismar-accordion").fadeIn('fast', function(){
					$("#content-wismar-accordion").removeClass('inactive');
					
					$("#content-wismar-accordion").tabs("#content-wismar-accordion div.pane", {tabs: 'h2', effect: 'slide', current: 'active', initialIndex: 0});														   					if(otherIndex == true && !$('#content h2#accordion-bewerbung-top').hasClass('active') ){
						$('#content h2#accordion-bewerbung-top').trigger('click');
					}
				})
			}
		})
		
		
	});
	
	//Bewerbung Link
	$('a.bewerbung').click(function(){
		$('#navi-cats-wismar').trigger('click', true);
	})
	
	//Bachelor Link
	$('#content-welcome-accordion a.bachelor').click(function(){
		$('#navi-cats-bachelor').trigger('click', true);
	})
	
	//Master Link
	$('#content-welcome-accordion a.master').click(function(){
		$('#navi-cats-master').trigger('click', true);
	})
	
	//�ffnen und Schlie�en des Accordions im Footer-Bereich
	$('#footer h4').toggle(function(){ 
         
        }, function () { 
         
    });
 
    $('#footer h4').click(function(){
		
		var parent = $(this).parent('div.footer-accordion').attr('id');
		
		$('#' + parent + ' h4').removeClass('current');
		$(this).addClass('current');
		
        $(this).next('div.footer-accordion-text').slideToggle('normal', function(){
			if( $(this).css('display') == 'none' ){
				$(this).prev('h4').removeClass('current');
			}
		});
		$('#' + parent + ' h4').next('div.footer-accordion-text').removeClass('open');
		$(this).next('div.footer-accordion-text').addClass('open');
		$('#' + parent + ' h4').next('div.footer-accordion-text:not(.open)').slideUp();

    });
	
	//ALUMNI Accordion
	$("#footer-alumni-accordion").tabs("#footer-alumni-accordion div.footer-accordion-text", {tabs: 'h4', effect: 'slide', current: 'active', initialIndex: null});	
	
	//FORSCHUNG Accordion
	$("#footer-forschung-accordion").tabs("#footer-forschung-accordion div.footer-accordion-text", {tabs: 'h4', effect: 'slide', current: 'active', initialIndex: null});
	
	//SERVICE Accordion
	$("#footer-service-accordion").tabs("#footer-service-accordion div.footer-accordion-text", {tabs: 'h4', effect: 'slide', current: 'active', initialIndex: null});
	
	
	//Logo Event
	$('#logo').click(function(){
		$('#navi-cats li.active').trigger('click', true);
		$('li').removeClass('active');
		$('div').removeClass('active');
		$('#content-welcome-accordion').fadeIn('fast');
		
	})
	
})
