function adduserClass(){
	this.addType=0;

    this.selectPhoto=function(sysPath){
		var photo=openUpfile(1,sysPath);
		if (photo!=null){
			photo=photo.split(c1);
			photo=photo[photo.length-2];
			imgobj=document.getElementById("userPhotoIMG");
			imgtext=document.getElementById("userPhotoUrl");
			imgobj.src=photo;
			imgtext.value=photo;
		}
	}
	
	
	this.save=function(){
		
		var v=new validate();
		v.form=form1;
		if (!v.start()){
			return false;
		}
		
		if (isNaN(form1.Mobile.value)&form1.Mobile.value!=""){
			alert("请正确填写手机号");
			return false;
		}
		if ($("PassWord")!=null){
			if (form1.PassWord.value!=form1.PassWord1.value){
				alert("密码和确认密码不一致请重新填写");
				return false;
			}
		}else{
			if (uid=="" | uid==null){
				return;
			}
		}
		var action=form1.action
		if (action.search(/type=/g)==-1){
			form1.action=form1.action+"type=add";
		}
		/*var obj=form1.getElementsByTagName("input");
		for (var i=0;i<obj.length;i++){
			alert("name: "+obj[i].name+"   id: "+obj[i].id+"    value:"+obj[i].value)
			
		}*/
		
		//alert(this.addType);
		
		var objResponse=new JHttpResponse();
		if (uid==null){
			uid="";
		}
		objResponse.write("uid",uid);
		objResponse.write("addType",this.addType);
		var out=objAjax.submit(form1,"post",true,objResponse);
		out=out.split(c1)
		if (out[0]=="OK"){
			if (out[1]=="1"){
				if (this.addType==0){
				
					alert("用户添加成功, "+form1.UserName.value+" 用户的ID:"+out[2]+"\n 点击确定继续添加用户");
					form1.UserName.value="";
					try{
						var wNum =readPar(location.href,"wNum");
						frame=eval("parent.wIframe_"+wNum);
						frame.uList.loadList();
				    }catch(e) {}
					try{
					form1.UserName.focus();				
					}catch(e) {}
				}else{
					alert("用户注册成功");
					location.href="../";
				}
				
					
			}else{
				if (uid!=null & uid!=""){
					alert("用户资料修改成功!")
				}else{
					alert("用户添加失败, "+form1.UserName.value+" 用户已存在.");
				}
			}
			
		}else{
			if (out==""){
				alert("用户注册失败, 可能网站没有开放注册用户,\n或你现在已经是登录状态,无法注册新用户\n也可能是由于你没有添加新用户的权限.")
			}else{
				alert(erStr(out[0]));
			}
		}
		
	}
	
	
	this.loadExinfo=function(sysPath){
		if (sysPath==null){
			var out=objAjax.getText("post","saveUser.aspx?type=readConfig",null,null);
		}else{
			var out=objAjax.getText("post",sysPath+"saveUser.aspx?type=readConfig",null,null);
		}
		out=comminute(out,c1,c2); 
		obj=document.getElementById("userEx");
		for (var i=0;i<out.length-1;i++){
			var tempObj=document.createElement("span");
			var newObj=obj.appendChild(tempObj);
			
			tempObj=document.createElement("span");
			var textSpan=newObj.appendChild(tempObj);
			textSpan.innerText=out[i][1];
			textSpan.style.cssText="width:80px;"
			//[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])
			 switch (out[i][4]){
				//<textarea isV="1" title="签名" max="100" notNull="0" isNum="0"   rows="5" name="idiograph" id="idiograph" cols="74"></textarea>
				case 1:
					tempObj=document.createElement("textarea");
					var textObj=newObj.appendChild(tempObj);
					textObj.id=out[i][0];
					textObj.name=out[i][0];
					textObj.isV="1";
					textObj.rows="4";
					textObj.cols="74";
					textObj.title=out[i][1];
					textObj.notNull=out[i][3];
					textObj.max="100";
					newObj.style.width="99%";
					break;
				 
			default :
			
				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.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],"");  //添加选项, 选项名或序号, 对象名, 样式表名
					findItem.obj=newObj;
					findItem.create(sysPath);
					
				}
				break;
				
			}
			tempObj=document.createElement("span");
			postfixObj=newObj.appendChild(tempObj);
			//alert(out[i][3])
			if (out[i][3]=="1"){
				postfixObj.innerHTML="<font color='#ff0000'>*</font>"
			}
		}
		
	}
	
	
	this.loadUserRecord=function(id,sysPath)  //读出用户资料, 填充数据
	{
		if (!isNaN(id)){
			var objResponse=new JHttpResponse();
			objResponse.write("uid",id);
		    if (sysPath==null){
				var out=objAjax.getText("post","saveUser.aspx?type=readUserRecord",objResponse,null);
			}else{
				var out=objAjax.getText("post",sysPath+"saveUser.aspx?type=readUserRecord",objResponse,null);
			}
			out= comminute(out,c1,c2);
			var field=raadArray(out,0,0);
			var value=raadArray(out,1,0);
			for (var i=0;i<field.length;i++){
				if (field[i]=="userPhoto"){
					$("userPhotoUrl").value=value[i];
					if (sysPath==null){
						$("userPhotoIMG").src=value[i];
					}else{
						$("userPhotoIMG").src=value[i].replace("../../","../");
					}
					//alert(value[i]);
				}
				var obj=document.getElementById(field[i]);
				if (obj!=null){
					
					
					switch (obj.type){
						case "text":
							obj.value=value[i];						
							break;
						 case "radio":
							 findRadio(obj.name,value[i])
						 	break;
						 case "checkbox":
							 findCheckbox(obj.name,value[i]);
						 	break;
						 case "hidden":
							 findSelect(obj.name,value[i])
						 	break;
						default:
							obj.value=value[i];
						
					}
					

				}
			}
			
		}
	}
	
}

