Add javascript functions and events