(function() {
    var Y = NB.Lib;
    
    NB.MarsPress.ImageGalleryTeaser = function() {
        NB.MarsPress.ImageGalleryTeaser.superclass.constructor.apply(this, arguments);
        
        this.gallery = new NB.MarsPress.ImageGallery({
            images : this.get("images")
        });
        
        this.gallery.render(this.get("element").one(".footer-teaser-bd"));
        this.gallery.on("imageClick", this.onImageClick, this);
        
        this.imageLayer = null;
    };
    
    NB.MarsPress.ImageGalleryTeaser.NAME = "imageGalleryTeaser";
    NB.MarsPress.ImageGalleryTeaser.ATTRS = {
        galleryData : {
            value : [],
            setter : function(value) {
                if(!this.gallery)
                {
                    return value;
                }
                this.gallery.set("images", value.images);
                return value;
            }
        },
        element : {
            value : null
        },
        langData : {
            value : null
        }
        
    };
    
    Y.extend(NB.MarsPress.ImageGalleryTeaser, Y.Base, {
        getImageLayer : function() {
            if(this.imageLayer === null)
            {
                this.imageLayer = new NB.MarsPress.ImageLayer({
                    categoriesData : [this.get("galleryData")],
                    langData : this.get("langData")
                });
            }
            
            return this.imageLayer;
        },
        onImageClick : function(e) {
            var imageLayer = this.getImageLayer();
            imageLayer.set("categoryId", 0);
            imageLayer.set("imageId", e.image.id);
            imageLayer.show({
                xy : imageLayer.getCenterXy(),
                from : this.get("element")
            });
        }
    });
    
    
})();
