Originated from https://code.google.com/p/fencevbox/ with a few bug fixes