better function structure on custom.js
added automatic coloring of captions