Debugging advanced inventory.

Add some bulletproofing to advanced inventory index handling, fixes various ways that the selection could be on an invalid item.

Also, treat paging like up and down when in category selection mode.
(Mostly detected by -D_GLIBCXX_DEBUG)