thumbnails.js: add documentation; organize code in function add().