<%@ page language="C#" autoeventwireup="true" masterpagefile="~/MasterPage/MyspaceMasterPage.master" inherits="User_ModifyBasicInfo, DoodiiShop" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Src="../../Controls/User/UserUploadHeadPortrait.ascx" TagName="UserUploadHeadPortrait"
    TagPrefix="uc1" %>
<%@ Register Assembly="Brettle.Web.NeatUpload" Namespace="Brettle.Web.NeatUpload"
    TagPrefix="Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <style type="text/css">
.title a{display:block;width:80px; height:25px; text-align:center; line-height:2em;float:left;}
.title{ width:600px;}
.title li{width:80px;}
    .ProgressBar {
        width:500px;
        height:100px;
    }
    .RestAffiche{width:597px;}
    .MyTable{margin-top:10px;}
    .Style_Input3
{
    float:left;
    margin-left:20px;
    display:inline;
}
.shangchuan{height:24px; *height:25px; width:53px; border:1px solid #0f7502;}
</style>
    <div>
        <asp:HiddenField ID="hidType" runat="server" Value="1" />
        <%--<ul class="title">
            <li><a class="selected" id="lnkTitle1" runat="server" href="javascript:show(1)">账号信息</a></li><li>
                <a id="lnkTitle2" runat="server" href="javascript:show(2)">我的信息</a></li><li><a id="lnkTitle3"
                    runat="server" href="javascript:show(3)">我的头像</a></li></ul>--%>
        <div class="Style_lei">
            <ul>
                <li>
                    <asp:LinkButton ID="lbt2" runat="server" OnClick="lbt2_Click">账号信息</asp:LinkButton></li><li>
                        <asp:LinkButton ID="lbt3" runat="server" OnClick="lbt3_Click">我的信息</asp:LinkButton></li><li>
                            <asp:LinkButton ID="lbt4" runat="server" OnClick="lbt4_Click">我的头像</asp:LinkButton></li></ul>
        </div>
    </div>
    <div id="divInfo1" style="clear: both; display: none;" class="RestAffiche" runat="server">
        <span style="color: #999;">（帐号信息是您的唯一标识，不能修改。）</span>
        <table width="100%" class="MyTable" cellspacing="1" cellpadding="1" border="0">
            <tr>
                <td class="htd">
                    邮箱：
                </td>
                <td class="rtd">
                    <asp:Label runat="server" ID="lblEmail"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    昵称：
                </td>
                <td class="rtd">
                    <asp:Label ID="lblName" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
    <div id="divInfo2" style="display: none; clear: both;" class="RestAffiche" runat="server">
        <span style="color: #999;">（填写完整的信息可以使我们为您提供更好的服务。）</span>
        <table width="100%" class="MyTable" cellspacing="1" cellpadding="1" border="0">
            <tr>
                <td class="htd">
                    姓名：
                </td>
                <td class="rtd">
                    <asp:TextBox ID="tbUserName" runat="server"></asp:TextBox><span id="lblUserNameMessage"></span>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    性别：
                </td>
                <td class="rtd">
                    <input id="rdoSex0" type="radio" value="0" runat="server" />
                    <span>&nbsp;男</span>&nbsp;&nbsp;&nbsp;
                    <input id="rdoSex1" type="radio" value="1" runat="server" />
                    <span>&nbsp;女</span>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    手机：
                </td>
                <td class="rtd">
                    <asp:TextBox ID="tbTel" runat="server" MaxLength="11"></asp:TextBox><span id="lblMobileMessage"></span>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    固定电话：
                </td>
                <td class="rtd">
                    <asp:TextBox ID="tbPhone" runat="server" MaxLength="12"></asp:TextBox><span id="lblPhoneMessage"></span>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    QQ：
                </td>
                <td class="rtd">
                    <asp:TextBox ID="tbQQ" runat="server" MaxLength="13"></asp:TextBox><span id="lblQQMessage"></span>
                </td>
            </tr>
            <tr>
                <td class="htd">
                    MSN：
                </td>
                <td class="rtd">
                    <asp:TextBox ID="tbMSN" runat="server" MaxLength="50"></asp:TextBox><span id="lblMSNMessage"></span>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="padding: 10px 0px;">
                    <a id="btnPost" class="Style_Input2" style="float: left; margin-left: 190px; display: inline;"
                        href="javascript:post1()">提&nbsp;交</a>
                   
                    <asp:Button ID="Button1" CssClass="Style_Input3" runat="server"
                        Text="还&nbsp;原" OnClick="Button1_OnClick" />
                </td>
            </tr>
        </table>
    </div>
    <div id="divInfo3" style="display: none; clear: both;" class="RestAffiche" runat="server">
        <%-- <uc1:UserUploadHeadPortrait ID="UserUploadHeadPortrait1" runat="server" />--%>
        <div style="color: #999;">
            （头像长宽比例最好是1:1，文件大小请不要超过100KB。文件类型可使用gif、jpg及pnp。）
            <div style="padding-top: 10px;">
                <Upload:InputFile ID="InputFile1" runat="server" Size="50" Height="25" BackColor="Transparent"
                    BorderColor="DarkGreen" BorderStyle="Solid" BorderWidth="1px" />
                <asp:Button ID="btnUpload" CssClass="shangchuan" runat="server" Text="上传" OnClick="btnUpload_Click" />
                <Upload:ProgressBar ID="ProgressBar1" runat="server" Inline="True">
                </Upload:ProgressBar>
            </div>
            <div style="padding-top: 20px;">
                上传头像时，新的头像会自动覆盖原头像。
                <br />
                <br />
                <img style="border:1px solid #d7d7d7;" id="imgCurrentPhoto" alt="当前头像" src="" />
                <img style="border:1px solid #d7d7d7;" id="imgCurrentPhoto2" alt="当前头像" src="" />
                <img style="border:1px solid #d7d7d7;" id="imgCurrentPhoto3" alt="当前头像" src="" /></div>
        </div>
    </div>

    <script type="text/javascript">
    var ModelType='<%=hidType.ClientID %>';
    var resetMessage = function( objDom, Message ) {
        $(objDom).removeAttr("class");
        $(objDom).html( Message );
    }
    
    var setRightMessage = function( objDom ) {
        $(objDom).attr("class", "MessageRight");
        $(objDom).html( "√" );
    }
    
    var setErrorMessage = function( objDom, Message ) {
        $(objDom).attr("class", "MessageError");
        $(objDom).html( Message );
    }
    function post1()
    {
        if(!validateForm())return;
        var SexId = 0;
        if ( $( "#<%=rdoSex1.ClientID%>").attr("checked") ) SexId = 1;
        var TrueName = $( "#<%=tbUserName.ClientID%>").val();
        var Mobile = $( "#<%=tbTel.ClientID%>").val();
        var Phone = $( "#<%=tbPhone.ClientID%>").val();
        var QQ = $( "#<%=tbQQ.ClientID%>").val();
        var MSN = $( "#<%=tbMSN.ClientID%>").val();
        ret=User_ModifyBasicInfo.SaveForm(SexId,TrueName,Mobile,Phone,MSN,QQ).value;
        if ( ret == "0" )
            alert("修改成功！");
        else
            alert("发生错误:" + ret);
    }
     var validateUserName = function() {
        var TrueName = $("#<%=tbUserName.ClientID%>").val().trim();
        if(TrueName.indexOf("@")>=0)
        {
            alert("真实姓名不能输入@符号" ); 
            return false;
        }
//        if ( TrueName == "" ) {
//            alert("真实姓名不能为空" );
//            return false;
//        }
        else
            return true;
    }
    
    var validateMobile = function() {
        if ( $("#<%=tbTel.ClientID%>").val() == "" ) return true;
        var reg = /^1\d{10}$/;
        if ( reg.exec( $("#<%=tbTel.ClientID%>").val() ) ) {
            return true;
        } else {
            alert("手机格式填写有误！" );
            return false;
        }
    }
    
    var validatePhone = function() {
        if ( $("#<%=tbPhone.ClientID%>").val() == "" ) return true;
        var reg = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{1,}))?$/;
        if ( reg.exec( $("#<%=tbPhone.ClientID%>").val() ) ) {
            return true;
        } else {
            alert("电话格式填写有误！" );
            return false;
        }
    }
    var validateMobilePhone = function() {
        if ( $("#<%=tbPhone.ClientID%>").val().trim() == ""&&$("#<%=tbTel.ClientID%>").val().trim() == "" ) 
        {
            alert( "手机和固定电话至少填写一项！" );
            return false;
        }
        else
        {
            return true;
        }
        
    }
    var validateMSN = function() {
        if ( $("#<%=tbMSN.ClientID%>").val() == "" ) return true;
        var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
        if ( reg.exec( $("#<%=tbMSN.ClientID%>").val() ) ) {
            return true;
        } else {
            alert( "MSN格式填写有误！" );
            return false;
        }
    }
    
    var validateQQ = function() {
        if ( $("#<%=tbQQ.ClientID%>").val() == "" ) return true;
        var reg = /^[A-Za-z0-9]+$/;
        if ( reg.exec( $("#<%=tbQQ.ClientID%>").val() ) ) {
            return true;
        } else {
            alert("QQ格式填写有误！");
            return false;
        }
    }
     var validateForm = function() {
        if ( !validateUserName() ) return false;
//        if ( !validateMobilePhone() ) return false;
        if ( !validateMobile() ) return false;
        if ( !validatePhone() ) return false;
        if ( !validateQQ()) return false;
        if ( !validateMSN() ) return false;
        return true;
    }
    var getCurrentPhoto = function(PhotoId) {
        if (PhotoId == undefined) 
        PhotoId = User_ModifyBasicInfo.GetCurrentHeadPhotoId().value;
        var arr=PhotoId.split(",");
        if ( PhotoId != null ) {
            document.getElementById("imgCurrentPhoto").src = "/getImage_" + arr[0] + "_100_100_0_0_0_1.aspx";
            document.getElementById("imgCurrentPhoto2").src = "/getImage_" + arr[1] + "_40_40_0_0_0_1.aspx";
            document.getElementById("imgCurrentPhoto3").src = "/getImage_" + arr[2] + "_20_20_0_0_0_1.aspx";
        } else {
            alert("获取当前头像失败！");
        }
    }
function init(){
    var PhotoId = User_ModifyBasicInfo.GetCurrentHeadPhotoId().value;
    getCurrentPhoto(PhotoId);
    }
$(document).ready(function(){init();});
    </script>

</asp:Content>
