refactored javascript - better file names and less ajax calls