function toggleTabs(t1, t2, t3) {
    if (t1) {
        $('#moduleNowosci').show();
        $('#moduleNowosci + .pagination').show();
        $('#tabs_nowosci').addClass('active');
        $('#cat_menu a').each(function(){
            $(this).attr('href', $(this).attr('href').split("#")[0] + '#1');
        });
    }
    else {
        $('#moduleNowosci').hide();
        $('#moduleNowosci + .pagination').hide();
        $('#tabs_nowosci').removeClass('active');
    }
    if (t2) {
        $('#modulePopularne').show();
        $('#modulePopularne + .pagination').show();
        $('#tabs_popularne').addClass('active');
        $('#cat_menu a').each(function(){
            $(this).attr('href', $(this).attr('href').split("#")[0] + '#2');
        });
    }
    else {
        $('#modulePopularne').hide();
        $('#modulePopularne + .pagination').hide();
        $('#tabs_popularne').removeClass('active');
    }
    if (t3) {
        $('#moduleMaterialy').show();
        $('#moduleMaterialy + .pagination').show();
        $('#tabs_materialy').addClass('active');
        $('#cat_menu a').each(function(){
            $(this).attr('href', $(this).attr('href').split("#")[0] + '#3');
        });
    }
    else {
        $('#moduleMaterialy').hide();
        $('#moduleMaterialy + .pagination').hide();
        $('#tabs_materialy').removeClass('active');
    }
}

$(document).ready(function() {
    $('#tabs_nowosci a').click(function(){
        toggleTabs(true, false, false)
    });
    $('#tabs_popularne a').click(function(){
        toggleTabs(false, true, false)
    });
    $('#tabs_materialy a').click(function(){
        toggleTabs(false, false, true)
    });

//    $('.droplist').width($('.droplist .options_wrapper').width()+26);
//    $('.droplist .option').hover(function() {
//        $('.droplist .selected').text($(this).text());
//    }, function() {});
//    $('.droplist .options_wrapper').hover(function() {}, function() {
//        $('.droplist .options_wrapper').hide();
//    });
//    $('.droplist').click(function() {
//        $('.droplist .options_wrapper').toggle();
//    });

    $('#moduleNowosci + .pagination a').each(function() {
        $(this).attr('href', $(this).attr('href').split("#")[0] + '#1');
    });
    $('#modulePopularne + .pagination a').each(function() {
        $(this).attr('href', $(this).attr('href').split("#")[0] + '#2');
    });
    $('#moduleMaterialy + .pagination a').each(function() {
        $(this).attr('href', $(this).attr('href').split("#")[0] + '#3');
    });


    if(document.location.hash == "#1") toggleTabs(true, false, false);
    else if(document.location.hash == "#2") toggleTabs(false, true, false);
    else if(document.location.hash == "#3") toggleTabs(false, false, true);

});
