changed to use jquery and comply with jshint & jslint