$(document).ready(function() {
	// Akkordeon-Navigation
	var title = document.title;
	var match = 0;
	var hash_substr = window.location.hash.substr(1);
	if (hash_substr != '') {
		$('#accordeon > div').each(function(i) {
			if (hash_substr == $(this).attr('id')) {
				match = i;
			}
		});
	}
    $('#accordeon > div:not(' + (match != 0 ? ':eq(' + match + ')' : ':first') + ')').hide();

	$('#accordeon').prepend('<div id="accordeon-glossary"><ul></ul></div>');
	$('#accordeon > div > h2').each(function() {
		$('#accordeon-glossary ul').append('<li><a href="#' + $(this).parent('div').attr('id') + '"><span>&raquo;</span> ' + $(this).html() + '</a></li>');
	});

	$('#accordeon-glossary').show();

	$('#accordeon-glossary').hover(function() {
		if (!$('#accordeon-glossary > *').is(':animated') && !$('#accordeon-glossary *').is(':visible')) {
			$('#accordeon-glossary > *').fadeIn();
		}
	}, function() {
		$('#accordeon-glossary > *').fadeOut();
	});

	$('#accordeon-glossary a').click(function(e) {
		var hash = this.hash;
		document.title = title + ' :: ' + $('#accordeon > div' + hash + ' > h2').text();
		$('#accordeon-glossary a').removeClass('selected');
		$(this).addClass('selected');

		if (!$('#accordeon > div' + hash).is(':visible')) {
			$('#accordeon > div:not(#accordeon-glossary):visible').hide();
			$('#accordeon-glossary ul').fadeOut('fast');
			$('#accordeon > div' + hash).fadeIn('slow');
		}
		e.preventDefault();
	}).filter(':eq(' + match + ')').click();

	// Partnerlinks
	$('.partner li a').css({ opacity: 0.75 });
	$('.partner li a').hover(function() {
		$(this).stop().animate({ opacity: 1 }, 'slow');
	}, function() {
		$(this).stop().animate({ opacity: 0.75 }, 'slow');
	});
});
