function Cls_jsPage(iRecCount,iPageSize,iPageNum,sName){
	this.iRC=Cls_jsPage.fFormatNum(iRecCount,1,0,0,0);
	this.iPS=Cls_jsPage.fFormatNum(iPageSize,1,0,1,0);
	this.iPN=Cls_jsPage.fFormatNum(iPageNum,0,0,0,0);
	this.sN=sName;
	this.sTPage="{$Page}";
	this.sTPageCount="{$PageCount}";
	this.sTRecCount="{$RecCount}";
	this.sTPageSize="{$PageSize}";
	this.sTPageFrist="{$PageFrist}";
	this.sTPagePrev="{$PagePrev}";
	this.sTPageNext="{$PageNext}";
	this.sTPageLast="{$PageLast}";
	this.sTPageText="{$PageText}";
	this.sTPageTextF="{$PageTextF}";
	this.sTPageInput="{$PageInput}";
	this.sTPageSelect="{$PageSelect}";
	this.sTPageNum="{$PageNum}";
	this.iPC=this.getPageCount();
}

Cls_jsPage.prototype.setPageSE=function(sPageStart,sPageEnd){
	var sPS=sPageStart,sPE=sPageEnd;
	this.sPS=(sPS.length>0)?sPS:"Page=";
	this.sPE=(sPE.length>0)?sPE:"";
}

Cls_jsPage.prototype.setUrl=function(sUrl){
	var s=sUrl;
	this.Url=(s.length>0)?s:""+document.location;
}

Cls_jsPage.prototype.setPageInput=function(sPageInput){
	var sPI=sPageInput;
	this.sPI=(sPI.length>0)?sPI:"Page";
}

Cls_jsPage.prototype.setPageFrist=function(sDis,sEn){
	this.PF_D=sDis;
	this.PF_E=sEn;
}

Cls_jsPage.prototype.setPagePrev=function(sDis,sEn){
	this.PP_D=sDis;
	this.PP_E=sEn;
}

Cls_jsPage.prototype.setPageNext=function(sDis,sEn){
	this.PN_D=sDis;
	this.PN_E=sEn;
}

Cls_jsPage.prototype.setPageLast=function(sDis,sEn){
	this.PL_D=sDis;
	this.PL_E=sEn;
}

Cls_jsPage.prototype.setPageText=function(sDis,sEn){
	this.PT_D=sDis;
	this.PT_E=sEn;
}

Cls_jsPage.prototype.setPageTextF=function(sDis,sEn){
	this.PTF_D=sDis;
	this.PTF_E=sEn;
}

Cls_jsPage.prototype.setPageSelect=function(sDis,sEn){
	this.PS_D=sDis;
	this.PS_E=sEn;
}

Cls_jsPage.prototype.setPageCss=function(sCssPageText,sCssPageInput,sCssPageSelect){
	this.CPT=sCssPageText;
	this.CPI=sCssPageInput;
	this.CPS=sCssPageSelect;
}

Cls_jsPage.prototype.setHtml=function(sHtml){
	this.Html=sHtml;
}

Cls_jsPage.prototype.getPageCount=function(){
	var iRC=this.iRC,iPS=this.iPS;
	var i=(iRC%iPS==0)?(iRC/iPS):(Cls_jsPage.fFormatNum((iRC/iPS),1,0,0,0)+1);
	return (i);
}

Cls_jsPage.prototype.getUrl=function(iType){
	var s=this.Url,sPS=this.sPS,sPE=this.sPE,sTP=this.sTPage,iPC=this.iPC;
	var iT=iType,i;
	if (s.indexOf(sPS)==-1) {	
		s+=((s.indexOf("?")==-1)?"?":"&")+sPS+sTP;
		i=1;
	}
	else {
		sReg="(\\S.*)"+Cls_jsPage.fFormatReg(sPS)+"(\\d*)"+Cls_jsPage.fFormatReg(sPE)+"(\\S.*|\\S*)";
		var sPIndex=Cls_jsPage.fReg(s,sReg,"$3");
		s=s.replace(sPS+sPIndex+sPE,sPS+sTP+sPE);
		i=Cls_jsPage.fFormatNum(sPIndex,1,1,0,iPC);
	}
	s=Cls_jsPage.fReg(s,"(&+)","&");
	s=Cls_jsPage.fReg(s,"(\\?&)","?");
	return (iT==0?s:i);
}

Cls_jsPage.prototype.PageJump=function(){
	var sPL,sPV,sP;
	var sU=this.getUrl(0),iPI=this.getUrl(1);
	var sPI=this.sPI,sTP=this.sTPage,iPC=this.iPC;
	sPL=document.getElementsByName(sPI).length;
	for (var i=0;i<sPL;i++)	{
		sPV=document.getElementsByName(sPI)[i].value;
		sP=Cls_jsPage.fFormatNum(sPV,1,1,0,iPC);
		if (sP>0) {
			location.href=sU.replace(sTP,sP);
			break;
		}
	}
}

Cls_jsPage.prototype.Write=function(){
	var sU=this.getUrl(0),iPI=this.getUrl(1);
	var sN=this.sN,sPI=this.sPI;
	var iPC=this.iPC,iPN=this.iPN;;
	var iRC=this.iRC,iPS=this.iPS;
	var PF_D=this.PF_D,PF_E=this.PF_E;
	var PP_D=this.PP_D,PP_E=this.PP_E;
	var PN_D=this.PN_D,PN_E=this.PN_E;
	var PL_D=this.PL_D,PL_E=this.PL_E;
	var PT_D=this.PT_D,PT_E=this.PT_E;
	var PTF_D=this.PTF_D,PTF_E=this.PTF_E;
	var PS_D=this.PS_D,PS_E=this.PS_E;
	var CPT=this.CPT,CPI=this.CPI;
	var CPS=this.CPS,iPN=this.iPN;
	var s=this.Html;
	sTPage=this.sTPage;
	sTPageCount=this.sTPageCount;
	sTRecCount=this.sTRecCount;
	sTPageSize=this.sTPageSize;
	sTPFrist=this.sTPageFrist;
	sTPPrev=this.sTPagePrev;
	sTPNext=this.sTPageNext;
	sTPLast=this.sTPageLast;
	sTPText=this.sTPageText;
	sTPTextF=this.sTPageTextF;
	sTPInput=this.sTPageInput;
	sTPSelect=this.sTPageSelect;
	sTPageNum=this.sTPageNum;
	PrevP=Cls_jsPage.fFormatNum((iPI-1),1,1,1,iPC);
	NextP=Cls_jsPage.fFormatNum((iPI+1),1,1,1,iPC);
	if (iPI<=1&&iPC<=1) {
		FirstPU=PF_D;  
		PrevPU=PP_D;
		NextPU=PN_D;
		LastPU=PL_D;
	}
	else if (iPI==1&&iPC>1) {
		FirstPU=PF_D;  
		PrevPU=PP_D;
		NextPU="<A href=\""+sU.replace(sTPage,NextP)+"\">"+PN_E+"</A>";
		LastPU="<A href=\""+sU.replace(sTPage,iPC)+"\">"+PL_E+"</A>";
	}
	else if (iPI==iPC) {
		FirstPU="<A href=\""+sU.replace(sTPage,1)+"\">"+PF_E+"</A>";
		PrevPU="<A href=\""+sU.replace(sTPage,PrevP)+"\">"+PP_E+"</A>";
		NextPU=PN_D;
		LastPU=PL_D;
	}
	else {
		FirstPU="<A href=\""+sU.replace(sTPage,1)+"\">"+PF_E+"</A>";
		PrevPU="<A href=\""+sU.replace(sTPage,PrevP)+"\">"+PP_E+"</A>";
		NextPU="<A href=\""+sU.replace(sTPage,NextP)+"\">"+PN_E+"</A>";
		LastPU="<A href=\""+sU.replace(sTPage,iPC)+"\">"+PL_E+"</A>";
	}
	PageSelect="";
	PageText="";
	PageInput="";
	if (iPN<0) {
		iPN=Math.abs(iPN);
		PageStart=(iPI%iPN==0)?(iPI/iPN):(Cls_jsPage.fFormatNum((iPI/iPN),1,0,0,0));
		PageStart=(PageStart*iPN==iPI)?((PageStart-1)*iPN+1):(PageStart*iPN+1);
		PageEnd=Cls_jsPage.fFormatNum(PageStart+iPN,0,1,0,iPC)
	}
	else if (iPN==0) {
		PageStart=1;
		PageEnd=iPC;
	}
	else {
		PageStart=Cls_jsPage.fFormatNum((iPI-iPN),1,0,1,0);
		PageEnd=Cls_jsPage.fFormatNum((PageStart+iPN*2),0,1,0,iPC);
		PageStart=(PageEnd==iPC)?Cls_jsPage.fFormatNum((PageEnd-iPN*2),1,0,1,0):PageStart;
	}
	if (iPC>=1) {
		PageSelect="<Select class=\""+CPS+"\" name=\""+sPI+"\" onChange=\""+sN+".PageJump()\">";
		PageInput="<Input class=\""+CPI+"\" type=\"text\" name=\""+sPI+"\" size=\"5\" maxlength=\"10\" onkeydown=\"if (event.keyCode==13) "+sN+".PageJump()\">";
		for (i=PageStart;i<=PageEnd;i++) {
			if (i!=iPI) {
				XX="<span class=\""+CPT+"\"><A href=\""+sU.replace(sTPage,i)+"\">"+PT_E.replace(sTPageNum,i)+"</A></span>";
				PageText+=PTF_E.replace(sTPTextF,XX);
				PageSelect+="<Option value=\""+i+"\">"+PS_E.replace(sTPageNum,i)+"</Option>";
			}
			else {
				XX="<span class=\""+CPT+"\">"+PT_D.replace(sTPageNum,i)+"</span>";
				PageText+=PTF_D.replace(sTPTextF,XX);
				PageSelect+="<Option Selected=\"Selected\">"+PS_D.replace(sTPageNum,i)+"</Option>";
			}
		}
		PageSelect+="</Select>";
	}
	s=s.replace(sTPage,iPI);
	s=s.replace(sTPageCount,iPC);
	s=s.replace(sTRecCount,iRC);
	s=s.replace(sTPageSize,iPS);
	s=s.replace(sTPFrist,FirstPU);
	s=s.replace(sTPPrev,PrevPU);
	s=s.replace(sTPNext,NextPU);
	s=s.replace(sTPLast,LastPU);
	s=s.replace(sTPText,PageText);
	s=s.replace(sTPInput,PageInput);
	s=s.replace(sTPSelect,PageSelect);
	document.write (s);
}

Cls_jsPage.fFormatNum=function(sNum,bMin,bMax,iMinNum,iMaxNum){
	var i,iN,iTMin,iTMax,sN=""+sNum,bMi=bMin,bMa=bMax,iMin=iMinNum,iMax=iMaxNum;
	if (sN.length>0) {
		iN=parseInt(sN,10);
		i=(isNaN(iN))?iMin:iN;
		i=(i<iMin&&bMi==1)?iMin:i;
		i=(i>iMax&&bMa==1)?iMax:i;
	}
	else {
		i=iMin;
	}
	return (i);
}

Cls_jsPage.fReg=function(sStr,sReg,sRe){
	var s="",sS=sStr,sR=sReg,sRe=sRe;
	if ((sS.length>0)&&(sR.length>0)) {
		eval("re=/"+sR+"/gim;");
		s=sS.replace(re,sRe);
	}
	return (s);
}

Cls_jsPage.fFormatReg=function(sReg){
	var s="",sR=sReg;
	var sF=new Array ("/",".","+","[","]","{","}","$","^","?","*");
	if (sR.length>0) {
		for (var i=0;i<=sF.length;i++) {
			sR=sR.replace(sF[i],"\\"+sF[i]);
		}
		s="("+sR+")";
	}
	return (s);
}
