var topMenuColor = new Object();
topMenuColor[0] = '#305a93';
topMenuColor[1] = '#c86a05';
topMenuColor[2] = '#ac06bb';
topMenuColor[3] = '#008f14';
topMenuColor[4] = '#c3053b';
topMenuColor[5] = '#c86a05';
topMenuColor[6] = '#305a93';

var topMenuBackground = new Object();
topMenuBackground[0] = '#AEDFFF';
topMenuBackground[1] = '#F9E3B2';
topMenuBackground[2] = '#F5CEFD';
topMenuBackground[3] = '#C2FCC2';
topMenuBackground[4] = '#ffdbea';
topMenuBackground[5] = '#F9E3B2';
topMenuBackground[6] = '#AEDFFF';

var topMenuPosition = new Object();
topMenuPosition[0] = '0px';
topMenuPosition[1] = '-30px';
topMenuPosition[2] = '-60px';
topMenuPosition[3] = '-90px';
topMenuPosition[4] = '-120px';
topMenuPosition[5] = '-30px';
topMenuPosition[6] = '0px';


$(function(){
    $('#top-menu > li').hover(
        function(){
            var indexItemMenu = $(this).index();
            $(this).css('background', "url('/bitrix/templates/main/images/menu-items.jpg') center "+topMenuPosition[indexItemMenu]+" no-repeat");
        },
        function(){
            $(this).css('background-image', 'none');
        }
    );

    $('#top-menu > li').mouseover(function(){
        var indexItemMenu = $(this).index();
        $("#top-menu > li").removeClass("selected");
        $("#top-menu > li").children('a').css('color', topMenuColor[0]);

        $(this).addClass("selected");
        $(this).children('a').css('color', topMenuColor[indexItemMenu]);


        $("#top-submenu").empty();        
        $(this).children("ul")
            .children("li")
            .clone()
            .appendTo("#top-submenu");

        $("#top-submenu").css('background', topMenuBackground[indexItemMenu]).corner("5px");
    });
    
    showCarouselItem(0);
});


function showCarouselItem(i) {
    var length = $('.carousel-item').length;

    if(i >= length) n = 0;
    else if (i < 0) n = length + i;
    else n = i;
    $('#carousel').data('i', n);


    $('.carousel-item').eq(n).fadeIn('slow', function(){
        setTimeout(function() {
            /*$('.carousel-item').eq(n).fadeOut('fast', function(){
                showCarouselItem($('#carousel').data('i') + 1);
            });*/
            $('.carousel-item').eq(n).fadeOut('slow');
            showCarouselItem($('#carousel').data('i') + 1);
        }, 8000);
    });
}



