
function slideSwitch() {
    var $active = $('#slideshow IMG.aktiv');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');


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

    $next.css({opacity: 0.0})
        .addClass('aktiv')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('aktiv last-aktiv');
        }); 
    /*$('#slideshow_container > #slide_title').css('margin-top', $next.attr('offsetHeight') + 20 + 'px');*/
    $('#meinSlideshow > #slideshow_container').css('margin-left', -parseInt($next.attr('offsetWidth')/2) + 'px');
    $('#meinSlideshow > #slideshow_container').css('margin-top', -parseInt($next.attr('offsetHeight')/2)+ 'px');
}

$(function() {
    //var w = $('#slideshow > img.aktiv').attr('offsetWidth');
    //var h = $('#slideshow > img.aktiv').attr('offsetHeight');
    //$('#meinSlideshow > #slideshow_container').css('margin-left', -parseInt(w/2) + 'px');
    //$('#meinSlideshow > #slideshow_container').css('margin-top', -parseInt(h/2)+ 'px');
    /*$('#slideshow_container > #slide_title').css('margin-top', $('#slideshow > img.aktiv').attr('offsetHeight') + 10 + 'px');*/

    var heighest = 0;
     $( '#slideshow > img ' ).each ( function () {
         if ( this.offsetHeight > heighest) {
             heighest = this.offsetHeight;
         }
     } ) ;
     $( '#slideshow_container > .stretch' ).css( 'height', (heighest + 10) + 'px' );

    setInterval( "slideSwitch()", 5000 );
});
 

