Transformed into a jQuery plugin. Plus a regression fixed.