
var Pager = Class.create();

Pager.prototype = {
	
	initialize: function() {
		this.itensPerPage = 10;
		this.currentPage = 0;
	},
	
	getItensPerPage: function() {
		return this.itensPerPage;
	},
	
	setItensPerPage: function(itensPerPage) {
		this.itensPerPage = itensPerPage;	
	},
	
	setPreviousButton: function(button) {
		this.previousButton = button;	
	},
	
	setNextButton: function(button) {
		this.nextButton = button;	
	},
			
	setTotalItens: function(totalItens) {
		this.totalItens = totalItens;
	},
	
	setTotalPages: function() {
		this.totalPages = Math.ceil(this.totalItens/this.itensPerPage);
	},
	
	setNextPage: function() {
		this.currentPage++;
	},
	
	setPreviousPage: function() {
		this.currentPage--;
	},
	
	hideItens: function(list) {
		for(i=(this.currentPage*this.itensPerPage); i<((this.currentPage+1)*this.itensPerPage); i++) {
			if(i<this.totalItens)
				list[i].style.display="none";
		}
	},
	
	showItens: function(list) {
		//percorre itens
		for(i=(this.currentPage*this.itensPerPage); i<((this.currentPage+1)*this.itensPerPage); i++) {
			if(i<this.totalItens)
				list[i].style.display="block";
		}
		
		if(this.currentPage==0)
			this.previousButton.style.display = "none";
		else
			this.previousButton.style.display = "block";
		if(this.currentPage+1>=this.totalPages)
			this.nextButton.style.display = "none";
		else
			this.nextButton.style.display = "block";
		
	}
	
}

var pagerList = new Pager();