var EKMA_PhotoGallery = function(ArrImages, ContainerID, ObjStr){
    this.arr_images = ArrImages; // resim dizisini tutar
    this.container_id = ContainerID;
    this.objStr = ObjStr; //bu class için tanımlanmış olan nesne
    
    this.previous = null; //önceki resim
    this.next = null; //sonraki resim
    this.shown = null; //şu anki resim
    
    
    this.loadBigImage = function(Shown, Key){
        if(!empty(Shown)){
            Shown = parseInt(Shown);
            
            this.shown = Shown;
            this.previous = Shown-1;
            this.next = Shown+1;
        }
        else if(!empty(Key)){
            var i;
            
            for(i in this.arr_images){
                i = parseInt(i);
                
                if(this.arr_images[i].spid == Key){
                    this.shown = i;
                    this.previous = i-1;
                    this.next = i+1;
                    break;
                }
            }
        }
        else{
            this.shown = 0;
            this.previous = null;
            this.next = 1;
        }
        
        var _show_prevNextSep_cntr = 0;
        
        if(this.shown == 0){
            $('.ekma_photogallery_previousbutton_cont').hide();
        }
        else{
            $('.ekma_photogallery_previousbutton_cont').show();
            
            _show_prevNextSep_cntr++;
        }
        
        if(this.shown == $(this.arr_images).length-1){
            $('.ekma_photogallery_nextbutton_cont').hide();
        }
        else{
            $('.ekma_photogallery_nextbutton_cont').show();
            
            _show_prevNextSep_cntr++;
        }
        
        if(_show_prevNextSep_cntr == 2){
            $('.ekma_photogallery_prev_next_sep').show();
        }
        else{
            $('.ekma_photogallery_prev_next_sep').hide();
        }
        
        if(typeof(this.arr_images[this.shown]) == 'object' && !empty(this.arr_images[this.shown])){
            var next_img_html = '<img src="' + this.arr_images[this.shown].img_big + '" title="' + this.arr_images[this.shown].title + '" alt="' + this.arr_images[this.shown].title + '"';
    
            if(typeof(this.arr_images[this.next]) == 'object' && !empty(this.arr_images[this.next])){//sonraki resim varsa
                //sonraki resmi önbelleğe at
                $('#' + this.container_id + ' .ekma_photogallery_cache_next').eq(0).html('<img src="' + this.arr_images[this.next].img_big + '"');
            
                var next_click = this.objStr + '.loadBigImage(\'' +this.next+ '\'); document.location.href=document.location.href.replace(/#.*/,\'\') + \'#' +this.arr_images[this.next].spid+ '\';';
                
                next_img_html += ' onclick="' +next_click+ '"';
                
                $('#' + this.container_id + ' .ekma_photogallery_nextbutton').eq(0).unbind('click').click(function(){
                    eval(next_click);
                    return false;
                });
    
                
            }//end if (sonraki resim varsa)
            
            if(typeof(this.arr_images[this.previous]) == 'object' && !empty(this.arr_images[this.previous])){//sonraki resim varsa
                //önceki resmi önbelleğe at
                $('#' + this.container_id + ' .ekma_photogallery_cache_prev').eq(0).html('<img src="' + this.arr_images[this.previous].img_big + '"');
            
                var prev_click = this.objStr + '.loadBigImage(\'' +this.previous+ '\'); document.location.href=document.location.href.replace(/#.*/,\'\') + \'#' +this.arr_images[this.previous].spid+ '\';';
                
                
                $('#' + this.container_id + ' .ekma_photogallery_previousbutton').eq(0).unbind('click').click(function(){
                    eval(prev_click);
                    return false;
                });
    
                
            }//end if (sonraki resim varsa)
            
            
            
            next_img_html += '>';
            
            $('#' + this.container_id + ' .ekma_photogallery_big_img_container .ekma_photogallery_big_img').eq(0).html(next_img_html);
            
            document.location.href=document.location.href.replace(/#.*/,'') + '#' +this.arr_images[this.shown].spid;
            
            $('#' + this.container_id + ' .ekma_photogallery_big_img_container .ekma_photogallery_big_img_title').eq(0).html(this.arr_images[this.shown].title);
            //$('#' + this.container_id + ' .ekma_photogallery_big_img_container .ekma_photogallery_big_img_id').eq(0).html(this.arr_images[this.shown].img_calc_id);
            
            if(!empty(this.arr_images[this.shown].date)){
                $('#' + this.container_id + ' .ekma_photogallery_big_img_container .ekma_photogallery_big_img_date').eq(0).html(this.arr_images[this.shown].date);
            }
            
            $('#' + this.container_id + ' .ekma_photogallery_big_img_container .ekma_photogallery_big_img_note').eq(0).html(this.arr_images[this.shown].note);
        }
        /*
        else{
            $('#' + this.container_id + ' .ekma_photogallery_big_img_container').eq(0).css('display','none');
        }*/
    }//end method loadBigImage()
}//end class EKMA_PhotoGallery

