/**
 * Created by VITAS on 09.03.2016.
 */


$( document ).ready(function() {

    //toggel usermenu
    $('.user_head').click(function(){

        if($('.usermenu_container').is(':visible')){
            $('.usermenu_container').hide();
        }else{
            $('.usermenu_container').show();
            $('.mainmenu_container').hide();
        }
    });

    $('.usermenu_container ul li').click(function(){
        $('.usermenu_container').hide();
    });

    //toggel main menu
    $('.mainmenu_btn').click(function(){

        if($('.mainmenu_container').is(':visible')){
            $('.mainmenu_container').hide();
        }else{
            $('.mainmenu_container').show();
            $('.usermenu_container').hide();
        }
    });

    $('.mainmenu_container ul li').click(function(){
        $('.mainmenu_container').hide();
    });

    //toggel tables
    $('.modlist_toggel li').click(function(){
        if(!$(this).hasClass('table_toggel_active')){
            $(this).parent('ul').children('li').removeClass('table_toggel_active');
            var pane = $(this).attr('id');
            $(this).addClass('table_toggel_active');
            $(this).parent('ul').parent('div').children('.table_toggel_entrys').hide();
            $('.' + pane + '_entrys').show();
        }


    });

    //slideshow for featured container
    var featureid = 0;
    function cyclefav() {
        $('.featured_top_container').children('div').hide();
        if($('.featured_top_container').children('div').length <= featureid){
            featureid=1;
        }else{
            featureid++;
        }
        var featureobj = $('.featured_container[data-featured="' + featureid + '"]');
        $('.featured_top_container').attr({"style":"background-image: url('" + $(featureobj).attr('data-image') + "');"});
        $('.feature_link').attr({"href":$(featureobj).attr('data-link')})
        $('.featured_container[data-featured="' + featureid + '"]').show();
        setTimeout(cyclefav, 2000);
    }
    //background: url('http://i.imgur.com/faNHVj0.jpg')no-repeat fixed top;
    cyclefav();

});
