Turned code into an actual jquery plugin