jQuery plugin to manage events