﻿function UserCenterDialog()
{
    if (!IsAuthenticated())
    {
        alert("需要登录!");
        return;
    } 
    var d="<div id=\"dialogUserCenter\" style=\"width:780px\" class=\"g_dialog\"><div id=\"dialogUserCenterTitle\" class=\"g_dialogtitle\"><div class=\"g_dialogtitletext\">用户中心</div><div id=\"dialogUserCenterclose\" class=\"g_dialogclose\"></div></div><div id=\"dialogUserCenterBody\" style=\"height:450px\" class=\"g_dialogbody\"></div><div id=\"dialogUserCenterBottom\" class=\"g_dialogbottom\"></div></div>";
     $("#dialogUserCenter").remove();

    $("body").append(d);

   // $("#dialogUserCentercode").Opacity(50);
    $("#dialogUserCenter").Dialog({
        maskColor:"#1b1613",
        maskOpacity:50,
        animate:"",
        close:"#dialogUserCenterclose",
        draggable:true,
        dragHandle:"#dialogUserCenterTitle"
    });
    $("#loading").remove();    
    $("#dialogUserCenterBottom").append("<div id='loading' style='z-index:99999;padding:0px 5px 5px 5px;'><img src='images/ajax-loader2.gif'>&nbsp;载入...</div>");    
    var userCenterView;
    AjaxService($.url(window.location.href,"ViewPath","/views/UserCenter.ascx"),false,function(obj){userCenterView=obj;});
    $("#dialogUserCenterBody").html(userCenterView);
    $("#userCenterPanel ul").idTabs();
    $("#loading").hide();
}

function LoadUserInfo()
{
    var userInfoView;
    $("#loading").show();    
    AjaxService($.url(window.location.href,"ViewPath","/views/UserInfo.ascx"),false,function(obj){userInfoView=obj;});
    $("#myInfo").html(userInfoView);
    $("#userinfoPanel ul").idTabs();
    $("#loading").hide();        
    $("#OldPassword").focus();
}

function ChangePassword()
{
    var oldPassword=$("#OldPassword").attr("value");
    var newPassword=$("#NewPassword").attr("value");
    var vnewPassword=$("#VNewPassword").attr("value");
    
    if (newPassword!=vnewPassword)
    {
        alert("密码不一致！");
        return;
    }
    var reValue;
    AjaxService('/admin/Service.asmx/ChangePassword',false,function(data){reValue=data.d;},"","json","{oldPassword:'"+oldPassword+"',newPassword:'" + newPassword + "'}");
    if (!reValue)
    {
        alert("密码错误！");
        return;    
    }
    else
    {
        alert("密码修改成功！");
        return;    
    
    }
}

function LoadUserForm()
{
    var userFormView;
    $("#loading").show();    
    AjaxService($.url(window.location.href,"ViewPath","/modules/eFormModule/views/UserForm.ascx"),false,function(obj){userFormView=obj;});
    $("#myForm").html(userFormView);
    $("#loading").hide();
}