// JavaScript Document

$(window).load(function() {
	//Menüpunkt aktiv-Animation--------------------------------------------------------------------------------------
	$("a#aktiv").animate({
		backgroundPosition: '0px 2px'
	});
});

$(document).ready(function() {	
	//Impressum
	$('#impressum').css('display','none');
	$('a.implnk').click(function(){
		if($('#impressum').css('display') == 'none'){
			$('#impressum').slideDown();
		} else {
			$('#impressum').slideUp();
		}		
	});

	//Menüpunkt aktiv - Vorbereitung für Animation--------------------------------------------------------------------	
	$("a#aktiv").css('backgroundPosition', '-66px 2px');

	//Gefälltmit-Ani--------------------------------------------------------------------------------------------------
	$("a.facebook img").mouseover(function() {
		$(this).animate({
			width: 90,
			height: 24
		},150 );
	});
	
	$("a.facebook img").mouseout(function() {
		$(this).animate({
			width: 75,
			height: 20
		},150 );
	});
	
	//Menüpunktanimation-----------------------------------------------------------------------------------------------
	$("#menu > ul > li > a[id!='aktiv']").mouseover(function() {
		$(this).stop();
		$(this).animate({
			paddingLeft: '75px'
		},100 );
	});
	
	$("#menu > ul > li > a[id!='aktiv']").mouseout(function() {
		$(this).stop();
		$(this).animate({
			paddingLeft: '60px'
		},100 );
	});

	//Logo/Home-Animation-----------------------------------------------------------------------------------------------	
	$("#logo a").mouseover(function() {
		$("#logo").stop();
		$("#logo > a > img").stop();
		$("#logo > a > img").animate({
			opacity: 0
		}, 150, function() {
		    $('#logo').animate({
				backgroundPosition: '70px 10px'
			}, 150 );
		});
	});
	
	$("#logo a").mouseout(function() {
		$("#logo").stop();
		$("#logo > a > img").stop();
		$("#logo").animate({
			backgroundPosition: '70px -60px'
		}, 150, function() {
		    $('#logo > a > img').animate({
				opacity: 1
			}, 150 );
		});
	});
	
	//Newshighlighting-------------------------------------------------------------------------------------------------
	$('#news div.news a').mouseover(function() {
		$(this).parents('.news').stop().animate({
			backgroundPosition: '0px 0px'
		}, 150 );
	});
	
	//Newshighlighting-------------------------------------------------------------------------------------------------
	$('#news div.news a').mouseout(function() {
		$(this).parents('.news').delay(250).stop().animate({
			backgroundPosition: '-230px 0px'
		}, 150 );
	});
	
	$('div.text div.news a').mouseover(function() {
		$(this).parents('.news').stop().animate({
			backgroundPosition: '0px 0px'
		}, 100 );
	});
	
	//Newshighlighting-------------------------------------------------------------------------------------------------
	$('div.text div.news a').mouseout(function() {
		$(this).parents('.news').delay(250).stop().animate({
			backgroundPosition: '-665px 0px'
		}, 100 );
	});
	
	//Fancybox für Referenzen------------------------------------------------------------------------------------------		
	$("a.fnc").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'width'			: 710,
		'height'		: '90%',
		'type'			: 'iframe'
	});
	
	$("a.fncw").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'width'			: 1000,
		'height'		: '90%',
		'type'			: 'iframe'
	});
	
	$("a.fnce").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'width'			: 650,
		'height'		: '90%',
		'type'			: 'iframe'
	});
		
	//Referenzübersicht------------------------------------------------------------------------------------------
	$(".refbox > .reftext > a").mouseover(function() {
		ide = $(this).attr('rel');
		$('#'+ ide +' > .refimage > a > img').animate({
			marginTop: 0,
			marginBottom: 5,
		    width: 206,
			height: 159
		}, 150, function() {
		    // Animation complete.
		});
	});
	
	$(".refbox > .reftext > a").mouseout(function() {
		ide = $(this).attr('rel');
		$('#'+ ide +' > .refimage > a > img').animate({
			marginTop: 11,
			marginBottom: 11,
		    width: 184,
			height: 142
		}, 150, function() {
		    // Animation complete.
		});
	});
	
	$(".refbox > .refimage img").mouseover(function() {
		$(this).animate({
			marginTop: 0,
		    width: 206,
			height: 159
		}, 150, function() {
		    // Animation complete.
		});
	});
	
	$(".refbox > .refimage img").mouseout(function() {
		$(this).animate({
			marginTop: 11,
		    width: 184,
			height: 142
		}, 150, function() {
		    // Animation complete.
		});
	});
	
	//Referenzfilter--------------------------------------------------------------------------------------
	$('a.filter').each(function(){
		$(this).click(function(){
			kat = $(this).attr('rel');
			$('a.filter').removeClass('aktiv');
			$(this).addClass('aktiv');
			$('div.refbox').css('display','none');
			$('div.'+kat).each(function(index) {
				$(this).removeClass('last');
				if((index % 3) == 2){
					$(this).addClass('last');	
				}
    			$(this).delay(index*100).fadeIn();
			});				
		});		
	});
});	
