function Paginator(targetContainer, exactWidth, idealHeight){
	this.targetContainer = targetContainer;
	this.exactWidth = exactWidth;
	this.idealHeight = idealHeight;

	this.TargetChild = function(node, renderHeight){
		this.node = node;
		this.renderHeight = renderHeight;
	}

	this.targetChildren = [];
	this.targetPages = [];
	this.currPage = 0;
	this.numPages;
    
    // CHECK ON NUMBER OF CHARACTERS
    // 17,200 has been tested to be the maximum number of chars the paginator function can handle.
    var numchars = targetContainer.innerHTML.length;
    if (numchars > 17000) { 
    	return false; // Don't paginate
    }

	this.pageMove = function(d){
		if(d < 0 && this.currPage > 0 || d > 0 && this.currPage < this.numPages - 1){
			this.targetPages[this.currPage].style.visibility = "hidden";
			this.currPage += d;
			this.targetPages[this.currPage].style.visibility = "visible";
			paginatorNum.innerHTML = this.currPage + 1;
		}
		prevActive.className = (this.currPage > 0 ? "paginatorPrev" : "paginatorPrevDisabled");
		nextActive.className = (this.currPage < this.numPages - 1 ? "paginatorNext" : "paginatorNextDisabled");
	}

	this.paginator = function(){
		function useNode(node){ // PRIVATE METHOD - Removes bad content created by the wysiwyg editor - not currently in use
//			if (node.innerHTML == "" // Empty node - Also captures TEXT nodes and WHITESPACE only strings (required)
//			 || node.innerHTML.length == 1 && node.innerHTML.charCodeAt(0) == 160 // Contains only one non-breaking spaces
//			){
//				return false;
//			}
			return true;
		}

		if(targetContainer.childNodes.length > 1){ // MAY NOT BE TAGGED UP
			// PULL ALL CONTENT MODES OUT INTO A PROCESS LIST
			while(targetContainer.childNodes.length > 0){
				var renderHeight = paginatedContent.firstChild.offsetHeight;

				if(renderHeight > this.idealHeight){ // EXTEND (IF NECESSARY) PAGE HEIGHT
					this.idealHeight = renderHeight;
				}
				
				var node = paginatedContent.removeChild(paginatedContent.firstChild);
				if(node.nodeType != 3) { // IGNORE WHITESPACE NODES (#TEXT)
					this.targetChildren.push(new this.TargetChild(node, renderHeight));
				}
			}

			// CREATE INDIVIDUAL PAGES
			while(this.targetChildren.length > 0){
				var currHeight = 0;
				var newDiv = document.createElement("DIV")
				do {
					var currElem = this.targetChildren.shift()
					if (currElem.renderHeight != 0) {
						currHeight += currElem.renderHeight;
						newDiv.appendChild(currElem.node);
					}
				} while(currHeight + (this.targetChildren.length > 0 ? this.targetChildren[0].renderHeight : this.idealHeight) < this.idealHeight)
				if (currElem.renderHeight != 0) this.targetPages.push(newDiv);
			}
			this.numPages = this.targetPages.length

			// SETUP PAGES FOR PAGINATOR
			if(this.numPages > 1){
				var h = 0;
				for(var i = 0, ii = this.numPages; i < ii; i++){
					this.targetPages[i].className = "paginatedPage";
					this.targetPages[i].style.width = "100%";
					targetContainer.appendChild(this.targetPages[i]);
					if(this.targetPages[i].offsetHeight > h){
						h = this.targetPages[i].offsetHeight;
					}
				}
				targetContainer.style.height = h + "px"
				this.targetPages[this.currPage].style.visibility = "visible";
				if(document.getElementById("staticPaginator")) {
					document.getElementById("staticPaginator").style.display = "none";
				}
				dynamicPaginator.style.display = "block";
				paginatorNum.innerHTML = this.currPage + 1;
				paginatorOf.innerHTML = this.numPages;
			} else {
				targetContainer.appendChild(this.targetPages[0]);
			}
		}
	}
	this.paginator();
}
//mainPaginator = new Paginator(paginatedContent, (_HD ? 450 : 270));
