refactored js to function as a jquery plugin

Resolves issue #2 by using jquery plugin architecture.  Eliminates global variables.