/* menu */
(function($) {
    jQuery.extend(jQuery.expr[':'], {
        focus: function(e) { return e == document.activeElement; }
    });
    $(function() {
        //check for js functionality
        $('html').removeClass('no-js');
        $('html').addClass('js');

        // Vertical menu
        $(".content_menu .arrow_link ").click(function(e) {
            var element = $(this).parents(".content_menu_link");
            var elements = element.parents('.content_menu').find('li.content_menu_link');

            element.find('.gradient').slideToggle(function() {

                if ($(this).css('display') == 'block') {
                    element.addClass('active');
                } else {
                    element.removeClass('active');
                }
            });
        })


        //timeline
        if (!$(".scrollable_years").length == 0) {

            $(".scrollable_years").scrollable();
            if ($(".scrollable_years li").length < 8) {
                $('.timeline a.prev, .timeline a.next').addClass('disabled');
            }

            var active = $('.scrollable_years li.active');
            var index = $(".scrollable_years li").index(active);
            var page = parseInt((index + 1) / 7, 10);
            $(".scrollable_years").scrollable().move(page);

        }


        // Show/Hide search area 
        $("#search").hover(function(mouse_enter) {
            var input_box = $(this).find('#searcharea');
            input_box.show();
        },
            function(mouse_leave) {
                var input_box = $(this).find('#searcharea');
                window.setTimeout(function() {
                    if (!$(input_box).is(":focus")) {
                        input_box.hide();
                    }
                }, 3000)
            })

        $("#container").click(function(e) {
            var input_box = $("#searcharea:visible");
            if (!$(input_box).is(":focus")) {
                input_box.hide();
            }
        })

        $('#searcharea').focus(function() {
            $(this).val('');
        });

        //hovereffect for boardlist
        $(".article").hover(function() { //On hover

            var thumbOver = $(this).find("img").attr("src");
            $(this).find("a.board_list").css({ 'background': 'url(' + thumbOver + ') no-repeat left bottom' });
            $(this).find("a>span").stop().fadeTo('normal', 0, function() {
                $(this).hide()
            });
        }, function() { //on hover out
            $(this).find("a>span").stop().fadeTo('normal', 1).show();
        });

    });
})(jQuery)
