Break typeahead code out of fixed page and into functions for general usage