var MixedMediaGallery = new JS.Class({
    initialize: function(display, thumbs) {
        this._current = 0;
        this._display = Ojay(display);
        
        thumbs        = Ojay(thumbs);
        this._thumbs  = thumbs.map(function(thumb, index) {
            var thumbnailImage = new this.klass.ThumbnailImage(thumb);
            
            thumb.on('click', function(link, evnt) {
                evnt.stopDefault();
                
                if (index == this._current) return;
                
                this._image.set({
                    alt: thumbnailImage.getAltText(),
                    src: thumbnailImage.getLink()
                });
                
                this._current = index;
            }, this);
            
            return thumbnailImage;
        }, this);
        
        this._image   = Ojay(Ojay.HTML.img({
            alt: this._thumbs[this._current].getAltText(),
            src: this._thumbs[this._current].getLink()
        }));
        
        if (this._thumbs.length < 2)
            thumbs.hide();
        
        this._display.setContent(this._image);
    },
    
    extend: {
        ThumbnailImage: new JS.Class({
           initialize: function(thumb) {
               this._link = Ojay(thumb);
               this._href = this._link.node.href;
               this._img  = this._link.children('img');
               this._alt  = this._img.node.alt;
           },
           
           getLink: function() {
               return this._href;
           },
           
           getAltText: function() {
               return this._alt;
           }
        }),
        
        ThumbnailVideo: new JS.Class({
            initialize: function() {
                // ...
            }
        })
    }
});

