converted to jQuery plugin, cleanup