

var gallery = {

    setup: function() {
        var img = app.get('gallery-large');
        if (img != null) {
            img.dataCaption = img.getAttribute('data-caption');
            img.dataDescription = img.getAttribute('data-description');
            img.removeAttribute('data-caption');
            img.removeAttribute('data-description');
            return caption.apply(img, true);
        }
    },
    display: function (el) {
        var g = app.get('gallery');
        var v = app.get('gallery-large');
        var l = g.getElementsByTagName('img');
        for (var i = 1; i < l.length; i++) {
            if (el == l[i]) {
                l[i].className = 'active';
            } else {
                l[i].className = '';
            }
        }
        var src = '';
        src = el.src.replace('.small.', '.large.');
        src = src.replace('.small-reverse.', '.large-reverse.');
        v.src   = src;
        v.alt   = el.alt;
        v.title = el.title;
        v.dataCaption = el.getAttribute('data-caption');
        v.dataDescription = el.getAttribute('data-description');
        return caption.apply(v, true);
    }
};

app.onload(gallery.setup);


