/*
*=================================================================
*                 TopSky Lib For Page Class Function
*
*=================================================================
*文件名称:Js_Page.JS
*摘　　要:TopSky Lib 海量级分页类分页样式
*作　　者:SkyFly
*日　　期:2006年3月7日 14:18:16
*联系方式:QQ:63758635  Msn:lxtx1981@hotmail.com
*=================================================================
*/
var int_StartPage 
var int_PageCount;
var int_PageSize;
var int_PartSize;
var int_RecordCount;
var int_CurPage;
var int_ShowType;
var str_WebURL;
var str_OutStr;

function ShowPage(PageSize,PartSize,RecordCount,WebURL,CurPage,ShowType){
	int_PageSize = PageSize;
	int_PartSize = PartSize;
	int_RecordCount = RecordCount;
	int_CurPage = CurPage;
	int_ShowType = ShowType;
	str_WebURL = WebURL;
	int_PageCount = Math.ceil(int_RecordCount / int_PageSize);
	
	if(int_CurPage%int_PartSize==0){
		int_StartPage = int_CurPage - (int_PartSize-1);
	}
	else{
		int_StartPage = int_CurPage - (int_CurPage % int_PartSize) + 1;
	}
		
	switch(int_ShowType){
	case 1:
		ShowPageInfo();
		ShowFirstPrv();
		ShowNumBnt();
		ShowNextLast();
		ShowJumpPage();
		break;
	case 2:
		ShowPageInfo();
		ShowFirstPrv();
		ShowNumBnt();
		ShowNextLast();
		ShowJumpPage();
		break;
	case 3:
		ShowPageInfo();
		ShowFirstPrv();
		ShowNextLast();
		ShowJumpPage();
		break;
	}
}

function ShowNumBnt(){
	var str_TmpString;
	
	str_TmpString = "";

	for(var i=int_StartPage;i<(int_StartPage+int_PartSize);i++){
		if(i<=int_PageCount)
			switch(int_ShowType){
			case 1:
				if (int_CurPage==i){
					str_TmpString += "<td bgcolor='#FFFFFF'>&nbsp;<strong><font color=red>" + i + "</font></strong>&nbsp;</td>"
				}
				else{
					str_TmpString += "<td bgcolor='#F3F3F3'>&nbsp;<a href='"+str_WebURL+i+"'>" + i + "</a>&nbsp;</td>";
				}
				break;
			case 2:
				if (int_CurPage==i){
					str_TmpString += "[<strong><font color=red>"+i+"</font></strong>]";
				}
				else{
					str_TmpString += "[<a href='"+str_WebURL+i+"'>" + i + "</a>]" ;
				}
			}
	}
	document.write(str_TmpString);
}

function ShowFirstPrv(){
	var int_PrvPage;
	var str_TmpString;

	str_TmpString = "";

	switch(int_ShowType){
	case 1:
		int_PrvPage = int_StartPage - int_PartSize;

		if (int_CurPage>1){
			str_TmpString = "<td bgcolor='#F3F3F3'>&nbsp;<a title='首页' href='"+str_WebURL+"1'><font face='Webdings'>9</font></a>&nbsp;</td>";
		}

		if (int_CurPage>int_PartSize){
			str_TmpString = str_TmpString + "<td bgcolor='#F3F3F3'>&nbsp;<a title='前"+int_PartSize+"页' href='"+str_WebURL+int_PrvPage+"'><font face=Webdings>7</font></a>&nbsp;</td>";
		}
		break;
	case 2:
		int_PrvPage = int_StartPage - int_PartSize;

		if (int_CurPage==1){
			str_TmpString = "<font face='Webdings'>9</font>";
		}
		else{
			str_TmpString = "<a title='首页' href='"+str_WebURL+"1'><font face='Webdings'>9</font></a>";
		}

		if (int_CurPage<=int_PartSize){
			str_TmpString = str_TmpString + "<font face=Webdings>7</font> ";
		}
		else{
			str_TmpString = str_TmpString + "<a title='前"+int_PartSize+"页' href='"+str_WebURL+int_PrvPage+"'><font face=Webdings>7</font></a> ";
		}
		break;
	case 3:
		int_PrvPage = int_CurPage - 1;
		if (int_CurPage>1){
			str_TmpString = "<a title='首页' href='"+str_WebURL+"1'>首页</a> ";
			str_TmpString = str_TmpString + "<a title='上一页' href='"+str_WebURL+int_PrvPage+"'>上一页</a> ";
		}
	}

	document.write(str_TmpString);
}

function ShowNextLast(){
	var int_NextPage;
	var str_TmpString;

	str_TmpString = "";

	switch(int_ShowType){
	case 1:
		int_NextPage = int_StartPage + int_PartSize;

		if (int_NextPage <=int_PageCount){
			str_TmpString = "<td bgcolor='#F3F3F3'>&nbsp;<a title='后"+int_PartSize+"页' href='" + str_WebURL + int_NextPage + "'><font face=Webdings>8</font></a>&nbsp;</td>";		
		}

		if(int_CurPage!=int_PageCount){
			str_TmpString = str_TmpString + "<td bgcolor='#F3F3F3'>&nbsp;<a title='尾页' href='"+str_WebURL+int_PageCount+"'><font face=Webdings>:</font></a>&nbsp;</td>";
		}
		break;
	case 2:
		int_NextPage = int_StartPage + int_PartSize;

		if (int_NextPage > int_PageCount){
			str_TmpString = " <font face=Webdings>8</font>";
		}
		else{
			str_TmpString = " <a title='后"+int_PartSize+"页' href='" + str_WebURL + int_NextPage + "'><font face=Webdings>8</font></a>";
		}

		if (int_CurPage==int_PageCount){
			str_TmpString = str_TmpString + "<font face=Webdings>:</font>";
		}
		else{
			str_TmpString = str_TmpString + "<a title='尾页' href='"+str_WebURL+int_PageCount+"'><font face=Webdings>:</font></a>";
		}
		break;
	case 3:
		int_NextPage = int_CurPage + 1;

		if (int_NextPage <= int_PageCount){
			str_TmpString = " <a title='下一页' href='" + str_WebURL + int_NextPage + "'>下一页 </a>";
			str_TmpString = str_TmpString + "<a title='尾页' href='"+str_WebURL+int_PageCount+"'>尾页</a>";
		}
		break;		
	}
	document.write(str_TmpString);
}

function ShowPageInfo(){
	var str_TmpString;
	
	if (int_ShowType == 1){
		str_TmpString = "<table cellspacing='1' border='1' style='border-collapse: collapse;border: 1px solid #698CC3;background-color:#FFFFFF;' height='25'><tr>";
		str_TmpString = str_TmpString + "<td bgcolor='#E1E1E1'>&nbsp;<strong>"+int_RecordCount+"</strong>&nbsp;</td><td bgcolor='#E1E1E1'>&nbsp;<strong>"+int_CurPage+"/"+int_PageCount+"</strong>&nbsp;</td>";
		document.write(str_TmpString);
	}
	else{
		document.write("共"+int_PageCount+"页 当前第"+int_CurPage+"页 ");
	}
}

function ShowJumpPage(){
	var str_TmpString;

	if (int_ShowType == 1){
		str_TmpString = "<td bgcolor='#F3F3F3'><input type='text' id='page' name='page' size=2 style='border: 1px solid #808080' onkeydown=\"javascript: if(window.event.keyCode==13) window.location='"+str_WebURL+"'+this.value;\"></td></tr></table>";
		document.write(str_TmpString);
	}
	else{
		document.write(" 转到第<input type='text' id='page' name='page' size=2>页");
		document.write("<input name='TopSkyLib_GoPage_Bnt' type='button' value='查看' onclick=\"javascript:window.location='"+ str_WebURL +"'+page.value;\">");
	}
}
