var teaserIndex = null;
var numTeasers;

function scrollTeaser() {
    teasers = $('#teaser .items .item');
    if (teaserIndex == null) {
        numTeasers = teasers.length;
        teaserIndex = numTeasers - 1;
        teasers.each(function (index) {
            if (index != teaserIndex) {
                $(this).hide();
            }
        });
    }
    var next = teaserIndex + 1;
    if (next == numTeasers) {
        next = 0;
    }
    $('#teaser .items .item').eq(teaserIndex).fadeOut("slow");
    $('#teaser .items .item').eq(next).fadeIn("slow");
    teaserIndex = next;

}


$(function() {
    $('#navigation .section > a').mouseenter(function() {
        $('#navigation .section ul').fadeOut('fast');
        $(this).parent().find('ul').fadeIn('fast');
    });

    $('#container').mouseleave(function() {
        $('#navigation .section ul').fadeOut('fast');
    });

    $('#teaser').each(function() {
        if ($(this).find('.item').length < 2)
            return;
        setInterval('scrollTeaser()', 5000);
    });
});


