function setWH(){
	var w=Element.getWidth(document.getElementById("winDiv"));
	var h=Element.getHeight(document.getElementById("winDiv"));
	try{
		var h1=Element.getHeight(document.getElementById("menuDiv"));
	}catch(e) {
		var h1=0;
	}	
	try{
		var h2=Element.getHeight(document.getElementById("toolsDiv"));
	}catch(e) {
		var h2=0;
	}
	var h3=Element.getHeight(document.getElementById("userTitle"));
	var h4=Element.getHeight(document.getElementById("userPage"));
	var w1=Element.getWidth(document.getElementById("leftDiv"));
	var rDiv=document.getElementById("rightDiv");
	var jobDiv=document.getElementById("userList");
	var lDiv=document.getElementById("leftDiv");
	
	var newH=h-h1-h2;
	var newW=w-w1-2;
	lDiv.style.height=newH+"px";
	rDiv.style.height=newH+"px";
	rDiv.style.width=newW+"px";
	jobDiv.style.width=newW+"px";
	jobDiv.style.height=(newH-h3-h4)+"px";
	rmenu.Xmax=w;
	rmenu.Ymax=h;
}


function  loadUi(){
	
	menu.addMain("新增","","");
	menu.addMain("修改","","");
	menu.addMain("查看","","您要查看哪类用户");
	menu.addMain("设置","","您要对用户作哪些设置");
	menu.addMain("排序","","设置排序方法");
	menu.addMain("工具","","系统工具选项");
	menu.addMain("帮助","",null);
	
	menu.addMenu(0,"新增用户","uList.adduser()","增加新用户")
	menu.addMenu(0,"新增用户组","uList.usergroup()","增加新用户组")

	menu.addMenu(1,"用户","uList.readInfo()","修改当前选定的用户的资料")
	menu.addMenu(1,"用户组","uList.usergroup()","修改用户组设置")
	menu.addMenu(1,"重设用户密码","uList.setUserInfo('pas')","")
	
	menu.addMenu(2,"刷新","uList.loadList(uList.uPage)","")
	menu.addMenu(2,"所有用户","uList.setView('all')","")
	menu.addMenu(2,"管理员","uList.setView('admin')","")
	menu.addMenu(2,"未审用户","uList.setView('ExamineNO')","")
	menu.addMenu(2,"已审用户","uList.setView('ExamineOK')","")
	menu.addMenu(2,"过期用户","uList.setView('EffectDate')","已过期用户")
	menu.addMenu(2,"即将过期用户","uList.setView('EffectDateEx')","15天内会过期的用户")
	menu.addMenu(2,"未锁定用户","uList.setView('LockedNO')","锁定不能登录用户")
	menu.addMenu(2,"已锁定用户","uList.setView('LockedOK')","状态正常用户")
	
	menu.addMenu(3,"删除选择用户","uList.deluser()","")
	menu.addMenu(3,"设置所属组","uList.setUserInfo('group')","")
	menu.addMenu(3,"设置为管理员","uList.setUserInfo('admin')","")
	menu.addMenu(3,"设置有效期","uList.setUserInfo('date')","")
	menu.addMenu(3,"设置锁定","uList.setUserInfo('clock')","")
	menu.addMenu(3,"设置审核状态","uList.setUserInfo('Examine')","")
	menu.addMenu(3,"设置管理员权限","","")
	
	menu.addMenu(4,"按用户名升序","uList.setOrder('userName','')","")
	menu.addMenu(4,"按用户名降序","uList.setOrder('userName','desc')","")
	menu.addMenu(4,"按注册日期升序","uList.setOrder('id','')","")
	menu.addMenu(4,"按注册日期降序","uList.setOrder('id','desc')","")
	menu.addMenu(4,"按有效期升序","uList.setOrder('EffectDate','')","")
	menu.addMenu(4,"按有效期降序","uList.setOrder('EffectDate','desc')","")
	menu.addMenu(4,"按登录次数升序","uList.setOrder('Count_Login','')","")
	menu.addMenu(4,"按登录次数降序","uList.setOrder('Count_Login','desc')","")

	menu.addMenu(5,"用户字段配置","uList.setField()","设置用户扩展资料字段")
	menu.addMenu(5,"用户注册登录规则","uList.loginSet()","")
	menu.addMenu(5,"默认积分规则","","")
	menu.addMenu(5,"用户等级设置","","")
	menu.addMenu(5,"投搞统计","","")
	menu.addMenu(5,"发送EMAIL","","")
	menu.addMenu(5,"EMAIL模板","","")
	menu.addMenu(5,"发送手机短信","","")	
	menu.addMenu(5,"手机短信模板","","")
	menu.addMenu(5,"发送站内短信","","")
	menu.addMenu(5,"站内短信模板","","")
	
	menu.addMenu(6,"帮助主题","","")
	menu.addMenu(6,"关于","","")
	
	menu.create(menuDiv)
	
	
	
	
	tools.add("","新增","uList.adduser()","增加新用户")
	tools.add("","删除","uList.deluser()","删除选定用户")
	tools.add("","通过审核","uList.setExamine()","审核通过未审用户")
	tools.add("","设为管理员","uList.setAdmin()","把用户设置成管理员")
	tools.add("","设有效期","uList.setUserInfo('date')","设置用户的有效期")
	tools.add("","设所属组","uList.setUserInfo('group')","设置用户的所属组别")
	//tools.add("","","","")
	tools.add("","全选","uList.selectAll()","全部选择")
	tools.add("","取消","uList.selectClear()","取消选择")

	tools.create(toolsDiv)
	
	
	var t=new outTitle();
	t.add("用户名","","150");
	t.add("所属组","","150");
	t.add("注册日期","","80");
	t.add("最后登录","","80");
	t.add("登录次数","","60");
	t.add("锁定","","30");
	t.add("审核","","30");
	t.add("有效期","","60");
	t.add("是否管理员","","60");
	t.obj=document.getElementById("userTitle");
	t.create();	
	
	
	userList.onmouseup=function(){  //设置右键菜单
    var button=event.button 
	  if (button!=1){
		   rmenu.clear();
		   rmenu.add("设置所属组","uList.setUserInfo('group')");
		   rmenu.add("设置管理员","uList.setUserInfo('admin')");
		   rmenu.add("设置有效期","uList.setUserInfo('date')");
		   rmenu.add("设置锁定","uList.setUserInfo('clock')");
		   rmenu.add("设置审核","uList.setUserInfo('Examine')");
		   rmenu.add("删除用户","uList.deluser()");
		   rmenu.add("重置密码","uList.setUserInfo('pas')");
		   rmenu.add("|","");
		   rmenu.add("全选","uList.selectAll()");
		   rmenu.add("清除","uList.selectClear()");
		   rmenu.add("|","");
		   rmenu.add("新建用户","uList.adduser()");
		   rmenu.add("新增用户组","uList.usergroup()");
		   rmenu.add("","listIco()");
		   rmenu.add("刷新页面","location.reload()");
		   rmenu.create();
		   isClearMenu=0;
		   setTimeout("isClearMenu=1",100);
	  }else{
		   rmenu.clear();
	   }
	}
	
	document.body.onmouseup=function(){
		if (isClearMenu==1){
		  rmenu.clear();
		}
	}
}


	
function userClass(){
	this.userList=null;
	var tempObj=null;
	var selectObj=null;
	this.uPage=null;
	this.viewType="all";
	this.setlectid="";
	var order="id";
	var orderType="desc";
	var pagesize="20";
	var where="";
	
	this.setPagesize=function(int){
		pagesize=int;
	}
	
	this.setOrder=function(field,type){ //设置排序方式
		order=field;
		orderType=type;
		this.loadList(this.uPage);
	}

	this.loadList=function(page){
		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);
		objResponse.write("view",this.viewType);
		var out=objAjax.getText("post","listSever.aspx?type=readList",objResponse,null);
		if (out==""){
			alert("对不起,没找到");
			this.viewType="all";
			return false;
		}
		//alert(out)
		
		  out= comminute(out,c1,c2);  //分割数据
		  this.userList=out;
		  
		  var page=out[0];
		  this.mPage=page[2];
		  //id,UserName,IsLocked,RegDate,Count_Login,Date_Login,IsExamine,EffectDate,GroupName,Last_IP,IPaddress,isAdmin
		  //0   1          2       3         4           5          6         7          8       9        10         11
		  
		  //显示内容
		  var wData=new tabList();
		  wData.obj=document.getElementById("userList");
		  wData.rowid="userRow_";                          //行的ID
		  wData.rowClass="tabListBodyRow";                 //行的样式
		  wData.mode=1;                                    //数据显示的格式
		  wData.isCheckbox=true;                          //加上复选框
		  wData.checkBoxID="userBox";                      //复选框名
		  wData.onmouseroverRun="uList.rowonmouseover";           //鼠标移上
		  wData.onmouseroutRun="uList.rowonmouseout";             //鼠标移走
		  wData.onclickRun="uList.rowonclick";                    //鼠标单击
		  wData.ondblclickRun="uList.readInfo";                   //鼠标双击
		  wData.add(raadArray(out,1),"listBodyOption","150");    //添加一列数据  用户名
		  wData.add(raadArray(out,8),"listBodyOption","150");    //添加一列数据 用户组
		  wData.add(raadArray(out,3),"listBodyOption","80");     //添加一列数据 注册日期
		  wData.add(raadArray(out,5),"listBodyOption","80");     //添加一列数据  最后登录
		  wData.add(raadArray(out,4),"list_count","60");         //添加一列数据  登录次数
		  wData.add(raadArray(out,2),"listBodyOption","30");     //添加一列数据  状态是否锁定
		  wData.add(raadArray(out,6),"listBodyOption","30");     //添加一列数据  用户是否审核
		  wData.add(raadArray(out,7),"listBodyOption","60");     //添加一列数据  用户有效期
		  wData.add(raadArray(out,11),"listBodyOption","60");     //添加一列数据  用户身份,是否管理员
		  wData.addid(raadArray(out,0));                         //添加行标识 TID
		  wData.create();		  
		  //内容显示完成
		  
		  //显示分页
		  var wPage=new outPage();
		  wPage.obj=document.getElementById("userPage");
		  wPage.pageArray=page;
		  wPage.run="uList.loadList";
		  wPage.create();
		  //分页显示完
		 
		 
		 //处理表中字符
		  var cObj=document.getElementsByName("userRow__5"); //字符处理第五列, 用户是否锁定
		  for (var i=0;i<cObj.length;i++){
			  if (cObj[i].innerText=="0"){
				  cObj[i].innerText="否";
				  cObj[i].title="未锁定";
			  }else{
				  cObj[i].innerHTML="<B>是</B>";
				  cObj[i].title="锁定";
			  }
		  }
		  
		  var cObj=document.getElementsByName("userRow__6"); //字符处理第六列, 用户是否审核
		  for (var i=0;i<cObj.length;i++){
			  if (cObj[i].innerText=="0"){
				  cObj[i].innerHTML="<B>否</B>";
				  cObj[i].title="未审";
			  }else{
				  cObj[i].innerHTML="是";
				  cObj[i].title="已审";
			  }
		  }
		  
		  var cObj=document.getElementsByName("userRow__8"); //字符处理第六列, 用户是否管理员
		  for (var i=0;i<cObj.length;i++){
			  switch (cObj[i].innerText){
				 case "0":
				  cObj[i].innerHTML="否";
				  cObj[i].title="否";
				  break;
				 case "1":
				  cObj[i].innerHTML="<b>是</b>";
				  cObj[i].title="是";
				  break;
				 case "2":
				  cObj[i].innerHTML="<font color='#ff0000'><b>Admin</b></font>";
				  cObj[i].title="系统管理员";
				  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{
			if (form1.userBox[tempObj.i].checked==true){
				form1.userBox[tempObj.i].checked=false;
			}else{
				form1.userBox[tempObj.i].checked=true;
			}
			if (selectObj!=null & selectObj!=obj){
				selectObj.className="tabListBodyRow";
			}
		}catch(e) {}
		selectObj=obj;
		
	}
	
	this.addFind=function(){  //添加 搜索项目
	
		var out=objAjax.getText("post","saveUser.aspx?type=readGroup",null,null);
		 out= comminute(out,c1,c2); 
		 //alert(out);
		//[ID],[GroupName],[IsDefault],[IsGuest] 
		// 0        1           2        3
		for (var i =0;i<out.length-1;i++){
			var opt=document.createElement("option");
			opt.text=out[i][1];
			opt.value=out[i][0]+"";
			formFind.GroupID.options.add(opt);
		}
	
	
		var out=objAjax.getText("post","saveUser.aspx?type=readFindConfig",null,null);
		out=comminute(out,c1,c2); 
		obj=document.getElementById("exFind");
		for (var i=0;i<out.length-1;i++){
			var tempObj=document.createElement("div");
			var newObj=obj.appendChild(tempObj);
			newObj.className="findDiv";
			
			tempObj=document.createElement("span");
			var textSpan=newObj.appendChild(tempObj);
			textSpan.innerText=out[i][1]+":";
			textSpan.className="findText";
			//[fieldName],[fieldAsName],[isFind],[isNull],[editMode] ,[isRow]
			//  0             1              2      3         4	("0"单行字符 "1"多行字符  2"数字  "3"日期 "4"EMAIL "5"网址 "6"IP) 5
			out[i][4]=parseInt(out[i][4])
			
			
			if (out[i][4]<20) {
				
				//newObj.style.backgroundColor ="#cfcfcf"
				tempObj=document.createElement("input");
				var textObj=newObj.appendChild(tempObj);
				textObj.id=out[i][0];
				textObj.name=out[i][0];
				textObj.isV="1";
				textObj.className="findInput";
				//textObj.title=out[i][1];
				//alert(out[i][3])
				//textObj.notNull=out[i][3];
				/*//if (out[i][5]=="1"){
					newObj.style.width="99%"
					textObj.style.width="450px"
				}else{
					textObj.style.width="150px"
					newObj.style.width="48%"
					
				}*/
				textObj.max="100";
				switch (out[i][4]){
					case 2:
						textObj.isNum="1";
						textObj.max="";
						break;
					case 3:
						textObj.isDate="1";
						break;
					case 4:
						textObj.isMail="1";
						break;
					case 5:
						textObj.isNurl="1";
						break;
					case 6:
						textObj.isIP="1";
						break;
				}
				
			}else{
				if (out[i][5]=="1"){
					newObj.style.width="99%"
				}else{
					newObj.style.width="48%"
				}
				var sindex=out[i][4]-20;
				var findItem=new itemClass();
				findItem.mode="sindex";
				findItem.add(sindex,out[i][0],"findInput");  //添加选项, 选项名, 对象名, 样式表名
				findItem.obj=newObj;
				findItem.create();
				
			}
		}		
	}
	
	this.startFind=function(){  //开始执行搜索
	
		var objs=formFind.getElementsByTagName("*");
		var nameList="";
		for (var i=0;i<objs.length;i++){
			if (objs[i].name!="" & objs[i].name!=null & objs[i].name!="findType"){
				if (nameList.search(objs[i].name+",")==-1){
					nameList=nameList+objs[i].name+","
					//alert(objs[i].name+"|"+objs[i].value)
				}
			}
		}
		var objResponse=new JHttpResponse();
		objResponse.write("fList",nameList);

		var out=objAjax.submit(formFind,"post",true,objResponse)
		where=out;
		//alert(out);
		this.loadList(1);
		
	}
	
	
	this.setView=function(vType){ //设置要显示的用户类型
		this.viewType=vType;
		this.loadList(1);
	}
	
	this.selectAll=function(){ //全选
		var cObj=document.getElementsByName("userBox");
		for (var i=0;i<cObj.length;i++){
			cObj[i].checked=true
		}
	}
	
	this.selectClear=function(){ //取消选择
		var cObj=document.getElementsByName("userBox");
		for (var i=0;i<cObj.length;i++){
			cObj[i].checked=false;
		}
		
	}
	
	this.setUserInfo=function(setType){  //设置用户属性
		var cObj=document.getElementsByName("userBox");
		var l="";
		for (var i=0;i<cObj.length;i++){
			if (cObj[i].checked==true){
				l=l+cObj[i].value+",";
				//break;
			}
		}
		if (l==""){
			alert("请选择用户");
			return false;
		}
		this.setlectid=l;
		var arr=showModalDialog("setUser.htm?type="+setType+"&t="+create_id(), window, "dialogWidth:700px; dialogHeight:450px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
		if (arr!=null){
			this.loadList(this.uPage);
		}
	}
	
	this.setAdmin=function(){ //设置为管理员
		var cObj=document.getElementsByName("userBox");
		var l="";
		for (var i=0;i<cObj.length;i++){
			if (cObj[i].checked==true){
				l=l+cObj[i].value+",";
			}
		}
		var uid=l.substr(0,l.length-1);
		
		var objResponse=new JHttpResponse();
		objResponse.write("uid",uid);
		//alert(uid);
		objResponse.write("isAdmin","1");
		var out=objAjax.getText("post","listSever.aspx?type=saveAdmin",objResponse,null);
		if (out=="OK"){
			this.loadList(this.uPage);
		}else{
			alert(erStr(out));
		}
	}
	
	
	this.setExamine=function(){ //设置为通过审核
		var cObj=document.getElementsByName("userBox");
		var l="";
		for (var i=0;i<cObj.length;i++){
			if (cObj[i].checked==true){
				l=l+cObj[i].value+",";
			}
		}
		var uid=l.substr(0,l.length-1);
		
		var objResponse=new JHttpResponse();
		objResponse.write("uid",uid);
		//alert(uid);
		objResponse.write("IsExamine","1");
		var out=objAjax.getText("post","listSever.aspx?type=savesExamine",objResponse,null);
		if (out=="OK"){
			this.loadList(this.uPage);
		}else{
			alert(erStr(out));
		}
	}
	
	
	this.deluser=function(){  //删除用户
		var cObj=document.getElementsByName("userBox");
		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="listSever.aspx?type=delUser";
		var out=objAjax.submit(form1,"post",true,null);
		if (out=="OK"){
			this.loadList(this.uPage);
		}else if (out=="-1"){
			alert("请选择要删除的用户");
		}else{
			alert(erStr(out));
		}
		
	}
	
	this.readInfo=function(){ //读出用户资料, 修改用户资料
		try{
			var objnum=parent.win.objNum;
			par="wNum="+objnum+"&uid="+selectObj.tid;
			//alert(par)
			parent.win.pCreate("p-modiUser",par,"",true);
		}catch(e) {}
	}
	
	this.adduser=function(){ //新增用户
		var objnum=parent.win.objNum;
		par="wNum="+objnum;
		parent.win.pCreate("p-addUser",par,"",true);
	}
	
	this.usergroup=function(){ //用户组设置
		var objnum=parent.win.objNum;
		par="wNum="+objnum;
		parent.win.pCreate("p-userGroupSet",par,"",true);
	}
	
	this.loginSet=function(){ //用户组设置
		var objnum=parent.win.objNum;
		par="wNum="+objnum;
		parent.win.pCreate("p-userLoginSetup",par,"",true);
	}
	
	this.setField=function(){ //用户字段设置
		var objnum=parent.win.objNum;
		par="wNum="+objnum;
		parent.win.pCreate("p-userFieldConfig",par,"",true);
	}
	
	
	
	
	
}


