Moved most javascript functions from JSP to JS file.