/*
Copyright DHTMLX LTD. http://www.dhtmlx.com
To use this component please contact sales@dhtmlx.com to obtain license
*/
dhtmlXGridObject.prototype.enablePaging = function(fl,pageSize,pagesInGrp,parentObj,showRecInfo,recInfoParentObj){if(typeof(parentObj)=="string"){parentObj = document.getElementById(parentObj)};if(typeof(recInfoParentObj)=="string"){recInfoParentObj = document.getElementById(recInfoParentObj)};this.pagingOn = fl;this.showRecInfo = showRecInfo;this.rowsBufferOutSize = pageSize;this.pagingBlock = document.createElement("DIV");this.pagingBlock.className = "pagingBlock";this.recordInfoBlock = document.createElement("SPAN");this.recordInfoBlock.className = "recordsInfoBlock";if(parentObj)parentObj.appendChild(this.pagingBlock)
if(recInfoParentObj)recInfoParentObj.appendChild(this.recordInfoBlock)
this.currentPage = 1;this.pagesPrefix = this.pagesPrefix||"Result Page: ";this.pagesDevider = " | "
this._pagesInGroup=this.pagesInGroup = pagesInGrp;this.recordsInfoStr = this.recordsInfoStr||"Results [from]-[to] of [about][total]";this.noRecordStr = this.noRecordStr||"No records found";this.attachEvent("onClearAll",function(){this.pagesInGroup=this._pagesInGroup})
};dhtmlXGridObject.prototype.setPageSize = function(size){this.rowsBufferOutSize = size;this.changePage()};dhtmlXGridObject.prototype.createPagingBlock = function(){this.pagingBlock.innerHTML = "";var self = this;var pagesNum = Math.ceil((this.limit||(this.rowsBuffer[0].length+this.rowsCol.length))/this.rowsBufferOutSize);if(pagesNum==0){this.createRecordsInfo();return false};if(!this.pagesInGroup || this.pagesInGroup>(pagesNum*2-2)){this.pagesInGroup = pagesNum};var startOfGroup = (this.currentPage - (this.currentPage-1)%this.pagesInGroup)||1
var lastPage = startOfGroup+this.pagesInGroup - 1
if(this.recordsNoMore){lastPage = Math.min(pagesNum,lastPage)};var prefObj = document.createElement("SPAN");prefObj.innerHTML = this.pagesPrefix;this.pagingBlock.appendChild(prefObj);if(startOfGroup!=1){var pageMark = document.createElement("SPAN");pageMark.innerHTML = "< ";this.pagingBlock.appendChild(pageMark)
pageMark.className = "pagingPage";pageMark.cp = startOfGroup-1;pageMark.onclick = function(){self.changePage(this.cp)
}};for(var i=startOfGroup;i<=lastPage;i++){var pageMark = document.createElement("SPAN");pageMark.innerHTML = i;this.pagingBlock.appendChild(pageMark)
if(i!=lastPage || !this.recordsNoMore || lastPage!=pagesNum){var divider = document.createElement("SPAN");divider.innerHTML = this.pagesDevider;this.pagingBlock.appendChild(divider)
};if(this.currentPage==i){pageMark.className = "pagingCurrentPage"}else{pageMark.className = "pagingPage";pageMark.cp = i;pageMark.onclick = function(){self.changePage(this.cp)
}}};if(!this.recordsNoMore || lastPage!=pagesNum){var pageMark = document.createElement("SPAN");pageMark.innerHTML = ">";this.pagingBlock.appendChild(pageMark)
pageMark.className = "pagingPage";pageMark.cp = i;pageMark.onclick = function(){self.changePage(this.cp)
}};if(this.showRecInfo){if(this.recordInfoBlock.parentNode==null){this.pagingBlock.appendChild(document.createTextNode(" "))
this.pagingBlock.appendChild(this.recordInfoBlock)
};this.createRecordsInfo()};this.createRecordsInfo();this.callEvent("onPaging",[pagesNum])};dhtmlXGridObject.prototype.createRecordsInfo = function(){if(this.showRecInfo){if(this.recordInfoBlock.parentNode==null){this.pagingBlock.appendChild(document.createTextNode(" "))
this.pagingBlock.appendChild(this.recordInfoBlock)
}}else{return false};this.recordInfoBlock.innerHTML = "";var rowsNum = this.getRowsNum()
if(rowsNum==0){var outStr = this.noRecordStr}else{var from = ((this.currentPage-1)*this.rowsBufferOutSize)+1;var to = Math.min((this.currentPage*this.rowsBufferOutSize),rowsNum)
var outStr = this.recordsInfoStr.replace(/\[from\]/,from);outStr = outStr.replace(/\[to\]/,to);outStr = outStr.replace(/\[total\]/,rowsNum);if(this.recordsNoMore){outStr = outStr.replace(/\[about\]/,"")}else{outStr = outStr.replace(/\[about\]/,"known ")}};this.recordInfoBlock.innerHTML = outStr};dhtmlXGridObject.prototype.changePage = function(pageNum){if(pageNum<1){return false};if(!this.callEvent("onBeforePageChanged",[this.currentPage,pageNum])){return};if(pageNum)this.currentPage = parseInt(pageNum);this.createPagingBlock();var totalRows = this.obj._rowslength();for(var i=0;iind || ( !this._startXMLLoading && this.limit && this.limit > ind)){row = this.getRowFromCollection(ind)
}};return row};dhtmlXGridObject.prototype.setPagePrefix = function(str){this.pagesPrefix = str};dhtmlXGridObject.prototype.getPagePrefix = function(){return this.pagesPrefix};dhtmlXGridObject.prototype.setRecordsInfoTemplate = function(str){this.recordsInfoStr = str};dhtmlXGridObject.prototype.getRecordsInfoTemplate = function(){return this.recordsInfoStr};dhtmlXGridObject.prototype.setNoRecordsString = function(str){this.noRecordStr = str};dhtmlXGridObject.prototype.getNoRecordsString = function(){return this.noRecordStr};dhtmlXGridObject.prototype.enableRecordsInfo = function(fl){this.showRecInfo = fl};dhtmlXGridObject.prototype.setRecordsInfoParent = function(obj){if(!obj)if(this.recordInfoBlock.parentNode)this.recordInfoBlock.parentNode.removeChild(this.recordInfoBlock)
else
obj.appendChild(this.recordInfoBlock)};dhtmlXGridObject.prototype.setPagingBlockParent = function(obj){obj.appendChild(this.pagingBlock)};dhtmlXGridObject.prototype.setOnPageChanged = function(func){this.attachEvent("onPageChanged",func)};dhtmlXGridObject.prototype.setOnPaging = function(func){this.attachEvent("onPaging",func)};dhtmlXGridObject.prototype.setPagingWTMode = function(navButtons,navLabel,pageSelect,perPageSelect,labels){this._WTDef=[navButtons,navLabel,pageSelect,perPageSelect];this._WTlabels=labels||["Results","Records from "," to ","Page ","rows per page"]};dhtmlXGridObject.prototype.enablePagingWT = function(fl,pageSize,pagesInGrp,parentObjId){if (!this._WTDef)this.setPagingWTMode(true,true,true,true);var self = this;this.enablePaging(fl,pageSize,pagesInGrp);this.setOnPageChanged(function(page,startRowInd,lastRowInd){if (this._WTDef[2]){self.aToolBar.enableItem("right");self.aToolBar.enableItem("rightabs");self.aToolBar.enableItem("left");self.aToolBar.enableItem("leftabs");if(self.currentPage==self.totalPages){self.aToolBar.disableItem("right");self.aToolBar.disableItem("rightabs")}else{if(self.currentPage==1){self.aToolBar.disableItem("left");self.aToolBar.disableItem("leftabs")}}};if (this._WTDef[2]){var sButton = self.aToolBar.getItem("pages");sButton.setSelected(page.toString())
};if (this._WTDef[1]){var iButton = self.aToolBar.getItem("results");iButton.setText(this._WTlabels[1]+(startRowInd+1)+this._WTlabels[2]+(lastRowInd+1))}});this.setOnPaging(function(pNum){if (this._WTDef[2]){var pButton = self.aToolBar.getItem("pages")
pButton.clearOptions();for(var i=0;i