Convert to a jQuery plugin

...but in a way that will allow us to stop depending on jQuery at any
time.