function PagedList(id, itemTagName, itemCssClass)
{
	this.id 					= id;
	this.itemTagName	= itemTagName;
	this.itemCssClass	= itemCssClass;
	this.items 				= [];
	this.pageSize 		= 5;
	this.pageCount		= 0;
	this.currentPage	= 0;
	this.navigation 		= null;
	this.obj					= null;
	
	this.setListObject = function()
	{
		this.obj = document.getElementById(id);
	}
	
	this.setItems = function()
	{
		var list = this.obj.getElementsByTagName(this.itemTagName);
		for (var i=0; i<list.length; i++)
		{
			if (this.itemCssClass.length<1 || list[i].className == this.itemCssClass)
			{
				this.items[this.items.length] = list[i];
			}
		}
		this.pageCount = Math.ceil(this.items.length / this.pageSize);
	}

	this.render = function(cssClass)
	{
		if (!document.getElementById) return;
		this.setListObject();
		if (!this.obj) return;
		this.setItems();
		if (this.items.length<1) return;
	
		this.navigation = document.createElement("div");
		this.navigation.className = cssClass;
		this.navigation.links = [];
		
		this.prev = document.createElement('a');
		this.navigation.appendChild(this.prev);
		this.prev.appendChild(document.createTextNode('<< back'));
		this.prev.setAttribute('href', 'javascript:void(0);');
		this.prev.list = this;
		this.prev.onclick = function() {
			this.list.currentPage--;
			this.list.show();
		}
		
		this.next = document.createElement('a');
		this.navigation.appendChild(this.next);
		this.next.appendChild(document.createTextNode('more >>'));
		this.next.setAttribute('href', 'javascript:void(0);');
		this.next.list = this;
		this.next.onclick = function() {
			this.list.currentPage++;
			this.list.show();
		}
		
		this.obj.appendChild(this.navigation);
		this.show();
	}
	
	this.show = function() {
		for (var i=0, item; item = this.items[i]; i++)
		{
			var page = Math.ceil((i + 1) / this.pageSize);
			item.style.display = (page != this.currentPage + 1) ? "none" : "";
		}
		this.prev.style.display = (this.currentPage == 0) ? 'none' : '';
		this.next.style.display = (this.currentPage + 1 == this.pageCount) ? 'none' : '';
	}	

}