function PageStyle(path){
 if(path)this.globalPath = path;
};

PageStyle.prototype.render = function (pageCount,currentPage,pageSize,formIndex,count){
if(!formIndex){
	 formIndex=0;
}
 //样式的初始化
var bgpic_no_repeat ='background-repeat:no-repeat;';
var page_font ='font-size: 12px;color: #999999;text-decoration: none;text-align: center;';
var page_num ='font-size: 12px;color: #999999;text-decoration: none;text-align: center;cursor:pointer;';
var page_num_cur ='font-size: 12px;color: #ff0000;text-decoration: none;text-align: center;cursor:pointer;vertical-align: top;';
//var text_r = 'font-size: 11px;color: #333333;text-decoration: none;font-weight: normal;';
//var text_b = 'font-size: 11px;color: #ffffff;text-decoration: none;font-weight: normal;';
//body区域
var  first,last,numClass,pageId;

var showText ="";

showText +='<table width="100%" border=0 align=center cellpadding=0 cellspacing=0>';
showText+=' <tr> ';

if(count){
  showText+=' <td width=100> ';
  showText+=' <table width=100%  border=0 align=right cellpadding=0 cellspacing=0 >';
  showText+='<tr> ';
  showText+='<td style="'+page_font+'">总记录:<span style="'+page_num_cur+'">'+count+'</span>条</td>';
  showText+='</tr>';
  showText+='</table>';
  showText+=' </td>';
}

showText+=' <td width=70> ';
showText+=' <table width=100%  border=0 align=right cellpadding=0 cellspacing=0 >';
showText+='<tr> ';
showText+='<td style="'+page_font+'">总共:<span style="'+page_num_cur+'">'+pageCount+'</span>页</td>';
showText+='</tr>';
showText+='</table>';
showText+=' </td>';
pageId=1;
showText+=' <td width=30 height=25 > ';
showText+=' <a href="javascript:setpage(1);document.forms['+formIndex+'].submit()" class="pageLink" title=第一页>';
//showText+='<img src="images/firstpage.gif" border="0" />';
showText+='首页';
showText+='</a></td>';

showText+='  <td width=30 height=25 > ';
if(currentPage>1){
	pageId = currentPage-1;
	showText+='<a href="javascript:setpage('+pageId+');document.forms['+formIndex+'].submit()" class="pageLink" title=上一页>';
}
//showText+='<img src="images/prevpage.gif" border="0" />';
showText+='上页';
if(currentPage>1){
	showText+='</a>';
}
  //设置默认分页索引个数
  var pageIndexSize = 5 ;

  if (pageCount>pageIndexSize){
    //如果总页数>分页索引个数
    //当前页显示在第一位
    first = currentPage ;

    if ((pageCount-currentPage+1)<pageIndexSize) {
      //如果剩余页数小于分页索引个数，则最后一个索引就是总页数+1
      last = pageCount + 1 ;
    } else {
      //如果剩余页数>=分页索引个数，则最后一个索引=当前页+索引个数
      last = currentPage + pageIndexSize ;
    }

	if ((last-pageIndexSize)>0)
	{
		first = (last-pageIndexSize) ;
	}
  } else {
    //如果总页数<=分页索引个数，则最后一个索引=总页数+1
    first = 1 ;
    last = pageCount + 1 ;
  }

for(var k=first;k<last;k++){
	showText+='<td width="20" align="center" background="images/numbg.gif" style='+bgpic_no_repeat+'> ';
	showText+='<table width="20"  border="0" align="center" cellpadding="0" cellāspacing="0" >';
//与当前页相匹配则样式显示为红否则默认
	if(k==currentPage){
 		numClass = page_num_cur;
	}else{
 		numClass = page_num;
	}

	showText+='<tr><td width=100% align=center valign=top  >';
	showText+='<a href="javascript:setpage('+k+');document.forms['+formIndex+'].submit()" class="pageLink" > ';
	showText+='<font style="'+numClass+'"> '+k+' </font>';
	showText+='</td></a>';
	showText+='</tr>';
	showText+='</table>';
	showText+='</td>';
}
//循环结束

//
showText+='<td width=30 >';
if(currentPage<pageCount){
pageId=currentPage+1;
showText+='<a href="javascript:setpage('+pageId+');document.forms['+formIndex+'].submit()" class="pageLink" title=下一页>';
}
//showText+='<img src="images/nextpage.gif" border="0" />';
showText+='下页';
if(currentPage<pageCount){
showText+='</a>';
}
showText+='</td>';

showText+='<td width=20 > ';
showText+='<table width=30 border=0 cellspacing=0 cellpadding=0>';
showText+='<tr> ';
showText+='<td><div align=left> <a href="javascript:setpage('+pageCount+');document.forms['+formIndex+'].submit()" class="pageLink"  title=最后一页>';
//showText+='<img src="images/lastpage.gif" border="0" />';
showText+='尾页';
showText+='</a></div></td>';
showText+=' </tr>';
showText+='</table>';
showText+='</td>';

showText+='<td  style="'+page_font+'">';
showText+='跳到';
showText+='<input onkeyup="onlyNum(this)" onafterpaste="onlyNum(this)" name="pageID" id="pageID" type="text" style="height:15px; font-size:12px" size="2" value='+ currentPage +' />';
showText+='页 ';
showText+='<a href="javascript:document.forms['+formIndex+'].submit();" class="pageLink" title=跳转到指定页>';
showText+='<img src="style/images/go.gif" border="0" /></a>&nbsp;&nbsp;&nbsp;';
showText+='每页';
showText+='<input onkeyup="onlyNum(this)" onafterpaste="onlyNum(this)" id="pageSize" name="pageSize" type="text" style="height:15; font-size:12px" size="2" value='+ pageSize +' />';
showText+='行 ';
showText+='<a href="javascript:document.forms['+formIndex+'].submit();" class="pageLink" title=每页行数设置>';
showText+='<img src="style/images/go.gif" border="0" /></a>';
showText+='</td>';

showText+='</tr></table>';
document.write(showText);
}
function setpage(pageID){
	document.getElementById("pageID").value = pageID;
}
function onlyNum(obj) {
    if(/\D/.test(obj.value)){
    alert('只能输入数字');
    document.execCommand("undo")
	}
}
