move the JS to jQuery plugin. fix a minor bug.
Merge pull request #1 from ShawTim/master

move the JS to jQuery plugin. fix a minor bug.