$(document).ready(function() {
	// ---
	
	// ueberschrift homepage: gleiche hoehe
  var hoehemax = 0;
	$('.beschreibung h3').each(function(){
		var hoehe = $(this).height();
		if (hoehe > hoehemax) {
			hoehemax = hoehe;
		}
		if (hoehemax < 10) {
			hoehemax = 10;
		}
  });
	$('.beschreibung h3').css('height',hoehemax);
											
	// beschreibung homepage: gleiche hoehe
  var hoehemax = 0;
	$('.beschreibung').each(function(){
		var hoehe = $(this).height();
		if (hoehe > hoehemax) {
			hoehemax = hoehe;
		}
		if (hoehemax < 10) {
			hoehemax = 10;
		}
  });
	$('.beschreibung').css('height',hoehemax);
	
	// zitat homepage : vertikal zentrieren
	$('body.uid1 .zitat-2').each(function(){
		var neu = (244 - $(this).height()) / 2 - 5;
		$(this).css('padding-top', neu);
	});
	
	// navigation: maximal einzeilig
	var a = jQuery('#menu > ul > li > a');
	var aFontSizeOld = parseInt(a.css('font-size'));
	var aFontSizeNew = aFontSizeOld;
	var aFontSizeMin = 13;
	
	for (aFontSizeNew; aFontSizeNew > aFontSizeMin; aFontSizeNew--) {
		var aMaxHeight = 0;
		a.each(function(){
			if($(this).innerHeight() > aMaxHeight) {
				aMaxHeight = $(this).innerHeight();
			}
		});
		if(aMaxHeight < 50) {
			break;
		}
		a.css('font-size', aFontSizeNew);
	}


	/* --- headerslideshow by bua --- */
	if($('#headerimages').children().length > 1) {
		$(function() {
				slideInterval = setInterval( "slideSwitch()", 5000
	);
		});
	}
	/* --- /headerslideshow by bua --- */


	// ---
});


/* --- headerslideshow by bua --- */
function slideSwitch() {	
    var $active = $('#headerimages IMG.active');

    if ( $active.length == 0 ) $active = $('#headerimages IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#headerimages IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });	
}
/* --- /headerslideshow by bua --- */
