

function PaginatorManager(){
    
    // Nombre total de pages
    this.pageCount = -1;
    // Première page de la fenêtre dynamique
    this.startPage = -1;
    // Dernière page de la fenêtre dynamique
    this.endPage = -1;
    // prefixe de l'id des éléments de paginations existants
    this.id_prefixe = '';
    // Taille de la fenêtre dynamique
    this.pageGroup = -1;
    
    this.applyState = function(){
        if(this.startPage > 1){
            $(this.id_prefixe + '_first').style.display = 'inline';
            $(this.id_prefixe + '_previous').style.display = 'inline';
        }
        else{
            $(this.id_prefixe + '_first').style.display = 'none';
            $(this.id_prefixe + '_previous').style.display = 'none';
        }
        
        for(i = 1; i <= this.pageCount; i++){
            if(i >= this.startPage && i <= this.endPage){
                $(this.id_prefixe + '_' + i).style.display = 'inline';
            }
            else{
                $(this.id_prefixe + '_' + i).style.display = 'none';
            }
        }
        
        if(this.endPage < this.pageCount){
            $(this.id_prefixe + '_next').style.display = 'inline';
            $(this.id_prefixe + '_last').style.display = 'inline';
        }
        else{
            $(this.id_prefixe + '_next').style.display = 'none';
            $(this.id_prefixe + '_last').style.display = 'none';
        }
    }
    
    this.firstPageClick = function(){
        this.startPage = 1;
        this.endPage = this.startPage + this.pageGroup -1;
        this.applyState();
        return false;
    }
    
    this.previousPageClick = function(){
        if(this.startPage > this.pageGroup){
            this.startPage = this.startPage - this.pageGroup;
            this.endPage = this.startPage + this.pageGroup - 1;
            this.applyState();
        }
        return false;
    }
    
    this.nextPageClick = function(){
        if(this.endPage < this.pageCount){
            this.startPage = this.startPage + this.pageGroup;
            this.endPage = this.startPage + this.pageGroup - 1;
            this.applyState();
        }
        return false;
    }
    
    this.lastPageClick = function(){
        if((this.startPage + this.pageGroup) <= this.pageCount){
            this.startPage = Math.floor(this.pageCount / this.pageGroup) * this.pageGroup + 1;
            this.endPage = this.pageCount;
            this.applyState();
        }
        return false;
    }
    
}