Fix for broken navigation in the autocomplete popup

jQuery's .index() method may have been used incorrectly. It now uses a
more reliable technique.