To make the previous and next buttons disabled on the first page and last page, add these callbacks inside the load engine function before viewer init:

viewer.callback.Register("PostPageChange", hidePrevNext);
viewer.callback.Register("PostViewerInit", hidePrevNext);

add this function after the load engine function:

function hidePrevNext()
{
  if (RVViewers[0].DisplayMode == "double")
  {
  if (RVKernel.features.StartDPS == true && (RVViewers[0].pages.current_page == 0 || RVViewers[0].pages.current_page == 1))
  {
  $('#toolbar_prev_btn').css('display', 'none');
  $('#toolbar_next_btn').css('display', 'block');
  }
  else if (RVKernel.features.StartDPS == false && RVViewers[0].pages.current_page == 0)
  {
  $('#toolbar_prev_btn').css('display', 'none');
  $('#toolbar_next_btn').css('display', 'block');
  $('#leftpage').html(zeropage);
  }
  if ((RVKernel.features.StartDPS == true) && (RVViewers[0].pages.current_page == RVViewers[0].pages.count) && (RVViewers[0].pages.count % 2 == 0))
  {
  $('#toolbar_next_btn').css('display', 'none');
  $('#toolbar_prev_btn').css('display', 'block');
  }
  else if((RVKernel.features.StartDPS == true) && (RVViewers[0].pages.current_page == RVViewers[0].pages.count) && (RVViewers[0].pages.count % 2 != 0))   
  {
  $('#toolbar_next_btn').css('display', 'none');
  $('#toolbar_prev_btn').css('display', 'block');
  $('#topDiv #BackpageContent').html(backpage);
  }
  if(RVViewers[0].pages.current_page > 1 && RVViewers[0].pages.current_page < RVViewers[0].pages.count)
  {
  $('#toolbar_prev_btn').css('display', 'block');
  $('#toolbar_next_btn').css('display', 'block');
  resizetoolbar();
  }
   
   
  }
  else if (RVViewers[0].DisplayMode == "single")
  {
  if (RVViewers[0].pages.current_page == 1)
  {
  $('#toolbar_prev_btn').css('display', 'none');
  $('#toolbar_next_btn').css('display', 'block');
  }
  else if (RVViewers[0].pages.current_page == RVViewers[0].pages.count)
  {
  $('#toolbar_next_btn').css('display', 'none');
  $('#toolbar_prev_btn').css({'top': RVKernel.coords.winh / 2, 'display': 'block'})
  }
  else
  {
  $('#toolbar_prev_btn').css('display', 'block');
  $('#toolbar_next_btn').css('display', 'block');
  resizetoolbar();
  }
  }

};

This handles single and double viewers.