added events and jquery global function