function Page(count, container, prev, next, sortStrategy){
 	this.per_page = count;
 	this.page = 0;
 	this.nav_prev = prev;
 	this.nav_next = next;
 	this.tbody = container;
 	this.last_page = Math.ceil(this.tbody.children('tr').length / this.per_page) - 1;
 	this.sortStrategy = sortStrategy;
 };

 Page.prototype.init = function() {
 	this.reorder_rows();
 	this.update_navigators();
 	this.nav_prev.bind('click', {page: this}, function(e){ e.data.page.previous(); return false; });
 	this.nav_next.bind('click', {page: this}, function(e){ e.data.page.next(); return false; });
 };

 Page.prototype.reorder_rows = function() {
 	var ordered = new Array();
 	this.tbody.children('tr').each(function(index){
 		var price = Number($(this).find('td.price').text().replace(/[A-Z]{3}(\s?)/, ''));
 		var city = $(this).find('.location').text();
 		ordered.push([this, {price: price, city: city}]);
 	});

 	ordered.sort(this.sortStrategy);

 	this.tbody.empty();

 	for (var i=0; i < ordered.length; i++) {
 		this.tbody.append(ordered[i][0]);
 	};
 };

 Page.prototype.next = function(){
 	if(this.page == this.last_page){
 		this.update_navigators();
 		return false;
 	}

 	this.page++;
 	this.refresh();
 	this.update_navigators();
 };

 Page.prototype.previous = function(){
 	if(this.page == 0){
 		this.update_navigators();
 		return false;
 	}

 	this.page--;
 	this.refresh();
 	this.update_navigators();
 };

 Page.prototype.update_navigators = function() {
 	this.enable_navigator(this.nav_prev);
 	this.enable_navigator(this.nav_next);

 	if(this.page == 0)
 		this.disable_navigator(this.nav_prev);

 	if(this.page == this.last_page)
 		this.disable_navigator(this.nav_next);
 };

 Page.prototype.enable_navigator = function(link_ref) {
 	link_ref.css('color', '#07519A');
 };

 Page.prototype.disable_navigator = function(link_ref) {
 	link_ref.css('color', '#333333');
 };

 Page.prototype.refresh = function(){
 	this.tbody.find('tr').hide();
 	var start = (this.page * this.per_page);
 	var end = start + this.per_page;

 	for (var i = start; i < end; i++) {
 		this.tbody.find('tr:eq(' + i + ')').show();
 	};
 };

 function paginate(pp, container, prev, next, sortStrategy){
 	p = new Page(pp, container, prev, next, sortStrategy);
 	p.init();
 	p.refresh();
 	return p;
 }