/*
前台分页控件
*/
function Page(id,url,opt){
	var T=this,q;
	opt=opt||{size:1,pn:1,resp:'text'};
	T.params={};
	T.callback=opt.callback||function(d){
		var e=util.$(id);
		if(e){e.innerHTML=d
			var a=e.getElementsByTagName('a'),n,h;
			util.map(a,function(e){
				if('_p'==(e.name||e.getAttribute('name'))){
					e.onclick=function(){
						url=T.getUrl((e.v||e.getAttribute('v')).substr(1),1);
						q=(e.v||e.getAttribute('v')).substr(1);
						T.exec();
						return false
					}
				}				
			});
		}  
	};
	T.exec=function(e){//执行
		util.ajax(url, function(d){
			T.callback.call(this,d);
		},{resp:opt.resp})
	};
	T.setParam=function(k,v){//增加参数
		T.params[k]=v;
	};
	T.getUrl=function(q,b){//获取请求参数
		var s=q,a=T.params,r=/^(.*)(\?.*)$/ig,m=url.match(r)?RegExp.$1:'';
		for(var p in a){
			s+='&'+p+'='+encodeURIComponent(a[p])
		}
		return (m?(b?m+'?':url+'&'):url+'?')+s;
	}
	//设置请求参数
	url=T.getUrl('pgNumber='+(opt.pn||1)+(opt.size?'&pgSize='+opt.size:''));
	return T
}