updated javascript function for loading book