$(function() {
    var prev = $('#portfolio-sterowanie #prv');
    var next = $('#portfolio-sterowanie #nxt');
    var tabs = $('#portfolio li');
    var current = 0;
    var size = tabs.size();
    prev.hide();
    var i;

    for (i = 1; i < size; i++) {
        $(tabs[i]).hide();
    }

    var showControls = function () {
        var prev_control = current > 0;
        var next_control = current < (size - 1);
        if (prev_control) {
            prev.show();
        } else {
            prev.hide();
        }
        if (next_control) {
            next.show();
        } else {
            next.hide();
        }
    }

    var showNext = function () {
        $(tabs[current]).hide();
        current++;
        showControls();
        $(tabs[current]).show();
    };

    var showPrev = function () {
        $(tabs[current]).hide();
        current--;
        showControls();
        $(tabs[current]).show();
    }

    prev.click(function () {
        showPrev();
        return false;
    })

    next.click(function() {
        showNext()
        return false;
    });

    showControls();
});
