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)
Merge remote-tracking branch 'bdragon28/advanced_inventory_fixes' into FrankenMod

Conflicts:
	src/advanced_inv.cpp

Wow! That file was a mess.