Moved JS code to a separate file.