
var objAjax=new JAjax();
var tools=new toolsClass();
var mList=new uModiClass();
		
function loadPage(){
	tools.add("","全选","mList.selectAll()","全部选择")
	tools.add("","取消","mList.selectClear()","取消选择")
    tools.add("","删除","mList.del()","删除选定")
	tools.create(toolsDiv)
	
	
	var t=new outTitle();
	t.add("创建人","","60");
	t.add("类型","","70");
	t.add("栏目","","100");
	t.add("日期","","80");
	t.add("标题","","250");
	t.obj=document.getElementById("userTitle");
	t.create();	
	mList.loadList();
	
	loadBodyclick();
	
    
}

function uModiClass(){
	
	this.modiList=null;
	this.uPage=null;
	this.viewType="all";
	var order="id";
	var orderType="desc";
	var pagesize="20";
	var where="";
	var tempObj=null;
	var selectObj=null;
	
	this.setPagesize=function(int){
		pagesize=int;
	}
	
	this.setOrder=function(field,type){ //设置排序方式
		order=field;
		orderType=type;
		this.loadList(this.uPage);
	}
	
	
	this.loadList=function(){
		if (page==null){
			page=1;
		}
		this.uPage=page;
		
		var objResponse=new JHttpResponse();
		objResponse.write("order",order+" "+orderType);
		objResponse.write("page",page);
		objResponse.write("pagesize",pagesize);
		objResponse.write("where",where);
		var out=objAjax.getText("post","userModiContent.aspx?type=readList",objResponse,null);
		if (out==""){
			alert("对不起,没找到");
			this.viewType="all";
			return false;
		}else if(out.indexOf(c1)==-1){
			alert(erStr(out));
			return;
		}
    	out= comminute(out,c1,c2);  //分割数据
	    this.modiList=out;
		
	//		menuName,tabTitle,tabid,tabid,createTime,userName,setType , ID
	//       0             1    2    3         4       5            6    7
	
	 var page=out[0];
	 this.mPage=page[2];
		
	
	  var wData=new tabList();
	  wData.obj=document.getElementById("dataList");
	  wData.rowid="mRow_";                          //行的ID
	  wData.rowClass="tabListBodyRow";                 //行的样式
	  wData.mode=1;                                    //数据显示的格式
	  wData.isCheckbox=true;                          //加上复选框
	  wData.checkBoxID="mBox";                      //复选框名
	  wData.onmouseroverRun="mList.rowonmouseover";           //鼠标移上
	  wData.onmouseroutRun="mList.rowonmouseout";             //鼠标移走
	  wData.onclickRun="mList.rowonclick";                    //鼠标单击
	  wData.ondblclickRun="mList.rowondbclick";                   //鼠标双击
//  t.add("类型","","40");
//	t.add("栏目","","50");
//	t.add("创建人","","50");
//	t.add("日期","","50");
//	t.add("标题","","250");
	  wData.add(raadArray(out,5),"listBodyOption","60");     //添加一列数据 发布人
	  wData.add(raadArray(out,6),"listBodyOption","70");    //添加一列数据  类型
	  wData.add(raadArray(out,0),"listBodyOption","100");    //添加一列数据  栏目
	  wData.add(raadArray(out,4),"listBodyOption","80");     //添加一列数据  日期
	  wData.add(raadArray(out,1),"list_count","250");         //添加一列数据  标题 
	  wData.addid(raadArray(out,7));                         //添加行标识 TID
	  wData.create();		  
		  
	  //显示分页
	  var wPage=new outPage();
	  wPage.obj=document.getElementById("pageDiv");
	  wPage.pageArray=page;
	  wPage.run="mList.loadList";
	  wPage.create();
	  //分页显示完
	  
	  //处理表中字符
	  var cObj=document.getElementsByName("mRow__1"); //字符处理第1列
	  for (var i=0;i<cObj.length;i++){
		  switch (cObj[i].innerText){
			  case "0":
				  cObj[i].innerText="未处理";
				  break;
			   case "1":
				  cObj[i].innerText="已查看";
				   break;
			   case "2":
				  cObj[i].innerText="已处理";
				   break;
			   case "3":
				  cObj[i].innerText="已替换";
				   break;
		  }
	  }

	
	  
	}
	
	
	 this.rowonmouseover=function(obj){
		tempObj=obj;
		obj.className="tabListBodyRow_1";
	}
	
	
	this.rowonmouseout=function(obj){
		//	alert(obj.tid)
		tempObj=null;
		if (obj !=selectObj){
			obj.className="tabListBodyRow";
		}
	}
	
	this.rowonclick=function(obj){
		try{
			//alert(tempObj.i);
			var x1=tempObj.i;
			form1.mBox[x1].click();
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=obj;
		
	}
	
	this.rowondbclick=function(){ //读出用户资料, 修改用户资料
		try{
			var objnum=parent.win.objNum;
			par="wNum="+objnum+"&errID="+selectObj.tid;
			//alert(par)
			parent.win.pCreate("p-userModiContentSet",par,"",true);
		}catch(e) {}
	}
	
	this.selectAll=function(){ //全选
		var cObj=document.getElementsByName("mBox");
		for (var i=0;i<cObj.length;i++){
			cObj[i].checked=true
		}
	}
	
	this.selectClear=function(){ //取消选择
		var cObj=document.getElementsByName("mBox");
		for (var i=0;i<cObj.length;i++){
			cObj[i].checked=false;
		}
		
	}
		

	this.del=function(){  //删除
		var cObj=document.getElementsByName("mBox");
		var l="";
		for (var i=0;i<cObj.length;i++){
			if (cObj[i].checked==true){
				l=cObj[i].value+",";
				break;
			}
		}
		if (l==""){
			alert("请选择要删除的记录");
			return false;
		}
		
		form1.action="userModiContent.aspx?type=del";
		var out=objAjax.submit(form1,"post",true,null);
		if (out=="OK"){
			this.loadList(this.uPage);
		}else if (out=="-1"){
			alert("请选择要删除的记录");
		}else{
			alert(erStr(out));
		}
		
	}	
}
