        ZONTIK.Class.create("ZONTIK.Controls.Nicebox", ZONTIK.Controls.Control, 
                function(config) {
                    var thisContext = this;
                    this.photos = config.photos;
                    this.caption = config.caption;
                    $(document).ready(function(){
                      thisContext.initialize();
                    });
                }, 
                {
                    items : [],
                    current: 0,
                    randId: 0,
                    
                    getHtml: function() {
                        var html =  "<div class='Nicebox' id='Nice" + this.randId + "'>";
                        html +=         "<div class='NiceboxContents'>";
                        html +=             "<div class='NiceboxTitle'>";
                        html +=                 "<div class='NiceboxCaption'></div>";
                        html +=                 "<img src='/images/overlay.close.gif' class='NiceClose' onClick='" + ZONTIK.Delegate.createAsString(this, this.hide) + "'>";
                        html +=                 "<div class='Clear'></div>";
                        html +=             "</div>";
                        html +=             "<a onClick='" + ZONTIK.Delegate.createAsString(this, this.next) + "'><img src='/images/gallery.next.gif' class='NiceboxNext'></a>";
                        html +=             "<a onClick='" + ZONTIK.Delegate.createAsString(this, this.previous) + "'><img src='/images/gallery.previous.gif' class='NiceboxPrevious'></a>";
                        html +=             "<div class='NiceboxImage'></div>";
                        html +=             "<div class='Clear'></div>";
                        html +=         "</div>";
                        html +=         "<div class='Clear'></div>";
                        html +=     "</div>";
                        return html;
                    },
                    
                    hide: function() {
                        $("#Nice" + this.randId).remove();
                    },
                    
                    initialize: function() {
                        this.randId = Math.floor(Math.random()*100000 + 1);
                    },
                    
                    launch: function() {
                        $(".Nicebox").remove();
                        $('html, body').animate({scrollTop: 95}, 'fast'); 
                        $("body").prepend(this.getHtml());
                        this.setImage(0);
                    },
                    
                    next: function() {
                        if (this.current+1 < this.photos.length) {
                            this.current++;
                            this.setImage(this.current);
                        } else {
                            this.current = 0;
                            this.setImage(this.current);
                        }
                    },
                    
                    previous: function() {
                        if (this.current > 0) {
                            this.current--;
                            this.setImage(this.current);
                        } else {
                            this.current = (this.photos.length-1);
                            this.setImage(this.current);
                        }
                    },
                    
                    setImage: function(id) {
                        $("#Nice" + this.randId+ " .NiceboxCaption").html(this.caption);
                        $("#Nice" + this.randId+ " .NiceboxImage").html("<img src='" + this.photos[id] + "' width='560'>");
                    }
                }
            );