
// image pool
function showImageHeader(link){
    $('#imgheader').fadeOut(300, function(){
        $(this).attr({style: "background-image:url("+link+");"});
        $(this).fadeIn(300);
     });
}

function loadImagepool(div){
    if(ImagepoolLoaded == false){
    ImagepoolLoaded=true;
        $.ajax({
           type: "GET",
           url: "/ajax/utils/media/index/",
           data: "obj_ids="+obj_ids,
           success: function(msg){
              $('.tabimg .img').animate({
                      height: 437+"px"
              }, 400);
               $('.tabimg .img').fadeIn("slow");
               target = div.find('.fotosvideos');
               target.hide();
               target.html(msg);
               target.fadeIn(400);

                $('#imagepool a.vorige').hide();
                $('#imagepool a.vorige').click(function(event){
                        event.preventDefault();
                        num_page = $(this).parent().attr('title');
                        num_page++;
                        $(this).parent().attr('title',num_page);
                        slide(num_page,$(this));
                });
                $('#imagepool a.volgende').click(function(event){
                        event.preventDefault();
                        num_page = $(this).parent().attr('title');
                        num_page--;
                        $(this).parent().attr('title',num_page);
                        slide(num_page,$(this));
                });
                
                $('#videopool a.vorige').hide();
                $('#videopool a.vorige').click(function(event){
                        event.preventDefault();
                        num_page = $(this).parent().attr('title');
                        num_page++;
                        $(this).parent().attr('title',num_page);
                        slide(num_page,$(this));
                });
                $('#videopool a.volgende').click(function(event){
                        event.preventDefault();
                        num_page = $(this).parent().attr('title');
                        num_page--;
                        $(this).parent().attr('title',num_page);
                        slide(num_page,$(this));
                });
           }
         });
     }
}

function checkImagePoolLength(){
   if($('#imagepool ul.list li.float_left').length < 5){
      $('#imagepool a.volgende').hide();
   }
   if($('#videopool ul.list li.float_left').length < 5){
      $('#videopool a.volgende').hide();
   }
}

function slide(page,div){
    setButtons(page,div);
    position = page*imageWidth;
    div.parent().find('ul.list').animate({left:position+"px"},200);
}

function setButtons(page,div){
    position = page*imageWidth;
    if(page == 0){
        div.parent().find('a.vorige').hide();
        div.parent().find('a.volgende').show();
    }
    else if(position <=  (div.parent().find('ul.list').width()-5*imageWidth)*-1){
        div.parent().find('a.volgende').hide();
       div.parent().find('a.vorige').show();
    }else {
       div.parent().find('a.vorige').show();
        div.parent().find('a.volgende').show();
    }
}
