if(typeof(obj)=="undefined"){
	alert("提示：\n\n数据加载失败！");
}
else{
	var headers=obj.headers;
	var lists=obj.lists;
	var total=obj.total;
	var p=obj.p;
	var q=obj.q;

	var row=(headers==null)?0:headers.length;
	var line=(lists==null)?0:lists.length;

	document.write("<table id='list'>");

	document.write("<tr>");
	for(var i=0;i<row;i++){
		document.write("<th>"+headers[i]+"</th>");
	}
	document.write("</tr>");

	for(var j=0;j<line;j++){
		document.write("<tr>");
		for(var k=0;k<row;k++){
			document.write("<td>"+replace_content(lists[j][k])+"</td>");
		}
		document.write("</tr>");
	}

	document.write("<tr>");
	document.write("<th id='page' colspan='"+row+"'>");
	document.write(show_page(ds,total,p,q));					
	document.write("</th>");
	document.write("</tr>");

	document.write("</table>");
}

function replace_content(content){
	if(typeof(content)=="string"){		
		return content.replace('"','\"');
	}
	else{
		return content;
	}
}

function show_page(ds,total,p,q){
	var page_min=1;
	var page_pre=p-1;
	var page_nex=p+1;
	var page_max=Math.ceil(total/q);

	page_pre=page_pre<page_min?page_min:page_pre;
	page_nex=page_nex>page_max?page_max:page_nex;

	var page_sta=p-5<1?1:p-5;
	var page_end=p+5>page_max?page_max:p+5;					
	
	page_sta=p+5>page_max?page_max-10:page_sta;
	page_end=p-5<0?11-page_sta:page_end;

	page_sta=page_sta<1?1:page_sta;
	page_end=page_end>page_max?page_max:page_end;

	var str="";
	for(var i=page_sta;i<=page_end;i++){
		if(i==p){
			str+="&nbsp;<font color='red'><b>"+i+"</b></font>&nbsp;";
		}
		else{
			str+="&nbsp;<a href='?ds="+escape(ds)+"&p="+i+"&q="+q+"' target='_self'>"+i+"</a>&nbsp;";
		}
	}
	str+="|| 第 "+p+"/"+page_max+" 页 共 "+Math.floor(total)+" 条记录";
	return str;
}