var sliderId = 1;
var sliderTimer = 0;
var sliderCount = 0;


$(document).ready(function() {
    $('ul.menu_main').supersubs({ minWidth: 12, maxWidth: 18, extraWidth:  1, delay:1200}).superfish({
        delay:       1200,                            // one second delay on mouseout
        dropShadows: true                            // disable drop shadows
    });

    var timeoutHome = 0;
    var intervalHome = 0;
    currentHomeTeaser = 1;
    sliderCount = $('#fadeBlock div.rotator_item').length;
    for (var i = 2; i <= sliderCount; i++) {
        $('#slider_home_top_' + i).hide();
    }
    sliderTimer = setTimeout(switchToNext, 5000);
});
function switchToNext() {
    var prevId = sliderId;
    sliderId ++;
    if (sliderId > sliderCount) sliderId = 1;
    switchTo(sliderId);
    sliderTimer = setTimeout(switchToNext, 5000);
}
function switchTo(id) {
    $active = $('#fadeBlock div.active');
    if ($active.length == 0) {
        $active = $('#fadeBlock div:first').next();
    }
    $next = $('#slider_home_top_' + id);
    if ($active.attr('id') == 'home_banner_' + id) return false;
    $('.slider_home_top_above').fadeIn(777,
            function() {
                $active.hide();
                $next.show();
                $('.slider_home_top_above').fadeOut(777);
            });
    $active.removeClass('active');
    $next.addClass('active');
    $('.navi_slider_home .thumb').removeClass('active');
    $('.navi_slider_home .thumb[rel=' + id + ']').addClass('active');
    return false;
}























