some logical and scope changes made on javascript; changed HTML canvas error message