

var side_gallery = {

    setup: function(id) {
        var div = app.get('side_gallery_' + id);
        var imgs = div.getElementsByTagName('img');
        for (var i = 0; i < imgs.length; i++) {
            side_gallery.add_caption(imgs[i], div);
        }
        return true;
    },
    add_caption: function(img, div) {
        img.dataCaption     = img.getAttribute('data-caption');
        img.dataDescription = img.getAttribute('data-description');
        img.removeAttribute('data-caption');
        img.removeAttribute('data-description');
        /* Note: Standard caption function allows for only one caption. For side gallery, need multiple captions. */
        var capt = caption.apply(img, false);
        if (!capt) return true;

        // http://stackoverflow.com/questions/5702187/distance-pixels-from-an-img-to-the-bottom-of-the-containing-div
        var bottom = (div.offsetHeight) - (img.offsetTop + img.offsetHeight);
        capt.style.bottom = bottom + 'px';
    }
};

