function Paging(idPageBox, idTableBox, idSourceTable, iPageSize) {
	pageBox = document.getElementById(idPageBox);
	tableBox = document.getElementById(idTableBox);
	sourceRows = document.getElementById(idSourceTable).rows;
	cPage = 1; pageSize = iPageSize; cntPages = Math.floor(sourceRows.length / pageSize) + 1;
}

function paging_f01(pNum) {
	if (pNum == "prev" && cPage > 1) { cPage -= 1; } else if (pNum == "next" && cPage < cntPages) { cPage += 1; } else { cPage = pNum; }
	this.refresh();
}
Paging.prototype.changePage = paging_f01;

function paging_f02() {
	var i, out, ce;
	// update table
	out = '<table class="border" cellspacing="0" cellpadding="2" border="0"><tr><td width="100" align="center">Äàòà</td><td width="180" align="center">Ñ×À, ðóá.</td></tr>';
	for (i = 0; i < pageSize; i++) {
		cIdx = (cPage - 1) * pageSize + i;
		if (sourceRows[cIdx]) {
			out += '<tr><td align="center">' + sourceRows[cIdx].cells[0].innerHTML  + '<td align="right">' + sourceRows[cIdx].cells[1].innerHTML;
		}
	}
	tableBox.innerHTML = out;
	// update page selector
	pageBox.innerHTML = "";
	if (cPage > 1) {
		ce = document.createElement("span"); ce.innerHTML = "&lt;"; ce.mBox = this;
		ce.onclick = function() { this.mBox.changePage("prev"); };
		pageBox.appendChild(ce);
	}
	for (i = 1; i <= cntPages; i++) {
		ce = document.createElement("span"); ce.innerHTML = " " + i; ce.pgNum = i; ce.mBox = this;
		ce.onclick = function() { this.mBox.changePage(this.pgNum); }
		if (i == cPage) { ce.style.fontWeight = "bold"; }
		pageBox.appendChild(ce);
	}
	if (cPage < cntPages) {
		ce = document.createElement("span"); ce.innerHTML = "&nbsp;&gt;"; ce.mBox = this;
		ce.onclick = function() { this.mBox.changePage("next"); };
		pageBox.appendChild(ce);
	}
}
Paging.prototype.refresh = paging_f02;