﻿function $(){return document.getElementById(arguments[0]);}
function PageList(pageCount,page,cells,divid){
	cells=cells>pageCount?pageCount:cells
	var loc=location.href.toString();
	if((v=loc.indexOf("Tid="))>0){
		var tid="&"+loc.substring(v,loc.length);
		}
	else{
		var tid="";
		}
	if(page==pageCount){
		nextpage=pageCount;
	}else{
		nextpage=page+1;
	}
	if(page==1){
		prepage=1;
	}else{
		prepage=page-1;
	}
	this.writeHTML=function(){
	$(divid).innerHTML+="<a href='?page="+prepage+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>Previous Page</span></a>";
	if(page>cells){
		$(divid).innerHTML+="<a href='?page=1"+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>1...</span></a>";
	}
	if(page<cells){	
		for(i=1;i<=cells;i++){
		if(i==page){
			$(divid).innerHTML+="<a href='?page="+i+tid+"'><span class='curcalss'  onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>"+i+"</span></a>";
		}else
		{
			if(i==cells&&cells!=pageCount){dian="...";}else{dian="";}
			$(divid).innerHTML+="<a href='?page="+i+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>"+i+dian+"</span></a>";
			}
		}
	}
	else{
		var i=page-(cells-1),j=(page+1)>pageCount?pageCount:page+1;
		for(i;i<=j;i++){
		if(i==page){
			$(divid).innerHTML+="<a href='?page="+i+tid+"'><span class='curcalss'  onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>"+i+"</span></a>";
		}else
		{
			if(i==j&&j<pageCount){dian="...";}else{dian="";}
			$(divid).innerHTML+="<a href='?page="+i+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>"+i+dian+"</span></a>";
			}
		}
	}	
	if(page<pageCount-1&&pageCount>cells){
		$(divid).innerHTML+="<a href='?page="+pageCount+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>"+pageCount+"</span></a>";
	}	
	$(divid).innerHTML+="<a href='?page="+nextpage+tid+"'><span onMouseOver=this.style.backgroundColor='#49280E' onMouseOut=this.style.backgroundColor=''>Next Page</span></a>";	
	}
}
