function PaginatedGallery(elem, page, width)
{
	this.gallery = elem;
	
	this.scroller = this.gallery.select('.pagination_scroller')[0];
	this.pagination_window = $(this.gallery).select('.pagination_window')[0];
	this.curPage = page;
	this.pageWidth = width;
	this.maxPage = $(this.gallery).select('.pagination_page').length;

	this.MoveGallery = function(page) 
	{
		if(page > this.maxPage)
			page = 1;
			
		if(page < 1)
			page = this.maxPage;			
		
		var pos = -1 * ((this.pageWidth * page) - (this.pageWidth));
		//this.scroller.setStyle({ left: '-' + pos + 'px' });
		new Effect.Move(this.scroller, { x: pos, y: 0, mode: 'absolute' });

		this.curPage = page;
		
		gallery.select('.pagination_page').invoke('removeClassName', 'selected');
		$(gallery.select('.pagination_page')[page-1]).addClassName('selected');
	}
	
	this.NextPage = function()
	{
		var page = curPage + 1;
		MoveGallery(page);
	}
	
	this.PrevPage = function()
	{
		var page = curPage - 1;
		MoveGallery(page);
	}
	
		
	this.PageClick = function(e)
	{
		e.stop();
		var page = this.readAttribute("data");
		MoveGallery(page);
	}
	
	this.NextClick = function(e)
	{
		e.stop();
		NextPage();
	}
	
	this.PrevClick = function(e)
	{
		e.stop();
		PrevPage();
	}
	
	this.gallery.select('.pagination_page').invoke('observe', 'click', PageClick);
	this.gallery.select('.pagination_next').invoke('observe', 'click', NextClick);
	this.gallery.select('.pagination_prev').invoke('observe', 'click', PrevClick);
	
	
	
}