Based on http://ejohn.org/apps/livesearch/