clean up indentation to be consistent
AJAX events should be attached to document (compatibility with jQuery 1.9.1)
http://jquery.com/upgrade-guide/1.9/#ajax-events-should-be-attached-to-document