	

function loadUI(){ //加载界面设置
	var t=new outTitle();
	t.add("组ID","","90");
	t.add("组名","","250");
	t.add("默认组","","60");
	t.add("匿名组","","60");
	t.obj=document.getElementById("groupTitle");
	t.create();	
	
	var tools=new toolsClass();
	//tools.add("","新增","gList.newGroup()","增加新用户组")
	tools.add("","设置为默认组","gList.setDefaultGroup()","把此组设置为用户注册后默认所属的组")
	tools.add("","设置为匿名组","gList.setGuestGroup()","设置匿名用户得到此组的权限")
	tools.add("","删除","gList.delgroup()","删除选定用户组")
	tools.add("","帮助","","使用帮助")
	//tools.add("","","","")
	tools.create(toolsDiv)
	
}


function userGroupClass(){
	var tempObj, selectObj
	
	this.getobj=function(){
		return selectObj;
	}
	
	this.loadGroup=function(outStr){
		//var objResponse=new JHttpResponse();
		//objResponse.write("page","1");
		if (outStr==null){
			var out=objAjax.getText("post","saveUser.aspx?type=readGroup",null,null);
		}else{
			out=outStr;
		}
	    out= comminute(out,c1,c2);  //分割数据
		
		//alert(out)
		//[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=true;             //加上复选框
		  wData.checkBoxID="groupBox";         //复选框名
		  wData.onmouseroverRun="gList.rowonmouseover";           //鼠标移上
		  wData.onmouseroutRun="gList.rowonmouseout";             //鼠标移走
		  wData.onclickRun="gList.rowonclick";                    //鼠标单击
		  wData.ondblclickRun="";                   //鼠标双击
		  wData.add(raadArray(out,0,1),"listBodyOption","90");    //添加一列数据  ID
		  wData.add(raadArray(out,1,1),"listBodyOption","250");    //添加一列数据 用户组名
		  wData.add(raadArray(out,2,1),"listBodyOption","60");     //添加一列数据 是否默认组
		  wData.add(raadArray(out,3,1),"listBodyOption","60");     //添加一列数据  是否匿名组
		  wData.addid(raadArray(out,0,1));                         //添加行标识, 标识 被添加 为TID属性和复框的VALUE属性
		  wData.create();		  
		  
		  var defaultObj=document.getElementsByName("groupRow__2"); //字符处理第三列
		 // alert(defaultObj);
		  for (var i=0;i<defaultObj.length;i++){
			  if (defaultObj[i].innerText=="0"){
				  defaultObj[i].innerText="否";
				  defaultObj[i].title="否";
			  }else{
				  defaultObj[i].title="是";
				  defaultObj[i].innerHTML="<B>是</B>";
			  }
		  }
		  
		  var defaultObj=document.getElementsByName("groupRow__3"); //字符处理第四列
		 // alert(defaultObj);
		  for (var i=0;i<defaultObj.length;i++){
			  if (defaultObj[i].innerText=="0"){
				  defaultObj[i].innerText="否";
				  defaultObj[i].title="否";
			  }else{
				  defaultObj[i].innerHTML="<B>是</B>";
				   defaultObj[i].title="是";
			  }
		  }
		  
		  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.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("groupname",this.value);
				  objResponse.write("groupid",gList.getobj().tid);
				 
				 // alert(gList.getobj().tid);
				  var out=objAjax.getText("post","saveUser.aspx?type=modiGroup",objResponse,null);
				  if (out!="OK"){
					   alert(erStr(out));
				  }
				 
			 }
		  }
		  
		  
		  
		  
	}
	

	this.newGroup=function(){ //显示新增用户组的层
		document.getElementById("newgroup").style.display="";
		form2.newGroupName.value="";
		form2.newGroupName.focus();
	}
	
	this.saveNewGroup=function(){
		var v=new  validate();
		v.form=form2;
		if (!v.start()){
			return false;
		}
		var objResponse=new JHttpResponse();
		objResponse.write("groupname",form2.newGroupName.value);
		objResponse.write("groupid","");
		//alert(form2.newGroupName.value);
		var out=objAjax.getText("post","saveUser.aspx?type=newGroup",objResponse,null);
	   $("newGroupName").value="";
		this.loadGroup(out);
	
	}
	
	
	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{
			if (form1.groupBox[tempObj.i].checked==true){
				form1.groupBox[tempObj.i].checked=false;
			}else{
				form1.groupBox[tempObj.i].checked=true;
			}
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=obj;
		
	}
	
	this.delgroup=function(){
		var cObj=document.getElementsByName("groupBox");
		var l=0;
		for (var i=0;i<cObj.length;i++){
			if (cObj[i].checked==true){
				l=1;
				break;
			}
		}
		if (l==0){
			alert("请你选择要删除的用户组");
			return false;
		}
		if (window.confirm("你确认要删除这些用户组吗?")){
			var out=objAjax.submit(form1,"post",true,null);
			//alert(out);
			if (out.search(c1)==-1){
				alert(erStr(out));
				return false;
			}
			out=out.split(c1);
			var str="";
			for (i=0;i<out.length-1;i++){
				if (out[i]=="1"){
					str=str+"匿名用户组未能删除\n"
				}else if(out[i]=="2"){
					str=str+"默认用户组未能删除\n"
				}else{
					out[i]=parseInt(out[i])-10;
					var rObj=document.getElementsByName("groupRow_");
				
					for (var x=0;x<rObj.length;x++){
						 //alert(rObj[x].tid+"\n"+out[i]);
						if (parseInt(rObj[x].tid)==out[i]){
						
							rObj[x].removeNode(true);
						}
					}
				}
			}
			if (str!=""){
				alert(str);
			}
		}
	}
	
	this.setGuestGroup=function(){
		if (selectObj==null){
			alert("请你选择用户组");
			return false;
		}
		var groupid=selectObj.tid;
		var objResponse=new JHttpResponse();
		objResponse.write("groupid",groupid);
		//alert(form2.newGroupName.value);
		var out=objAjax.getText("post","saveUser.aspx?type=setGuestGroup",objResponse,null);
		this.loadGroup(out);
		
	}
	
	
		this.setDefaultGroup=function(){
		if (selectObj==null){
			alert("请你选择用户组");
			return false;
		}
		var groupid=selectObj.tid;
		var objResponse=new JHttpResponse();
		objResponse.write("groupid",groupid);
		//alert(form2.newGroupName.value);
		var out=objAjax.getText("post","saveUser.aspx?type=setDefaultGroup",objResponse,null);
		this.loadGroup(out);
		
	}
	
	
	
	
}