jQuery plugin

Converted the code to work as a jquery plugin