
function userLevelClass(){
    var outStr=null;
	var selectObj=null;
	
    this.loadUI=function(){
		var t=new outTitle();
		t.add("等级名","","180");
		t.add("积分","","80");
		t.add("图标","","180");
		t.obj=document.getElementById("groupTitle");
		t.create();	
		
		var tools=new toolsClass();
		tools.add("","删除","uLevel.delLevel()","删除选定用户等级")
		tools.add("","刷新","uLevel.loadData()","删除选定用户等级")
		tools.create(toolsDiv)
	}
	
	
    this.loadData=function(){
    		//var objResponse=new JHttpResponse();
		//objResponse.write("page","1");
		$("groupBody").innerHTML="";
		var out=objAjax.getText("post","saveUser.aspx?type=readLevel",null,null);
			
		//alert(out)
	    out= comminute(out,c1,c2);  //分割数据
		
		
		//[ID],[GroupName],[IsDefault],[IsGuest] 
		// 0        1           2        3
		var wData=new tabList();
		  wData.obj=document.getElementById("groupBody");
		  wData.rowid="groupRow_";            //行的ID, 列ID=行ID_行号如(  [abc_][_0])
		  wData.rowClass="tabListBodyRow";                 //行的样式
		  wData.mode=1;                      //数据显示的格式
		  wData.isCheckbox= false ;             //加上复选框
		  wData.checkBoxID="groupBox";         //复选框名
		  wData.onmouseroverRun="uLevel.rowonmouseover";           //鼠标移上
		  wData.onmouseroutRun="uLevel.rowonmouseout";             //鼠标移走
		  wData.onclickRun="uLevel.rowonclick";                    //鼠标单击
		  wData.ondblclickRun="";                   //鼠标双击
		  wData.add(raadArray(out,1,1),"listBodyOption","180");    //添加一列数据  ID
		  wData.add(raadArray(out,2,1),"listBodyOption","80");    //添加一列数据 用户组名
		  wData.add(raadArray(out,3,1),"listBodyOption","180");    //添加一列数据 用户组名
		  wData.addid(raadArray(out,0,1));                         //添加行标识, 标识 被添加 为TID属性和复框的VALUE属性
		  wData.create();		  
		  
		  
		  var gObj=document.getElementsByName("groupRow__1"); //字符处理第二列用户组名
		 // alert(defaultObj);
		  for (var i=0;i<gObj.length;i++){
			  var gname=gObj[i].innerText;
			  gObj[i].innerHTML="";
			  var tempObj=document.createElement("input");
			  tempObj.type="text";
		      var textObj=gObj[i].appendChild(tempObj);
			  textObj.value=gname;
			  textObj.className="userGroupName";
			  textObj.style.width="50px";
			  textObj.title="点击修改积分";
			  textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onblur=function(){
				   this.className="userGroupName"; 
			  }
			  textObj.onchange=function(){
				  if (this.value=="") {
					  alert("积分不能为空"); 
					  return false;
				  }
				  var v=new validate()
				  if (isNaN(this.value)){
					  alert("积分只能是数字"); 
					  this.value=this.value.replace(/[\/\*,\.;※⊙\"(><'\=\[\]\{\}]{1,}/g,"")
					  return false;
				  }
				  var objResponse=new JHttpResponse();
				  objResponse.write("levelInt",this.value);
				  objResponse.write("id",uLevel.getobj().tid);
				 
				 // alert(gList.getobj().tid);
				  var out=objAjax.getText("post","saveUser.aspx?type=modiLevelInt",objResponse,null);
				  if (out!="OK"){
					//   alert(erStr(out));
				  }
			 }
			 
			 
		  }
		  


		  var gObj=document.getElementsByName("groupRow__0"); //字符处理第一列用户等级名
		 // alert(defaultObj);
		  for (var i=0;i<gObj.length;i++){
			  var gname=gObj[i].innerText;
			  gObj[i].innerHTML="";
			  var tempObj=document.createElement("input");
			  tempObj.type="text";
		      var textObj=gObj[i].appendChild(tempObj);
			  textObj.value=gname;
			  textObj.className="userGroupName";
			  textObj.style.width="150px";
			  textObj.title="点击修改等级";
			  textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onblur=function(){
				   this.className="userGroupName"; 
			  }
			  textObj.onchange=function(){
				  if (this.value=="") {
					  alert("用户等级不能为空"); 
					  return false;
				  }
				  var v=new validate()
				  if (!v.vString(this.value)){
					  alert("用户等级不能包含符号"); 
					  this.value=this.value.replace(/[\/\*,\.;※⊙\"(><'\=\[\]\{\}]{1,}/g,"")
					  return false;
				  }
				  var objResponse=new JHttpResponse();
				  objResponse.write("levelName",this.value);
				  objResponse.write("id",uLevel.getobj().tid);
				 
				 // alert(uLevel.getobj().tid);
				  var out=objAjax.getText("post","saveUser.aspx?type=modiLevelName",objResponse,null);
				  if (out!="1"){
					   alert(erStr(out));
				  }
			 }
		  }
		  
		  var gObj=document.getElementsByName("groupRow__2"); //字符处理第三列用户图标
		 // alert(defaultObj);
		  for (var i=0;i<gObj.length;i++){
			 /* var gname=gObj[i].innerText;
			  gname="abc.gif";
			  gObj[i].innerHTML="";
			  var tempObj=document.createElement("input");
			  tempObj.type="hidden";
		      var textObj=gObj[i].appendChild(tempObj);
			  textObj.value=gname;
			  
			  tempObj=document.createElement("img");
			  
			  var imgObj=gObj[i].appendChild(tempObj);
			  imgObj.style.height="16px";
			  imgObj.src=gname;
			  //alert(imgObj.fileSize);
			  
			  tempObj=document.createElement("input");
			  tempObj.type="button";
			  var bObj=gObj[i].appendChild(tempObj);
			  bObj.value="修改";
			  bObj.style.cssText="height:18px;font-Size:12px;border: 1px solid #C0C0C0;";
			 
*/
		
			  
			 /* textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onclick=function(){
				 this.className="userGroupName_1"; 
			  }
			  textObj.onblur=function(){
				   this.className="userGroupName"; 
			  }
			  textObj.onchange=function(){
				  if (this.value=="") {
					  alert("用户等级不能为空"); 
					  return false;
				  }
				  var v=new validate()
				  if (!v.vString(this.value)){
					  alert("用户等级不能包含符号"); 
					  this.value=this.value.replace(/[\/\*,\.;※⊙\"(><'\=\[\]\{\}]{1,}/g,"")
					  return false;
				  }
				  var objResponse=new JHttpResponse();
				  objResponse.write("levelName",this.value);
				  objResponse.write("id",uLevel.getobj().tid);
				 
				 // alert(uLevel.getobj().tid);
				  var out=objAjax.getText("post","saveUser.aspx?type=modiLevelName",objResponse,null);
				  if (out!="1"){
					   alert(erStr(out));
				  }
			 }*/
		  }
		  



    }
    

	this.getobj=function(){
		return selectObj;
	}
	
	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{
			form1.userBox[tempObj.i].click()
											   
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=obj;
		
	}
	
	this.delLevel=function(){
		var id=	 selectObj.tid;
		var objResponse=new JHttpResponse();
		objResponse.write("id",id);
		
		// alert(id);
		var out=objAjax.getText("post","saveUser.aspx?type=delLevel",objResponse,null);
		if (out!="1"){
			 alert(erStr(out));
			 return;
		}
		
		this.loadData();
		
	}
	
	this.newLevel=function(){
		var LevelName=$("newLevelName").value;
		if (LevelName==""){
		    alert("用户等级不能为空"); 
			return;	
		}
		var v=new validate()
		 if (!v.vString(LevelName)){
			  alert("用户等级不能包含符号"); 
			  return false;
	    }
		
		var objResponse=new JHttpResponse();
		objResponse.write("LevelName",LevelName);
		
		var out=objAjax.getText("post","saveUser.aspx?type=addLevel",objResponse,null);
		if (out!="1"){
			 alert(erStr(out));
			 return;
		}
		
		this.loadData();
		
		
	}
	
	
}