<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="JuSNS.Web.home.ibase.index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title id="ptitle" runat="server"> 帐户设置</title>
<script language="javascript" type="text/javascript" src="../../js/ajax.js"></script>
<script language="javascript" type="text/javascript" src="../../js/public.js"></script>
<link href="../../template/<% Response.Write(JuSNS.Config.UiConfig.SkinStyle); %>/css/base.css" id="skinpath" type="text/css" rel="stylesheet" />
</head>
<body>
<!--头部-->
<%=this.GetHtmlShort()%>
<div id="divhead">
    <%=this.GetHtmlHead()%>
</div>

<div id="divbody">
    <div id="body_first">
        <div class="body_menu"> 
        <%=this.GetHtmlLeft()%>
        </div>
    </div>
    <div id="body_sec">
            <div id="body_mid"> 
                <div class="body_frame"> 
                 <!--主题内容中-->    
                
                <input type="hidden" id="txtYear" runat="server" /><input type="hidden" id="txtDay" runat="server" />                    
                <div class="body_frame_otherinfo">
	                        <div class="title">
                                <div class="l"><img src="../../template/<%Response.Write(JuSNS.Config.UiConfig.SkinStyle); %>/images/site/acc.gif" align="absmiddle" /> <span class="shenlan bold font14 ocolor">帐户设置</span></div>
                                <div class="r"><a href="javascript:window.history.back();" title="返回上一页">返回上一页</a></div>
                                <div class="c"></div>
                            </div>
            		       
                            <div class="nav-menu">
                                <ul>
                                 <li class="current"><a href="index.aspx">帐号管理</a></li>
                                 <li style="display:none;"><a href="advs.aspx">高级管理</a></li>
                                 <li><a href="network.aspx">网络设置</a></li>
                                 <li><a href="msn.aspx">MSN/GTalk</a></li>
                                 <li><a href="mobile.aspx">手机</a></li>
                                 <li><a href="email.aspx">邮件通知</a></li>
                                 <li><a href="../space/edit.aspx">空间设置</a></li>
                                 </ul>
                            </div>        
                     </div>
                <div class="body_sec_all">
                    <div class="content-reshow">
                        你可以通过<a href="../privacy">隐私设置</a>控制谁可以看见以下内容
                    </div>
                    <div class="msg-warn" id="div_Suc" runat="server" style="display: none;"></div>
	                <div class="msg-error" id="div_Error" runat="server" style="display: none;"></div>
	                <!--修改真是姓名-->
                    <div class="content" id="rn" sect:link="修改">
                        <h3>姓名</h3><a href="javascript:'" onclick="javascript:HiddenDis('divName');">修改</a>
                        <div class="c"></div>
                         <div class="pstr">
			                请尽量使用真实姓名，方便你的老朋友找到你。
		                </div>
                        <div class="c"></div>
                        <div id="divName" style="display:none;">
			                <form method="post" action="" class="nf" id="realnameForm">
			                <input type="hidden" id="txtRadioCount" runat="server" value="0" />
			                <input type="hidden" id="txtOldEmail" runat="server" value="0" />
			                <input type="hidden" id="txtFlag" runat="server" value="0" />
				                <p>
					                <label class="f-label" for="realname">姓名</label>
									<input name="realname" type="text" class="f-text" id="realname" runat="server" value="" maxlength="12" /> <input type="button" class="f-button" id="realnameFormSubmit" value="修改姓名" runat="server" onclick="Submit(0);" /> <span class="reshow" id="ttimes" runat="server"></span>
								</p>
			                </form>
		                </div>
                    </div>
                    <div class="line1"></div>
                    <!--修改Email-->
                    <div class="content" id="em" sect:link="修改">
                        <h3>Email</h3><a href="javascript:;" onclick="javascript:HiddenDis('divMyEmail');">修改</a>
		                <div  id="divEmail" style="display:none;">
			                <div class="pending-box">
				                <p>你申请使用下面的 Email，我们向该地址发送了一封邮件以确认其有效，请查收。</p>
		                </div>
		                </div>
		                
		                <div id="divMyEmail" style="display:none;">
		                <div class="pstr">
			                设置你最常用的 Email 地址，用于登录、找回密码等。
		                </div>
			                <form method="post" action="/settings?a=email" id="changeEmail" class="nf">
				                <div>
					                <label class="f-label">联系 Email</label>
						                <%=StrEmail %> <input type="button" class="f-button" value="修改 Email" onclick="Load();" />
				                </div>

			                </form>
		                </div>
		                
                    </div>
                    
                    <div class="line1"></div>
                    <!--修改密码-->
                    
                    <div class="content" id="pw" sect:link="修改">
		                <h3>密码</h3><p><a href="javascript:;" onclick="javascript:HiddenDis('divPwd');">修改</a></p>
		                <div class="pstr">
			                建议使用尽量复杂的密码，最少 4 个字符。
		                </div>
		                <div id="divPwd" style="display:none;">
			                <form method="post" action="" class="nf">
				                <div class="content">
					                <label class="f-label" for="password">旧密码</label>
					                <input name="password" type="password" class="f-text" id="password" maxlength="32" />
				                </div>
				                <div class="content">
					                <label class="f-label" for="newpass">新密码</label>
					                <input name="newpass" type="password" class="f-text" id="newpass"  maxlength="32" />
				                </div>
				                <div class="content">
					                <label class="f-label" for="verifypass">重复新密码</label>
					                <input name="verifypass" type="password" class="f-text" id="verifypass" maxlength="32" />
				                </div>
				                <div class="pstr">
					                <input type="button" class="f-button" value="修改密码" onclick="Submit(1);" />
				                </div>
			                </form>
		                </div>
	                </div>
	             
	                <div class="line1"></div>
	                
	                <div class="content" id="outAccount" sect:link="取消帐户" style="display:none;">
	                     <h3>取消帐户</h3>
	                       <input type="button" class="f-button" value="注销帐户" onclick="clearmy();" />
	                </div>
	                   
	             </div>
	             <div class="spline"></div>   
                    
           </div>  
           <!--底部-->
             <div class="divbottom">
              <%=this.GetHtmlFoot()%>
              </div>
           </div>
   </div>
</div>
</body>
</html>
<script language="JavaScript" type="text/javascript">
function clearmy()
{
    if(window.confirm("确定要注销您的帐户(姓名：<%=UserName %>，电子邮件：<%=eMail %>)吗?\n注销后所有资料将消失，包括照片，相册，好友，无可恢复！\n您可以在取消帐户后再使用相同的帐户重新注册一个帐户，但整个私人好友圈却需要重新建立"))
   {
         if(window.confirm("再次确认：真的要注销您帐户吗？"))
         {
            self.location="index.aspx?r=delaccount";
         }
   } 
}
//提交
function Submit(I)
{
    var str;
    if(I==0)
    {
        if($("realname").value=="")
        {
            alert('请输入姓名！');
            return;
        }
        var array=$("realname").value.split('|');
        if(array.length>1)
        {
            alert("姓名不能含竖线 '|'");
            return;
        }
        str="newName="+$("realname").value+"&Type=Name";
    }
    else if(I==1)
    {
        var newPwd=$("newpass").value;   
        var verifypass=$("verifypass").value;
        var oldPwd=$("password").value;
        if(oldPwd=="")
        {
            alert('请输入旧密码！');
            return;
        }
        if(newPwd=="")
        {
            alert('请输入新密码！');
            return;
        }
        if(verifypass=="")
        {
            alert('请输入重复密码！');
            return;
        }
        
        if(verifypass!=newPwd)
        {
            alert('新密码和重复密码不一致！');
            return;
        }
        str="oldPwd="+oldPwd+"&newPwd="+newPwd+"&Type=Pwd";
    }
    $('div_Error').style.display="none";
    var  options={  
				   method:'post',  
				   parameters:str,  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText;
					     $('div_Suc').style.display="";
					    if (v.indexOf("??")>-1)
					    {
                           $('div_Suc').innerHTML="修改失败！";
                        }
					    else
					    {
                           $('div_Suc').innerHTML=v;
                        }
					}  
				  }; 
       new Ajax.Request('index.aspx',options);
}


function Load()
{
    var n=$("txtRadioCount").value-1;
    if($("rad"+n).checked)
    {
        if($("newemail").value=="")
        {
            alert("请输入Email");
            $("newemail").focus();
            return ;
        }
        else
        {
            var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
           
           if(!myreg.test($("newemail").value))
            {
               alert('提示\n\n请输入有效的E_mail！');
               $("newemail").focus();
               return ;
            }
        }
    }
    var tSTR="";
    var isV='<%=JuSNS.Common.Public.GetXMLValue("RegVer") %>';
    if(isV=="1")
    {
        tSTR="更新后需要重新电子邮件激活，才能登陆本系统！";
    }
    else
    {
        tSTR="更新后需要重新登陆本系统！";
    }
    var content="<div class=\"pstr\"><span class=\"reshow font14\">您确定要更新？"+tSTR+"</span><br />如果你确定要更改，输入本站的密码进行确认</div><div class=\"pstr\">密码：<input type=\"password\" class=\"f-text\" id=\"txtLoginPwd\" /></div><div class=\"line1\"></div>";
    ShowDlg(464,194,'修改Email',content,"LoadOnclick()");
}

function LoadOnclick()
{
    var Pwd=$("txtLoginPwd").value;
    var newEmail=$("newemail").value;
    var flag=0;//添加新邮箱
    
    if(Pwd=="")
    {
        alert('请输入密码！');
        $("txtLoginPwd").focus();
        return;
    }
    var k=$("txtRadioCount").value;
    
    for(var i=0;i<k-1;i++)
    {
        if($("rad"+i).checked)
        {
            newEmail=$("rad"+i).value;
            flag=1;//更换已有邮箱
        }
    }
    
    var  options={  
				   method:'post',  
				   parameters:"Pwd="+Pwd+"&newEmail="+newEmail+"&oldEmail="+$("txtOldEmail").value+"&flag="+flag+"&Type=Email",  
				   onComplete:function(transport)
					{ 
					    var v=transport.responseText; 
                        if(v==1)// 密码错误
                        {
                           $('divEmail').style.display="none";
					       $('div_Error').style.display="";
					       $('div_Suc').style.display="none";
                           $('div_Error').innerHTML="密码错误，请重试";
                            HideAlertBox();
                        }
                        else if(v==2)//邮箱重复
                        {
                            HideAlertBox();
                           $('divEmail').style.display="none";
                           $('div_Error').style.display="none";
                           $('div_Suc').style.display="";
                           $('div_Suc').innerHTML="此邮箱已被用户使用了！";
                        }
                        else if(v==3)//修改成功
                        {
                           HideAlertBox(); 
                           $('div_Error').style.display="none";
                           $('div_Suc').style.display="";
                           var isV='<%=JuSNS.Common.Public.GetXMLValue("RegVer") %>';
                           if(isV=="1")
                           {
                               $('div_Suc').innerHTML="<span class=\"bold font14\">修改邮箱成功！需要通过电子邮件激活您的帐户，才能登录本系统！<a href=\"<%=rooDir %>/EmailActive.aspx?r=<%=this.GetUserID() %>&email="+newEmail+"\">点这里激活电子邮件</a></span>";
                           }
                           else
                           {
                               $('div_Suc').innerHTML="<span class=\"bold font14\">修改邮箱成功！需要重新登陆！<a href=\"<%=rooDir %>/?urls=\">重新登陆</a></span>";
                           }
                           $("divMyEmail").style.display="";
                           if($("rad"+k-1).checked)
                           {
                               $('divEmail').style.display="";
                           }
                           else
                           {
                                $('divEmail').style.display="none";
                           }
                        }
                        else
                        {
                           $('divEmail').style.display="none";
                           $('div_Error').style.display="none";
                           $('div_Suc').style.display="";
                           $('div_Suc').innerHTML="修改邮箱失败！";
                           HideAlertBox();
                        }
					}  
				  }; 
      new Ajax.Request('index.aspx',options);
}

//删除邮箱
function DelEmail(Email)
{
    if(window.confirm("你确定取消该申请吗？"))
    {
       var  options={  
				       method:'post',  
				       parameters:"Email="+Email+"&Type=Del",  
				       onComplete:function(transport)
					    { 
					        var v=transport.responseText; 
					        if (v.indexOf("??")>-1)
					        {
					            alert("删除失败！");
					        }
					        else
					        {
					           window.location.href="index.aspx?flag=divMyEmail";
					        }
					    }  
				      }; 
          new Ajax.Request('index.aspx',options);
      }
}

function HiddenDis(div)
{
    if(div!="0")
    {
        if($(div).style.display=="")
        {
            $(div).style.display="none";
        }
        else
        {
            $(div).style.display="";
        }
    }
}HiddenDis($('txtFlag').value);

//新邮箱设置获取焦点
function setChecked(s)
{
   $(s).checked=true;
}
</script>