jQuery Plugin

Formatted the JavaScript to run as a jQuery plugin.