$(document).ready(function() {
    $('.gallery a').lightBox();
    $('.small-gallery a').lightBox();
    $('.show-small-gallery').click(function(){
        var $bigGallery = $(this).parent().find('.popup-gallery');
        //$bigGallery.show();
        popup.setContent($bigGallery.html());
        popup.open();
        $('.closeButton').show();
        $('.gallery a').lightBox();
        return false;
    });
    popup.close();
});
    
var popup = {
    content: '',
    $popup: false,
    setContent: function(content) {
        this.content = content;
        return this;
    },
    open: function() {
        this.getJObject().html(this.content);
        this.getJObject().css('width', '600px');
        this.getJObject().css('left', screen.availWidth/2-300+'px');
        this.getJObject().css('display', 'block');
        this.getJObject().find('.closeButton').click(function(){
            popup.getJObject().hide();
            
            return false;
        });
    },
    close: function() {
//        $('.closeButton').hide();
        this.getJObject().css('display', 'none');
    },
    getJObject: function() {
        this.setPopup();
        return this.$popup;
    },
    setPopup: function() {
        if(!this.$popup) {
            this.$popup = $('#popup');
        }
    }
};
