function pagebar(){
	this.firstWord = "First";
	this.lastWord = "Last";
	this.gotoWord = "Goto";
	this.maxNum=23456;
	this.perPage=20;
	this.showPageNum=10;
	this.totalRec=0;
	this.prefix="";
	this.prefix1="";
	this.prefix2="";
	this.showDiv="";
	this.ownerId="0";
	this.divOpen=0;
	this.Func=1;
	this.pageNum=23456;
}
pagebar.prototype.setInfo = function(p_word,p_info) {
        eval("this."+p_word+"='"+p_info+"'");
}
pagebar.prototype.genPageBar = function (p_curBackPage,p_total,p_prefix,p_pageNum,p_pageNbr){
	if(!p_pageNum) p_pageNum = this.showPageNum; 	
	if(!p_pageNbr) p_pageNbr = this.perPage; 	
	if(!p_prefix) p_prefix = this.prefix; 	
	if(!p_total) p_total = this.totalRec; 	
	if(this.showDiv!="") this.divOpen=1;
	this.prefix1 = this.prefix +"/"+this.Func + "/";
	this.prefix2 = "/"+this.Func+"-"+this.ownerId+"-";
	var nbr = 0;
	if(this.ownerId.indexOf("-")>0){
		nbr = parseInt(this.ownerId.split("-")[1]);
	}
   var totalPageNum;
	if ((p_total%p_pageNbr)==0) totalPageNum = parseInt(p_total/p_pageNbr);
   else if ((p_total%p_pageNbr)<parseInt(p_pageNbr/2)) totalPageNum = parseInt(p_total/p_pageNbr);
	else totalPageNum = parseInt(p_total/p_pageNbr)+1;

   var fromPage = 1;
   var toPage = 10;
	var showBar = "";
	if((parseInt(p_total) < parseInt(p_pageNbr)) || p_total==0 || p_total=="" || totalPageNum<=1){
		return showBar;
	}
	p_curPage = totalPageNum-p_curBackPage;
   var halfPageNum = parseInt(p_pageNum/2);
   if (p_curPage>halfPageNum) fromPage=p_curPage-halfPageNum;
   if (totalPageNum>(p_curPage+halfPageNum)) toPage=p_curPage+halfPageNum;
   else toPage = totalPageNum;
	if (this.divOpen == 1){
		//add this for show first fb content.
		showBar +="<script language='javascript'>divOs.openUrl('"+this.showDiv+"','"+p_prefix+"&Page="+(totalPageNum)+"');</script>";
		showBar +="<a href=\"javascript:divOs.openUrl('"+this.showDiv+"','"+p_prefix+"&Page="+(totalPageNum)+"');\">"+this.firstWord+"</a> ";
	}
	else {
		if(nbr>0){
			showBar +="<a href=\""+this.prefix1+nbr%97+this.prefix2+(this.maxNum-totalPageNum+1)+".php\">"+this.firstWord+"</a> ";
		}else{
			showBar +="<a href=\""+this.prefix1+(this.maxNum-totalPageNum+1)%97+this.prefix2+(this.maxNum-totalPageNum+1)+".php\">"+this.firstWord+"</a> ";
		}
	}
   for (var i=fromPage;i<=toPage;i++){
     	var backPage = totalPageNum-i;
		var link_s=link_e="";
		if (this.divOpen == 1){
			if (i!=0) {link_s = " <a href=\"javascript:divOs.openUrl('"+this.showDiv+"','"+p_prefix+"&Page="+parseInt(parseInt(backPage)+1)+"');\">";link_e = "</a>";}else{link_s=" ";link_e="";}
			showBar +=link_s+i+link_e;
		}
		else {
			if (i!=(p_curPage+1)) {
				if(nbr>0){
					link_s = " <a href=\""+this.prefix1+nbr%97+this.prefix2+ (this.maxNum-backPage)+".php\">";link_e = "</a>";
				}else{
					link_s = " <a href=\""+this.prefix1+(this.maxNum-backPage)%97+this.prefix2+ (this.maxNum-backPage)+".php\">";link_e = "</a>";
				}
			} else{link_s=" ";link_e="";}
			showBar +=link_s+i+link_e;
		}
	}
		if (this.divOpen == 1){
			showBar +=" <a href=\"javascript:divOs.openUrl('"+this.showDiv+"','"+p_prefix+"&Page=1');\">"+this.lastWord+"</a>";
			showBar +=" "+this.gotoWord+"<input style=\"width:30px\"  style=\"width:100px\" class=\"input2select\" onfocus=\"nextSibling.style.display='inline';nextSibling.focus();style.display='none';\" value=\"--\"><select name=\"gopage\" onchange=\"if(this.selectedIndex) divOs.openUrl('"+this.showDiv+"','"+p_prefix+"&Page='+("+totalPageNum+"-this.selectedIndex+1));\" onblur=\"previousSibling.style.display='inline';style.display='none';\" style=\"display:none\">";

		}
		else {
			if(nbr>0){
				showBar +=" <a href=\""+this.prefix1+nbr%97+this.prefix2+this.maxNum+".php\">"+this.lastWord+"</a>";
			}else{
				showBar +=" <a href=\""+this.prefix1+this.maxNum%97+this.prefix2+this.maxNum+".php\">"+this.lastWord+"</a>";
			}
			showBar +=" "+this.gotoWord+" <input style=\"width:30px\"  style=\"width:100px\" class=\"input2select\" onfocus=\"nextSibling.style.display='inline';nextSibling.focus();style.display='none';\" value=\"--\"><select name=\"gopage\" onchange=\"if(this.selectedIndex) {window.location.href=this.options[this.selectedIndex].value;}\" onblur=\"previousSibling.style.display='inline';style.display='none';\" style=\"display:none\">";
		}
	showBar +="<option value=''>--</option>";
	for (var j=1;j<=totalPageNum;j++){
     	var backPage2 = totalPageNum-j;
		if(nbr>0){
			showBar +="<option value=\""+this.prefix1+nbr%97+this.prefix2+(this.maxNum-backPage2)+".php\">"+j+"</option>";
		}else{
			showBar +="<option value=\""+this.prefix1+(this.maxNum-backPage2)%97+this.prefix2+(this.maxNum-backPage2)+".php\">"+j+"</option>";
		}
	}

	showBar +="</select>";
	return showBar;
}
