<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #INCLUDE FILE = "inc.asp" -->
<!-- #INCLUDE FILE = "config.asp" -->
<%Response.Buffer = True
Response.Expires = 0

Dim iGUID, sUserID
iGUID = Request.Cookies("GUID")
sUserID = Request.Cookies("USERID")
%>
<html>
<head>
<script src="inc.js" language="javascript"></script>
<script language="javascript">
<!--
var aPortraits = new Array(
	new Array("经典卡通(101)","portraits/classicalcartoon","gif",101),
	new Array("经典杂和(618)","portraits/mixedcartoon","gif",618),
	new Array("儿童(22)","portraits/child","gif",22),
	new Array("笑脸(88)","portraits/face","gif",88),
	new Array("怪物(202)","portraits/bugbear","gif",202),
	new Array("外星人/机器人(13)","portraits/bugbear","gif",13),
	new Array("胖胖(29)","portraits/fat","gif",29),
	new Array("物体(53)","portraits/object","gif",53),
	new Array("食物(88)","portraits/food","gif",88),
	new Array("动物(419)","portraits/animal","gif",419),
	new Array("飞鸟(35)","portraits/bird","gif",35),
	new Array("昆虫(74)","portraits/insect","gif",74),
	new Array("动漫①(88)","portraits/portraitcartoon1","gif",88),
	new Array("动漫②(78)","portraits/portraitcartoon2","gif",78),
	new Array("卡通系列①(392)","portraits/cartoonmovie1","gif",392),
	new Array("卡通系列②(90)","portraits/cartoonmovie2","gif",90),
	new Array("卡通系列③(82)","portraits/cartoonmovie3","gif",82),
	new Array("卡通系列④(65)","portraits/cartoonmovie4","gif",65),
	new Array("男性(103)","portraits/male","gif",103),
	new Array("女性(93)","portraits/female","gif",93),
	new Array("OICQ（旧）(65)","portraits/oicq","gif",65),
	new Array("中国特色(49)","portraits/chinese","gif",49),
	new Array("蹦蹦像素人(19)","portraits/jump","gif",19),
	new Array("流氓兔(78)","portraits/rabbit","gif",36),
	new Array("VOOZ系列(53)","portraits/vooz","gif",53),
	new Array("其他(208)","portraits/other","gif",208)
);

function init()
{
	for(var i=0;i<aPortraits.length;i++)
	{	form.Directory.options[i] = new Option(aPortraits[i][0]);
		form.Directory.options[i].value = i;
	}
	ShowPortaits(0);
}

function ShowPortaits(value)
{
	for(var i=form.Portrait.length;i>=0;i--)
		form.Portrait.options[i] = null;
	for(i=1;i<=aPortraits[value][3];i++)
	{	form.Portrait.options[i-1] = new Option(i + "." + aPortraits[value][2]);
		form.Portrait.options[i-1].value = aPortraits[value][1] + "/" + i + "." + aPortraits[value][2];
	}
	form.Portrait.options[0].selected = true;
	ShowMyPortrait(form.Portrait.options[0].value);
}

function ShowMyPortrait(value)
{
	form.MyPortrait.src=value;
}

function isEmailError(sEmail){
	var pattern = /^([\.\w-])+@([\.\w-])+(\.)([a-zA-Z]){1,3}$/;
	var flag = pattern.test(sEmail);
	if(flag)//初步检查
	{
		//详细检查
		var str = sEmail.substring(sEmail.indexOf("@") + 1, sEmail.lastIndexOf("."))
		if(/^[\.]./.test(str) || /.[\.]$/.test(str) || /(\.)\1/.test(str))
			return true;
		else
			return false;
	}
	else
		return true;
}

function check(obj){
	//检查用户名
	if(isUserIDErr(obj))
		return false;
	//检查密码1
	if(obj.Password1.value=="")
		{alert("密码不能为空！");
		obj.Password1.focus();
		return false;
		}
	//检查密码2
	if(obj.Password1.value!=obj.Password2.value)
		{alert("两次密码应该相同！");
		obj.Password2.focus();
		return false;
		}
	//检查姓名
	if(obj.NickName.value=="")
		{alert("昵称不能为空！");
		obj.NickName.focus();
		return false;
		}
	//检查性别
	if(obj.Sex.value=="")
		{alert("请选择性别！");
		obj.Sex.focus();
		return false;
		}
	//检查生日
	if(obj.Birthday.value=="")
		{alert("员工生日不能为空！");
		obj.button_birthday.focus();
		return false;
		}
	//检查个人email
	if(isEmailError(obj.Email.value))
		{alert("个人Email不合法！格式为user@domain.com");
		obj.Email.focus();
		return false;
		}
}

function fPopUpCalendarDlg(ctrlobj)
{
	showx = event.screenX - event.offsetX - 4 - 10 ; // + deltaX;
	showy = event.screenY - event.offsetY -168; // + deltaY;
	newWINwidth = 210 + 4 + 18;

	retval = window.showModalDialog("Calendar.asp", "", "dialogWidth:180px; dialogHeight:205px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
	if( retval != null ){
		ctrlobj.value = retval;
	}else{
		//alert("canceled");
	}
}

function isUserIDErr(obj)
{

	if(obj.UserID.value==""||obj.UserID.value.length<3)
		{alert("用户名不能为空，且应该大于2个字符！");
		obj.UserID.focus();
		return true;
		}
	if((/[\W]/.test(obj.UserID.value)) || /\s/.test(obj.UserID.value))
		{alert("用户名不合法！\n用户名只能由英文、数字和下划线组成，中间不能含有空格。\n示例：user_123");
		obj.UserID.focus();
		return true;
		}
	return false;
}

function checkUser()
{
	var obj = document.form;
	if(!isUserIDErr(obj))
		window.self.location = "m_checkaccount.asp?UserID=" + obj.UserID.value + "&CompanyID=" + obj.CompanyID.value + "&DepartmentID=" + obj.DepartmentID.value;
}
//-->
</script>
<script>document.write("<title>"+Title+"</title>");</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="common.css">
</head>
<body <%=g_BodyTag%>>
<!-- #INCLUDE File = "top.asp" -->
<%
If iGUID = Empty Then
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>请您先登陆。</td>
  </tr>
</table>
<%
Else
	Dim oChat, rst
	Set oChat = Server.CreateObject("LSChat.Users")
	oChat.Configure g_SiteName, g_SiteDomain, g_DBString, g_ErrFile, g_ScriptName

	Set rst = oChat.GetChatUser(iGUID)
	If rst.EOF Then
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>您并未开通聊天账号！点<a href="regchatuser.asp">这里</a>开通！</td>
  </tr>
</table>
<%
	Else
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="solid1">
  <form name="form" method="post" action="mchatuser.asp" onSubmit="return check(this)">
    <tr> 
      <td bgcolor="#FFFFFF"> 
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr align="center"> 
            <td colspan="2" background="images/titlebg.gif"><font color="#FFFFFF"><b>修改聊天室用户资料</b></font></td>
          </tr>
          <tr align="left" bgcolor="#BCCBF5"> 
            <td colspan="2"><b><%=Request.Cookies("USERID")%>，如果你要进行密码修改，请打勾</b><input type="checkbox" name="ChangePassword" value="1"></td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>旧密码：</b> <br>
            </td>
            <td> 
              <input type="password" name="OldPassword" size="20">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>新密码：</b> <br>
            </td>
            <td> 
              <input type="password" name="Password1" size="20">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>确认新密码：</b> <br>
            </td>
            <td> 
              <input type="password" name="Password2" size="20">
            </td>
          </tr>
          <tr align="left" bgcolor="#BCCBF5"> 
            <td colspan="2"><b>聊天室用户信息</b></td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>昵称：</b> <br>
            </td>
            <td> 
              <input type="text" name="NickName" size="20" value="<%=rst("NickName")%>">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td><b>组：</b></td>
            <td> 
              <input type="text" name="ChatGroup" size="20" value="<%=rst("ChatGroup")%>" readonly class="readonlyinput">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>性别：</b></td>
            <td> 
              <select name="Sex">
                <%If rst("Sex") Then%>
                <option value="1" selected>男</option>
                <option value="0">女</option>
                <%Else%>
                <option value="1">男</option>
                <option value="0" selected>女</option>
                <%End If%>
              </select>
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td><b>是否公开性别：</b></td>
            <td> 
              <select name="ShowSex">
                <%If rst("ShowSex") Then%>
                <option value="1" selected>是</option>
                <option value="0">否</option>
                <%Else%>
                <option value="1">是</option>
                <option value="0" selected>否</option>
                <%End If%>
              </select>
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>生日：</b> <br>
              格式为1979-1-1</td>
            <td> 
              <input name="Birthday" size="20" readonly value="<%=rst("Birthday")%>">
              <input type="button" name="button_birthday" value="&gt;&gt;" onClick="fPopUpCalendarDlg(Birthday);return false">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>是否公开年龄：</b></td>
            <td> 
              <select name="ShowAge">
                <%If rst("ShowSex") Then%>
                <option value="1" selected>是</option>
                <option value="0">否</option>
                <%Else%>
                <option value="1">是</option>
                <option value="0" selected>否</option>
                <%End If%>
              </select>
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td> <b>电子邮件：</b></td>
            <td> 
              <input type="text" name="Email" size="20" value="<%=rst("Email")%>">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td><b>肖像：</b></td>
            <td>原肖像：<img src="<%=rst("Portrait")%>"> <br>
              新肖像： 
              <select name="Directory" onChange="ShowPortaits(this.value);">
              </select>
              <select name="Portrait" onChange="ShowMyPortrait(this.value);">
              </select>
              <img name="MyPortrait" id="MyPortrait"> 应用新肖像： 
              <input type="checkbox" name="ChangePortrait" value="1">
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td><b>个性宣言：</b></td>
            <td>
              <textarea name="AboutMe" cols="60" rows="5"><%=rst("AboutMe")%></textarea>
            </td>
          </tr>
          <tr bgcolor="#DEE5FA"> 
            <td colspan="2"> 您的聊天账号 <b> 
              <%If rst("State") = 1 Then
				Response.Write "正常"
			ElseIf rst("State") = 2 Then
				Response.Write "被暂时禁用"
			ElseIf rst("State") = 0 Then
				Response.Write "已被完全禁用"
			End If
			%>
              </b> ，最后登陆时间是 <b><%=rst("LastLogin")%></b> ，登陆聊天 <b><%=rst("Logins")%></b> 
              次，在线 <b><%=rst("ChatMinutes")%></b> 分钟，共计发言 <b><%=rst("ChatMessages")%></b> 
              次， <b><%=rst("ChatWords")%></b> 字节。 </td>
          </tr>
          <tr bgcolor="#DEE5FA" align="right"> 
            <td colspan="2"> 
              <input type="hidden" name="GUID" value="<%=iGUID%>">
              <input type="submit" name="Submit" value="提交">
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </form>
</table>
<script language="javascript">
<!--
init();
-->
</script>
<%
	End If
	rst.Close
	Set rst = Nothing
	Set oChat = Nothing
End If
%>
<!-- #INCLUDE File = "bottom.asp" -->
</body>
</html>