Further code clean up and added metric capture

Moved all event handlers to the controller
Switched all buttons to jqueryui buttons
Implemented the visit level metric capture