$(document).ready(function() {

	// Bildunterschriften nicht breiter als das Bild laufen lassen
	$('div.image').each(function() {
		w = $(this).find('img').width();
		if (w) $(this).find('div.caption').css('width', w + 'px');
	});

	$('.bildarchiv p').each(function() {
		var maxHeight = 0;
		$(this).find('div.caption').each(function() {
			if ($(this).height() > maxHeight) maxHeight = $(this).height();
		});
		$(this).find('div.caption').height(maxHeight);
	});
	
	
	// Video-Links in FLV-Player umbauen
	$("a.video, a.audio").click(function() {
		var wasActive = $(this).hasClass('active');

		$('div.video').remove();
		$("a.video, a.audio").removeClass('active');

		if (wasActive) return false;

		$(this).addClass('active');
		var mode = $(this).attr('class').match(/ lq /) ? 'LQ' : 'HQ';
		$(this).parents('p').after('<div class="video"><div id="player">player</div></div>'); 

		if ($(this).hasClass('audio')) $('div.video').css({position: 'absolute', left: '-9999px'});

		var FO = { 
			movie: "/static/common/mediaplayer.swf", /* TODO: WFD_STATIC_COMMON einbauen */
			width: (mode == 'LQ' ? "320" : "768"),
			height: (mode == 'LQ' ? "200" : "432"),
			majorversion: "7",
			build: "0",
			bgcolor: "#FFFFFF", 
			flashvars: "file=" + encodeURI($(this).attr('href')) + "&autostart=true"
		};
		UFO.create(FO,"player");

		return false;
	});
	
	// Extranet-Navigation: Oberpunkte hervorheben
	$('#subnav.extranet > ul > li').addClass('subnav-title');
	$('#subnav.extranet > ul').addClass('level-1');
});
