/* Truss */
function trussSwitch() {
    var $active = $('#truss img.active');
 
    if ( $active.length == 0 ) $active = $('#truss img:last');
 
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#truss img:first'); 
 
    $active.addClass('last-active');
 
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
}

/* Fotoblock */
function fotoblockSwitch() {
    var $active = $('#foto_repeat img.active');
 
    if ( $active.length == 0 ) $active = $('#foto_repeat img:last');
 
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#foto_repeat img:first'); 
 
    $active.addClass('last-active');
 
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
}
 
$(function() {
    setInterval( "trussSwitch()", 4000 );
    setInterval( "fotoblockSwitch()", 4000 );
});

