function pagingObject(pageSize, buttonContainer) {
	this.size = pageSize;
	this.bc = buttonContainer;
	this.pages = new Array();
	this.currentPage = -1;
	this.visibleDisplayStyle = "inline";
	
	this.bc.innerHTML="<div style=\"font-weight:bold;\">More Pages:</div>";
	
	this.prevButton = document.createElement("span");
	this.prevButton.pagingParent=this;
	this.prevButton.style["padding"] = ".5em";
	this.prevButton.style["cursor"] = "pointer";
	this.prevButton.onclick=
		function(){
			this.pagingParent.showPrev();
		}
	this.prevButton.ondblclick = 
		function(){
			clearSelection();
			//this.pagingParent.showPrev();
		}
	this.prevButton.innerHTML="&lt;";
	this.bc.appendChild(this.prevButton);
	
	this.nextButton = document.createElement("span");
	this.nextButton.pagingParent=this;
	this.nextButton.style["padding"] = ".5em";
	this.nextButton.style["cursor"] = "pointer";
	this.nextButton.onclick=
		function(){
			this.pagingParent.showNext();
		}
	this.nextButton.ondblclick = 
		function(){
			clearSelection();
			//this.pagingParent.showNext();
		}
	this.nextButton.innerHTML="&gt;";
	this.bc.appendChild(this.nextButton);
	
	this.addPage = function (page) {
		if(page){
			this.pages[this.pages.length] = page;
			this.currentPage = 0;
			// add a button for this control to the button container
			var x = document.createElement("span");
			x.id="pageButton"+(this.pages.length-1)
			x.pagingParent = this;
			x.style["padding"] = ".5em";
			x.style["cursor"] = "pointer";
			x.onclick = 
			function() {
				this.pagingParent.showPage(parseInt(this.innerHTML)-1);
			};
			x.ondblclick=clearSelection;
			x.innerHTML = this.pages.length;
   			this.bc.insertBefore(x, this.nextButton);
			if(this.pages.length>1){
				//alert("hiding "+this.pages.length);
				page.style["display"]="none";
				this.bc.style["display"]="";
			}else{
				this.bc.style["display"]="none";
				x.style["fontWeight"]="bold";
			}
		}
	};
	this.showPage = function(pageIndex){
		this.pages[this.currentPage].style["display"]="none";
		document.getElementById("pageButton"+this.currentPage).style["fontWeight"]="normal";
		this.pages[pageIndex].style["display"] = this.visibleDisplayStyle;
		this.currentPage = pageIndex;
		document.getElementById("pageButton"+this.currentPage).style["fontWeight"]="bold";
	};
	this.showPrev = function(){
		if(this.currentPage==0){
		}else{
			this.showPage(this.currentPage-1);
		}
	};
	this.showNext = function(){
		if(this.currentPage==(this.pages.length-1)){
		}else{
			this.showPage(this.currentPage+1);
		}
	};
}
function clearSelection() {
	var sel ;
	if(document.selection && document.selection.empty){
		document.selection.empty() ;
	} else if(window.getSelection) {
		sel=window.getSelection();
		if(sel && sel.removeAllRanges){
			sel.removeAllRanges();
		}
	}
}
