refactored so JS in separate files

refactored so JS in separate files, removed redundant code
refactored so JS in separate files

refactored so JS in separate files, removed redundant code
cleanup

cleanup