$(document).ready(function(){
  if (document.getElementById("pageslisttable")!=null)
  {
  $('#arrow_left').removeAttr('href');
  $('#arrow_left').removeClass('arrow_left_novisible');
  $('#arrow_right').removeClass('arrow_right_novisible');
  $('#arrow_right').removeAttr('href');
  arr=window.location.pathname.split('/');
  current_page=parseInt(arr[arr.length-2].replace('page_',''));
  pages=document.getElementById('pageslisttable').clientWidth;
  $('#pagelist').animate({scrollLeft:current_page*27-145+"px"},0);
    
  $('#arrow_left').mouseover(function(){
    $('#arrow_left').addClass('arrowleftfast');
    $('#pagelist').animate({scrollLeft:"0px"},(document.getElementById('pagelist').scrollLeft)*20,"linear");
  }).mouseout(function(){
    $('#arrow_left').removeClass('arrowleftfast');//css({background:"url('/images/design/arrowleft.gif') center center no-repeat"});
    $('#pagelist').stop();
  }).mousedown(function(){
    $('#pagelist').stop();
    $('#pagelist').animate({scrollLeft:"0px"},(document.getElementById('pagelist').scrollLeft)*3,function(){
        $('#arrow_left').trigger('mouseover');
    });
    return false;
  }).mouseup(function(){
    $('#pagelist').stop();
        $('#arrow_left').trigger('mouseover');
    return false;
  }).click(function(){
    $('#pagelist').stop();
    $('#pagelist').animate({scrollLeft:document.getElementById('pagelist').scrollLeft-100+'px'},500,"linear",function(){
        $('#arrow_left').trigger('mouseover');
    });
    return false;
  });;
  
  $('#arrow_right').mouseover(function(){
    $('#arrow_right').addClass('arrowrightfast');
    $('#pagelist').animate({scrollLeft:pages},(pages-document.getElementById('pagelist').scrollLeft)*20,"linear");
  }).mouseout(function(){
    $('#arrow_right').removeClass('arrowrightfast');//css({background:"url('/images/design/arrowright.gif') center center no-repeat"});
    $('#pagelist').stop();
  }).mousedown(function(){
    $('#pagelist').stop();
        $('#pagelist').animate({scrollLeft:pages},(pages-document.getElementById('pagelist').scrollLeft)*3,function(){
        $('#arrow_right').trigger('mouseover');
    });
    return false;
  }).mouseup(function(){
    $('#pagelist').stop();
        $('#arrow_right').trigger('mouseover');
    return false;
  }).click(function(){
    $('#pagelist').stop();
    $('#pagelist').animate({scrollLeft:document.getElementById('pagelist').scrollLeft+100+'px'},500,"linear",function(){
        $('#arrow_right').trigger('mouseover');
    });
    return false;
  });
;
  }
});