Originally written by Sujit Pal (http://sujitpal.blogspot.com/2007/02/three-autocomplete-implementations.html), I have made some minor changes to the code and added documentation.