moved function creation to jQuery plugin ininitialization, and the rest to the init function. Also updated some event triggering