function ImageViewer(){};

ImageViewer.prototype.visible = false;
ImageViewer.prototype.url = '';
ImageViewer.prototype.title = '';
ImageViewer.prototype.idDivInside = 'imageViewerInside';
ImageViewer.prototype.idDivAll = 'imageViewer';
ImageViewer.prototype.containerId = '';

ImageViewer.prototype.show = function(){
    var inside = '<div class="left">';
    if(this.title != ''){
        this.title = 'Zdjęcie';
    }
    inside += '<div class="photoTitle">' + this.title + '</div>';


    if(isDefined('imageViewerContainer') && this.containerId !== ''){
        for(i in imageViewerContainer){
            if(i == parseInt(this.containerId)){
                var iPrev = parseInt(i)-1;
                var iNext = parseInt(i)+1;
            }
        }
        if(iPrev < 0){
            iPrev = imageViewerContainer.length - 1;
        }
        if(iNext > imageViewerContainer.length - 1){
            iNext = 0;
        }
        inside += '<div class="photoNavigation"><span class="button" onclick="imageViewerContainer[' + iPrev + '].click();">poprzednie</span>&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;<span class="button" onclick="imageViewerContainer[' + iNext + '].click();">następne</span></div><div class="defaultSpacer"></div>';
    }
    inside += '</div>';
    inside += '<div class="right"><img  src="' + imageUrl+ 'image_viewer_close.gif" class="close" /></div><div class="clear"></div>';
    inside += '<img class="img button" onclick="imageViewerContainer[' + iNext + '].click();" src="' + this.url+ '" />';
    this.visible = true;
   $('#' + this.idDivAll).show();
   $('.image', '#' + this.idDivInside).html(inside);
   $('#' + this.idDivInside).show();
   
    $('#imageViewerInside > .image > .right > .close').click(function(){
       Viewer.close();
    });
   
}

ImageViewer.prototype.close = function(){
    var inside = '... trwa ładowanie ...';
    this.visible = false;
   $('#' + this.idDivAll).hide();
   $('#' + this.idDivInside).hide();
   $('.image', '#' + this.idDivInside).html(inside);
}


