    $(document).ready(function() {
        //hide all list items, and show the first 5 items
        $('#items li').hide().slice(0, 4).show();
        //hide the up button
        $('#up').hide();

        var length = $('#items li').length;
        var current_page = 0;
        var per_page = 4;

        $(".arrow").click(function(){
         var arrow = $(this).attr("id"); 
         if(arrow == 'down') {
          current_page = current_page + 1; //increment the page
          if (length >= current_page*per_page) { //check if it's possible page
           $('#items li').hide().slice((current_page*per_page), (current_page*per_page+per_page)).fadeIn(); //show the next page
          }
         } 
         else if(arrow == 'up') {
          current_page = current_page - 1; //decrement the page  
          if (current_page >= 0) { //check if it's possible page
           $('#items li').hide().slice((current_page*per_page), (current_page*per_page+per_page)).fadeIn(); //show the prev page
          }
         }
         //check if the down button will be still shown or hidden
          if (length >= (current_page+1)*per_page) $('#down').show();
          else $('#down').hide();
         //check if the up button will be still shown or hidden
          if ((current_page-1) >= 0) $('#up').show();
          else $('#up').hide();
        });
    });
