var univers = { src: 'js/univers.swf' };
sIFR.activate(univers);

sIFR.replace(univers, {
	selector: '#content h1',
	css: '.sIFR-root {color: #000000; background-color:#ffffff; text-transform:uppercase; font-size:28px;}',
	wmode: 'transparent'
});
sIFR.replace(univers, {
	selector: '#content h2',
	css: '.sIFR-root {color: #000000; background-color:#ffffff; text-transform:uppercase; font-size:16px;}',
	wmode: 'transparent'
});
	
$(document).ready(function(){
	
	if($('#tabs').length > 0){
		$('#tabs').tabs();
	}
	
	$('.right a.apply').click(function(){
		$('#tabs').tabs("option", "selected", 3);
		$(this).hide();
		return false;
	});
	
	$('#tabs li a').click(function(){
		if(!$(this).hasClass('bewerbung')){
			$('.right a.apply').show();
		}else{
			$('.right a.apply').hide();
		}
		
	});
	
	/*
	 * Funktion bei "Warum re-lounge": Weiter
	 */
	
	$("#content a.next").click(function(){
		var visibleElement = null;
		var nextElement = null;
		
		$(this).blur();
		
		$("#content a.prev").removeClass('inactive');
		
		if($(this).attr('class') != "next inactive"){
			$('.flippingContent div').each(function(){
				if ($(this).hasClass('visible')) {
					//console.info($(this).attr('class'));
					visibleElement = $(this);
					nextElement = $(this).next();
					return;
				}	
			});
			if (nextElement.length != 0) {
				
				visibleElement.fadeOut('slow');
				window.setTimeout(function(){
					nextElement.fadeIn('slow');
					
					visibleElement.attr('class', 'hide');
					nextElement.attr('class', 'visible');
					
					sIFR.replace(univers, {
						selector: '#content h2',
						css: '.sIFR-root {color: #000000; text-transform:uppercase; font-size:16px;}',
						wmode: 'transparent'
					});
				}, 600);
				
				if(nextElement.next().length == 0)
					$(this).addClass('inactive');
			}
		}
		
		return false;
	});
	/****************************************************************************************************/
	
	/*
	 * Funktion bei "Warum re-lounge": Zurück
	 */
	
	$("#content a.prev").click(function(){
		var visibleElement = null;
		var prevElement = null;
		
		$(this).blur();
		
		$("#content a.next").removeClass('inactive');
		
		if($(this).attr('class') != "prev inactive"){
			$('.flippingContent div').each(function(){
				if ($(this).hasClass('visible')) {
					visibleElement = $(this);
					prevElement = $(this).prev();
					return;
				}	
			});
			if (prevElement.length != 0) {
				
				visibleElement.fadeOut('slow');
				window.setTimeout(function(){
					prevElement.fadeIn('slow');
					
					visibleElement.attr('class', 'hide');
					prevElement.attr('class', 'visible');
					
					sIFR.replace(univers, {
						selector: '#content h1',
						css: '.sIFR-root {color: #000000; text-transform:uppercase; font-size:20px;}',
						wmode: 'transparent'
					});
				}, 600);
				
				if(prevElement.prev().length == 0)
					$(this).addClass('inactive');
			}
		}
		
		return false;
	});
	/****************************************************************************************************/
	
	/*
	 * Initialisierung: falls die Fenstergröße zu klein für den Inhalt ist, soll keine 
	 * dynamisch vertikale zentrierung stattfinden
	 */
	
	if($(window).height() + 28 <= $("#site").height()){
		$("#site").css("top",0);
		$("#site").css("margin-top","-14px");
	}else{
		$("#site").css("top","50%");
		$("#site").css("margin-top","-343px");
	}
	
	/****************************************************************************************************/
	
	/*
	 * Initialisierung: falls die Fenstergröße zu klein für den Inhalt ist, soll keine 
	 * dynamisch vertikale zentrierung stattfinden
	 */
	
	$("#flashstage.loader").css('background','url(media/loader.gif) center center no-repeat');
	/*window.setTimeout(function(){
		$("#flashstage.loader").css('background','none');
	}, 3000);*/
	
	
	
    /**
     * Addthis SocialPlugin (2-Klick-Button)
     */
    $("li.share").hover(
    		function(){
    	        var timeout_id = window.setTimeout(function(){ $('li.share').append('<div class="addthis_infobox"><div class="text">Aus Datenschutzgr&uuml;nden m&uuml;ssen Sie das Social-Plugin mit einem Klick aktivieren. Dabei werden ggf. Daten an Dritte &uuml;bertragen.</div></div>'); }, 100);
    	        $(this).data('li.share', timeout_id);
    	    },
    	    function(){
    	        window.setTimeout(function(){ $('li.share div.addthis_infobox').remove(); }, 400);
    	    }
	);
	
	$('li.share').click(function(){
		$('li.share div.addthis_infobox').remove();
		$.addthis('xa-4ae5928742594b1d');
	});
});

$(window).resize(function(){
	//console.info($(window).height());
	if($(window).height() + 28 <= $("#site").height()){
		$("#site").css("top",0);
		$("#site").css("margin-top","-14px");
	}else{
		$("#site").css("top","50%");
		$("#site").css("margin-top","-343px");
	}
});

function removeLoader(){
	$("#flashstage.loader").css('background','none');
}

