Moved the event handlers of basic XUL events to a single function