Made script into a jQuery plugin