$(document).ready(function() {
	
	// 设置上一页、下一页信息
	var curpage = $("#curpage").length>0 ? parseInt($("#curpage").text()) : "1";
	var totalpage =  $("#totalpage").length>0 ? parseInt($("#totalpage").text()) : "1";
	if(curpage==1)
	{
		if(curpage!=totalpage && totalpage!=0)
		{
			$(".prepage").html(prePage);
			curpage = curpage+1;
			$(".nextpage").html("<a href='"+baseUrl+"-"+number+"-"+curpage+"-"+display+"-"+sort+"-"+status+"."+extend+"'>"+nextPage +"</a>");

		}
		else
		{
			$(".prepage").html(prePage);
			$(".nextpage").html(nextPage);
		}
	}
	else if(curpage!=1 && curpage!=totalpage)
	{
		var curpage1=curpage-1
		var curpage2=curpage+1
		$(".prepage").html("<a href='"+baseUrl+"-"+number+"-"+curpage1+"-"+display+"-"+sort+"-"+status+"."+extend+"'>"+nextPage +"</a>");
		$(".nextpage").html("<a href='"+baseUrl+"-"+number+"-"+curpage2+"-"+display+"-"+sort+"-"+status+"."+extend+"'>"+nextPage +"</a>");
	}
	else
	{
		$(".nextpage").html(nextPage);
		curpage = curpage-1;
		$(".prepage").html("<a href='"+baseUrl+"-"+number+"-"+curpage+"-"+display+"-"+sort+"-"+status+"."+extend+"'>"+nextPage +"</a>");
	}

	//给页码文本框绑定onkeyup事件
	$("#gopage").bind("keyup",function(){
		$("#gopage").attr({
			"value" : $("#gopage").val().replace(/\D/g,"")
		});
	});
	//给跳转按钮绑定onclick事件
	$("#go").bind("click",function(){
		var pageNum = $("#gopage").val();
		if(pageNum.replace(new RegExp("(^[\\s]*)|([\\s]*$)", "g"), "") != "" )
        {
            if(pageNum != "0")
            {
                if(pageNum > totalpage)
                {
                    alert("输入的数字大于总页数");
                    $("#gopage").attr("value","");
                    return false;
                }
                else
                {
					window.location.href=baseUrl+"-"+number+"-"+pageNum+"-"+display+"-"+sort+"-"+status+"."+extend
                }
            }
            else
            {  
                alert("输入错误！");
                $("#gopage").attr("value","");
                return false;
            }
        }
        else
        {
            alert("请输入要跳转到的页面");
           $("#gopage").attr("value","");
            return false;
        }
	});
});