Remake applications.js

Used delegations to make form creation more robust. Also changes the format of the data returned from the form from a nested hash to a hash. Includes corresponding changes to the form submit controller.