Moved some js functions to new js file.