/// <reference path="Extjs_Intellisense.js" />
/// <reference path="src/data/XmlStore.js" />
/// <reference path="addjs/Base.js" />
/// <reference path="addjs/XmlTreeLoader.js" />




//检查是否每个都有输入
function CheckLoginData()
{
    var user=$("username").value;
    var pass=$("password").value;
    var ip=$("ipAddr").value;
    var port=parseInt($("port").value);
    if(user=="")
    {
        $("username").focus();
        return false;
    }
    if(pass=="")
    {
        $("password").focus();
        return false;
    }
    if(ip=="")
    {
        $("ipAddr").focus();
        return false;
    }
    if($("port").value=="")
    {
        $("port").focus();
        return false;
    }
    return true;
}

 
 
 
 
 
 
function CheckPlayList(sendnow)
{
    try
    {
        try
        {
            if(__timer_forchekplay!=0)
            {
                window.clearTimeout(__timer_forchekplay);
            }
            if(sendnow)
            {
                var realtree=GetRelaTimeTree();
                for(var idx=1;idx<=Max_play_Count;idx++)
                {
                    try
                    {
                        var nowplayid="player"+idx;
                        var devid= playobjDevIdList[nowplayid];
                        if(devid!="")
                        {
                            var playobj=GetPlayerById(nowplayid);
                            var lastTick=playobj.GetUserData("getlastrecvtime");//取最后收流时间
                            var streamId=PlayVideoTypeList[nowplayid];
                            var playstatus=parseInt(playobj.GetPlayStatus());
                            if(playstatus===5 || playstatus===1 || playstatus===8)
                            {//出错，停止，结束,则要重新开始播放                    
                                var node=realtree.root.findChild("Id",""+devid,true);
                                if(node!=null && node!=undefined)
                                {//重新请求流
                                    //PlayVideoByNode(node,nowplayid,streamId,false);
                                    var videoport=playobj.GetBindPort();///parseInt(LastPlayVideoPort[selectPlayerId]);
                                    WriteWebLog("5000 InviteDeviceMonitor start,new video port="+videoport+"...");                                
                                    if(videoport>=0 && videoport<65535)
                                    {
                                        loginobj.InviteDeviceMonitor(devid,streamId,videoport,0);//camid,流id,recvport,轮询id
                                    }
                                    WriteWebLog("5000 InviteDeviceMonitor end...");
                                }
                            }
                        }
                    }catch(eee)
                    {
                        
                    }
                }
            }
        }catch(eeevv)
        {
                 
        }
        //__timer_forchekplay=window.setTimeout("CheckPlayList()",60*1000);//10秒一次
        __timer_forchekplay=window.setTimeout("CheckPlayList(true)",5*1000);//10秒一次
    }catch(eee){}
}


function LoadConfingData(str)
{
    PlayVideoByConfig(str);
    CheckPlayList(false);
}


function InitAudioCtrl()
{
    if(__userFCom)
    {
        var auobj=$("audioobj");
        WriteWebLog("FCom_InitDevList start...");
        var retret=auobj.FCom_InitDevList();
        WriteWebLog("FCom_InitDevList end...");
    }
}



function StartLogin(isLogin)
{    
    if(!isLogin)
    {
        if(!CheckLoginData())
        {
            //alert("输入内容错误!","错误");
            return false;
        }
    }
    var obj=$("loginobj");
    loginObj=obj;
    
    try
    {
        if(IsEnglish())
        {
            loginObj.SetLanguage(1);
        }else
        {
            loginObj.SetLanguage(0);
        }
    }catch(eevv){}
    
    var user=$("username").value;
    var pass=$("password").value;
    var ip=$("ipAddr").value;
    var port=parseInt($("port").value);
    if(user=="")
    {
        alert(GetDefaultLang("lang_usernamenotfind","用户名不能为空"),GetDefaultLang("lang_inputerror","输入错误"));
        $("username").focus();
        return false;
    }
    if(pass=="")
    {
        alert(GetDefaultLang("lang_passwordempty","密码错误不能为空"),GetDefaultLang("lang_inputerror","输入错误"));
        $("password").focus();
        return false;
    }
    if(ip=="")
    {
        alert(GetDefaultLang("lang_serverurlempty","服务地址不能为空"),GetDefaultLang("lang_inputerror","输入错误"));
        $("ipAddr").focus();
        return false;
    }
    //    if(ip.replace(/^[0-9a-zA-Z]+(.[0-9a-zA-Z]+){1,10}$/,"")!="")
    //    {
    //        alert("服务地址输入错误","输入错误");
    //        $("ipAddr").focus();
    //        return false;
    //    }

    try
    {
        var player=GetPlayerById("player1");
        var myip=player.GetHostByName(ip);
        if(myip=="-1")
        {
            alert(GetDefaultLang("lang_serverurlerror31","服务地址不能为空"),GetDefaultLang("lang_inputerror","输入错误"));
            $("ipAddr").focus();
            return false;
        }
        if(myip=="-2")
        {
            alert(GetDefaultLang("lang_serverurlerror32","服务地址错误,请输入有效域名，如:test.com!"),GetDefaultLang("lang_inputerror","输入错误"),null,250);
            $("ipAddr").focus();
            return false;
        }
        if(myip!="" && myip!=undefined)
        {
            ip=myip;
        }
    }catch(eeee){}
        
    if(!IsNormIp(ip))
    {
        alert(GetDefaultLang("lang_serverurlerror33","服务地址错误,请输入IP地址或域名，如:192.168.1.2!"),GetDefaultLang("lang_inputerror","输入错误"),null,300);
        $("ipAddr").focus();
        return false;
    }

    var portmsg=$("port").value;
    var portError=false;
    if(portmsg.replace(/[^0-9]+/g,"")!=portmsg)
    {
        portError=true;
    }
    if(port<=0 || port>=65536 || $("port").value=="" || portError )
    {
        alert(GetDefaultLang("lang_serverporterror34","服务端口必须是1至65535之间的整数"),GetDefaultLang("lang_inputerror","输入错误"),null,300);
        $("port").focus();
        return false;
    }
    WriteWebLog("登录:用户="+user+",密码:"+pass+",IP:"+ip+",端口"+port+"开始.........");
    var res=0;
    try
    {
        WriteWebLog("LoginPlat start...");
        res=obj.LoginPlat(user,pass,ip,port,1);//监控客户端登录最后面参数为1
        WriteWebLog("LoginPlat end...");
    }catch(eee)
    {
        alert(GetDefaultLang("lang_controlerror35","登录失败，可能是由于你未注册控件！"),GetDefaultLang("lang_loginerrormsg","登录失败"));
        return false;
    }
    WriteWebLog("登录:用户="+user+",密码:"+pass+",IP:"+ip+",端口"+port+"结束.........");
    var doc=CreateXmlByStr(res);
    var rightValueList=doc.getAttribute("Purview");
    var result=doc.getAttribute("Result");
    if(typeof(result)=="string")
    {
        result=parseInt(result);
    }
    
    
   var rightlist="PTZRight,DevMNGRight,SURVEILRight,USRMNGRight,VideoReplayRight,AudioControlRight";
   rightlist+=",BCControlRight,TVWallRight,AlarmMngRight,ContentDeleteRight";
   
   
   var rgls=rightlist.split(",");
   for(var idx=0;idx<rgls.length;idx++)
   {
        var codedata="have_"+rgls[idx]+"="+doc.getAttribute(rgls[idx]);
        try
        {
            eval(codedata);
        }catch(eee){}
   }
   
   if(__userFCom)
   {
        WriteWebLog("FCom_ClientLogin开始.........");                                                                                            
        try
        { 
            if(result===0 || result==="0")
            {
                var portstr=""+port;
                var auobj=$("audioobj");            
                WriteWebLog("FCom_Init start...");
                var retvalue=auobj.FCom_Init(0); 
                WriteWebLog("FCom_Init end...");
                
                
                WriteWebLog("FCom_ClientLogin start...");
                var ret=auobj.FCom_ClientLogin(user,pass,ip,portstr);
                WriteWebLog("FCom_ClientLogin end...");
                
                if(ret!==0 && ret!=="0")
                { 
                    try
                    {
                        obj.LogoutPlat();
                    }catch(ee){}
                    result=ret;
                }else
                {
                    try
                    {//2秒后调用初始化参数
                        window.setTimeout("InitAudioCtrl();",1000);
                    }catch(eeee)
                    {
                        InitAudioCtrl();
                    }
                }
            }
        }catch(eeee){}
        WriteWebLog("FCom_ClientLogin结束.........");  
    }
    
    var ErrorCode=doc.getAttribute("Code");
    if((result==0 || result=="0") )// && rightValueList!=undefined && rightValueList.replace(/[0]+/g,"")!="")
    {
        loginUser=user;
        loginPass=pass;//itemsplitobj
        var savestr=user+itemsplitobj+$("ipAddr").value+itemsplitobj+port;
        if(main_needsavepass_field.getValue())
        {
            savestr+=itemsplitobj+base64encode(pass);
        }else
        {
            savestr+=itemsplitobj;
        }            
        if(main_needsavepass_field.getValue())
        {
            savestr+=itemsplitobj+"true";
        }else
        {        
            savestr+=itemsplitobj+"false";
        }
        if(main_autologin_field.getValue())
        {
            savestr+=itemsplitobj+"true";
        }else
        {        
            savestr+=itemsplitobj+"false";
        }
        savestr+=itemsplitobj+__now_Play_ShowCount;
        savestr+=itemsplitobj+__playAudioDevId;
                 
        SaveConfigData(savestr);
        
        
        WriteWebLog("登录成功,权限:"+rightValueList);
        try{document.title.innerText=GetDefaultLang("lang_webclientname","Web客户端");}catch(erritem){}
        
        
        
        if(main_autologin_field.getValue())
        {// 要自动登录
            __LastTimeisAutoLogin=true;
        }
        
        loginview.destroy();        
        viewport= ShowTreePlan(viewport);
        ChangeUserButtonByString(have_PTZRight==1,have_PTZRight==1);
        if(__user_function_to_readcamera)
        {
            UpdateDevStatus();
        }
        ResizeLeftTreePlan();
        
        try
        {
            $("mdnewpass1").className="input";
            $("mdnewpass2").className="input";
            $("mdpassword").className="input";
        }catch(eeee){}
    
    
        return false;
    }else
    {
        switch(result)
        {
            case 4902:
            {//
                alert(GetDefaultLang("lang_userlockerror","此用户已被锁定,请联系管理员!"),GetDefaultLang("lang_loginerroritem","登录错误"),undefined,250);
            }
            break;
            case 4912:
            {
                alert(GetDefaultLang("lang_loginmaxusercount","登录用户数已超过最大值!"),GetDefaultLang("lang_loginerroritem","登录错误"),undefined,250);
            }
            break;
            case 4883:
            {
                alert(GetDefaultLang("lang_servertimeout","服务响应超时！"),GetDefaultLang("lang_loginerroritem","登录错误"));                
            }
            break;
            case 4886:
            {
                alert(GetDefaultLang("lang_norightuser","用户名没有登录权限！"),GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
            case 4888:
            {
                alert(GetDefaultLang("lang_uernotfind","用户名不存在！"),GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
            case 4880:
            {
                alert(GetDefaultLang("lang_passerror","用户密码错误！"),GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
            case 4901:
            {
                alert(GetDefaultLang("lang_userhavelogin","此用户已在其它地方登录，请更换用户！"),GetDefaultLang("lang_loginerroritem","登录错误"),null,300);
            }
            break;
            case -1:
            {
                alert(GetDefaultLang("lang_connecterrorcheckip","连接失败，请检查服务地址或端口是否正确！"),GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
            case -3:
            {
                alert(GetDefaultLang("lang_logintime","登录超时，请重试！"),GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
            default:
            {
                alert(GetDefaultLang("lang_loginothererror","登录失败！错误代码:")+result,GetDefaultLang("lang_loginerroritem","登录错误"));
            }
            break;
        }
        return false;
    }
    
    loginForm.getForm().submit({
            waitMsg: GetDefaultLang("lang_logintipmsg",'正在验证中...'),
            success: function(loginForm, o)
            {//o.result.file//
             //viewport.remove(0);
             //viewport= ShowTreePlan();
            },
            failure:function(loginForm,o)
            {
                //alert(o.result.errormsg,"登录失败");
            }
        });
}


function OnKeyUp(textobj,evobj)
{
    if(evobj.keyCode==evobj.ENTER)
    {
        StartLogin(false);
    }
}



function ShowLoginForm(viewport)
{
    if(loginForm==null)
    {
        var play=GetPlayerById("player1");
        var userdata=null;
        var userconfigdata=new Array();
        try
        {
            userdata=play.GetUserData(__configfilefullpath);
            if(userdata=="" || userdata==undefined)
            {
                userdata=play.GetUserData(__configfilefullpath2);
            }
            userdata=userdata.replace(/[\r\n]+/g,"\r\n");
            var usls=userdata.split("\r\n");
            userdata=(usls[0]);
            for(var idx=0;idx<usls.length;idx++)
            {//'allvalue','text'
                var tempmsg=usls[idx];
                if(tempmsg==undefined)
                {
                    continue;
                }
                try
                {
                    var decmsg=base64decode(tempmsg);
                    if(decmsg.split(itemsplitobj).length>1)
                    {//base64新数据
                        tempmsg=decmsg;
                        if(idx==0)
                        {
                           userdata=tempmsg;
                        }
                    }else
                    {//无效数据
                        continue;
                    }
                }catch(eeee){}
                var showuser=tempmsg.split(itemsplitobj);
                userconfigdata[idx]=[idx,tempmsg,showuser[0]];
            }
        }catch(eee){}
        
        
        var tempmsg="";
        
        //前面是所有内容，后面是值
        //userconfigdata=[[userdata, "item1"], ["", "item2"]];
        
        
        
        logindefwidth=180;
        loginwidth=330;
        loginlabelwidth=90;
        if(!IsEnglish())
        {
            logindefwidth=200;
            loginwidth=330;
            loginlabelwidth=70;
        }
        
        
                        
         loginForm = new Ext.FormPanel({
            labelWidth: loginlabelwidth, // label settings here cascade unless overridden
            url:'Save.aspx',
            frame:true,
            title: GetDefaultLang("lang_loginformititle",'用户登录窗口'),
            bodyStyle:'padding:20px 20px 0;',
            width: loginwidth,
            height:220,
            defaults: {width: logindefwidth},
            defaultType: 'textfield',
            items: [
                main_loginuser_field=new Ext.form.ComboBox({
                    typeAhead: true,
                    fieldLabel: GetDefaultLang("lang_usernametitleitem","用 户 名"),
                    triggerAction: 'all',
                    lazyRender:true,
                    mode: 'local',
                    name: 'username',
                    id:'username',
                    store: new Ext.data.ArrayStore({
                        id: 0,
                        fields: ['idvalue','allvalue','text'],
                        data: userconfigdata
                    }),
                    valueField: 'idvalue',
                    displayField: 'text',
                    enableKeyEvents:true,
                    listeners:
                    {
                        keyup:function(thisobj,evobj)
                        {
                            OnKeyUp(thisobj,evobj);
                        },
                        select:function(combo,record,index) 
                        {
                            var selectallvalue=record.data["allvalue"];
                            ChnageUserConfig(selectallvalue);
                        }
                    }
                }),
//                main_loginuser_field=new Ext.form.TextField({
//                    fieldLabel: '用 户 名',
//                    name: 'username',
//                    id:'username',
//                    value:'',
//                    //style:'border: 1px solid #7f9db9;',
//                    enableKeyEvents:true,
//                    listeners:
//                    {
//                        keyup:function(thisobj,evobj)
//                        {
//                            OnKeyUp(thisobj,evobj);
//                        }
//                    }
//                }),
                main_loginpass_field=new Ext.form.TextField({
                    fieldLabel:GetDefaultLang("lang_passitemtitle", '登录密码'),
                    name: 'password',
                    id:'password',
                    inputType:'password',
                    value:"",
                    cls:'input',
                    enableKeyEvents:true,
                    listeners:
                    {
                        keyup:function(thisobj,evobj)
                        {
                            OnKeyUp(thisobj,evobj);
                        }
                    }
                }),
                main_loginip_field=new Ext.form.TextField({
                    fieldLabel: GetDefaultLang("lang_loginserver",'服务地址'),
                    name: 'ipAddr',
                    id:'ipAddr',
                    value:"",
                    cls:'input',
                    enableKeyEvents:true,
                    listeners:
                    {
                        keyup:function(thisobj,evobj)
                        {
                            OnKeyUp(thisobj,evobj);
                        }
                    }
                }),
                main_loginport_field=new Ext.form.TextField({
                    fieldLabel: GetDefaultLang("lang_loignport",'服务端口'),
                    name: 'port',
                    value:"20001",
                    cls:'input',
                    id:'portvalue',
                    maxLength:5,
                    enableKeyEvents:true,
                    listeners:
                    {
                        keyup:function(thisobj,evobj)
                        {
                            OnKeyUp(thisobj,evobj);
                        }
                    }
                }),
                {
                    width:300,
                    xtype:'label',
                    html:'<a href="activex/TPPlayer.cab" class="linka" >'+GetDefaultLang("lang_downloadctrlerror","若不能登录，请手动下载并注册控件")+'</a> '
                }
            ],
            buttons: [
            {
                xtype:'label',
                html:GeLanguageLink()
            }
            ,
            main_needsavepass_field=new Ext.form.Checkbox({
              id:'main_needsavepass_field',
              boxLabel:GetDefaultLang("lang_savepasswords",'保存密码'),
              listeners:
              {
                  check: function()
                  {
                    if(!main_needsavepass_field.checked)
                    {
                        main_autologin_field.setValue(false);
                    }
                  }
              } 
            }),
            main_autologin_field=new Ext.form.Checkbox({
              id:'main_autologin_field',
              boxLabel:GetDefaultLang("lang_autologin",'自动登录'),
              listeners:
              {
                  check: function()
                  {
                    if(main_autologin_field.checked)
                    {
                        main_needsavepass_field.setValue(true);
                    }
                  }
              }
            }),
            {
               text:GetDefaultLang("lang_loginbut",'登录'),
               handler: function()
               {
                    StartLogin(true);
               }
            }]
        });
  }
    
    if(loginview==undefined)
    {
        loginview = new Ext.Viewport({
            layout:'border',
            region:'center',
            id:'logindivbox',
            layoutConfig: {
                padding:'2',
                pack:'center',
                align:'middle'
            },
            items: [{
                region:'center',
                baseCls:'x-plain',
                split:true,
                layout:'fit',
                margins: '2 2 2 2',
                layoutConfig: {
                    padding:'5',
                    pack:'center',
                    align:'middle'
                },
                defaults:{margins:'0 5 0 0'},
                items:
                [
                    {
                    layoutConfig: {
                        padding:'5',
                        pack:'center',
                        align:'middle'
                    },
                    defaults:{margins:'0 5 0 0'},
                    layout:'hbox',
                    width:350,
                    height:250,
                    items:[loginForm]
                }
                ]
           }]
        }); 
    }
    
    
    
    //var main_loginuser_field=null;
    //var main_loginpass_field=null;
    //var main_loginip_field=null;
    //var main_loginport_field=null;

    
    ChnageUserConfig(userdata);
    
    $("portvalue").setAttribute("maxLength",5);
    try
    {
        $("username").className="input";
        $("portvalue").className="input";
        $("password").className="input";
        $("ipAddr").className="input";
        function CheckPort(){$("portvalue").value=$("portvalue").value.replace(/[^0-9]+/g,'');}        
        $("portvalue").onkeyup=CheckPort;
        $("portvalue").onkeydown=CheckPort;
        $("username").setAttribute("maxLength",31);
        $("password").setAttribute("maxLength",31);
        
    }catch(eeee){}
    viewport=loginview;
    return viewport;
}



function ChnageUserConfig(userdata)
{
    if(userdata!=null)
    {
        try
        {
            var tempmsg=base64decode(userdata);
        }catch(eeee){}
        var lines=userdata.split("\r\n");
        var userandpass=lines[0];//用户密码之类
        var ls=userandpass.split(itemsplitobj);
        if(ls.length<2)
        {
            return false;
        }
        if(ls.length>0)
        {
            main_loginuser_field.setValue(ls[0]);
        }
        if(ls.length>1)
        {
            main_loginip_field.setValue(ls[1]);
        }
        if(ls.length>2)
        {
            main_loginport_field.setValue(ls[2]);
        }
        if(ls.length>3 && ls[3]!="")
        {
            main_loginpass_field.setValue(base64decode(ls[3]));
        }    
        if(ls.length>4 && ls[4]=="true")
        {//   保存密码  
            main_needsavepass_field.setValue(true);//要选上
        }    
        if(ls.length>5 && ls[5]=="true")
        {//   自动登录   
            main_autologin_field.setValue(true);//要选上
        }
//      var __now_Play_ShowCount=1;
//      var __playAudioDevId="";
        if(ls.length>6 && ls[6]!="")
        {
            if(ls[6]=="4")
            {
                __now_Play_ShowCount=4;
            }else
            {
                __now_Play_ShowCount=1;
            }
        }
        if(ls.length>7)
        {//当前启用的音频
            __playAudioDevId=ls[7];
        }
    }
}



function ShowViewPanel(itempanel)
{
    var view= new Ext.Viewport({
            layout:'border',
            region:'center',
            layoutConfig: {
                padding:'2',
                pack:'center',
                align:'middle'
            },
            items: [{
                id:'maintree',
                region:'center',
                baseCls:'x-plain',
                split:true,
                layout:'fit',
                margins: '2 2 2 2',
                layoutConfig: {
                    padding:'5',
                    pack:'center',
                    align:'middle'
                },
                defaults:{margins:'0 5 0 0'},
                items:
                [
                    {
                    layoutConfig: {
                        padding:'5',
                        pack:'center',
                        align:'middle'
                    },
                    defaults:{margins:'0 5 0 0'},
                    layout:'hbox',
                    width:350,
                    height:250,
                    items:[itempanel]
                }
                ]
           }]
        }); 
   
    
   return view;
}


function GetModifyPassPanel()
{
    if(modifyPassPanel==null)
    {
        modifydefwidth=200;
        modifywidth=350;
        modifylabelwidth=110;
        if(!IsEnglish())
        {
            modifydefwidth=160;
            modifywidth=260;
            modifylabelwidth=60;
        }
    
         modifyPassPanel = new Ext.FormPanel({
            labelWidth: modifylabelwidth, // label settings here cascade unless overridden
            url:'Save.aspx',
            frame:true,
            title:GetDefaultLang("lang_modifipassword", '修改密码'),
            bodyStyle:'padding:5px 5px 0;',
            align:'middle',
            region:'center',
            width:modifywidth,
            defaults: {width: modifydefwidth},
            defaultType: 'textfield',
            items: [
                {
                    fieldLabel: GetDefaultLang("lang_oldpassword",'旧 密 码'),
                    name: 'password',
                    id:'mdpassword',
                    inputType:'password',
                    value:"",
                    allowBlank:true
                },{
                    fieldLabel: GetDefaultLang("lang_newpassword",'新设密码'),
                    name: 'newpass1',
                    id:'mdnewpass1',
                    value:"",
                    inputType:'password',
                    allowBlank:true
                },{
                    fieldLabel: GetDefaultLang("lang_retrypassword",'重输密码'),
                    name: 'newpass2',
                    inputType:'password',
                    id:'mdnewpass2',
                    value:"",
                    allowBlank:true
                }
            ],        
            buttons: [
                {
                    xtype:'label',
                    html:'<span style="color:#ff0000" >'+GetDefaultLang("lang_passmaxlentip","密码最长为31个字符")+'</span>'
                },
                {
                text:GetDefaultLang("lang_modifybut",'修改'),
                 handler: function()
                 {
                        var obj=$("loginobj");
                        loginObj=obj;
                        var user=loginUser;
                        var pass=$("mdpassword").value;
                        var pass1=$("mdnewpass1").value;
                        var pass2=$("mdnewpass2").value;
                        if(loginPass!=pass)
                        {
                            alert(GetDefaultLang("lang_oldpasserror","旧密码错误"),GetDefaultLang("lang_inputerror","输入错误"));
                            return false;
                        }
                        if(pass1==undefined || pass1=="")
                        {//
                            alert(GetDefaultLang("lang_newpassempty","新密码不能为空"),GetDefaultLang("lang_inputerror","输入错误"));
                            return false;
                        }
                        if(pass1!=pass2)
                        {
                            alert(GetDefaultLang("lang_passerror40","两次密码不一样"),GetDefaultLang("lang_inputerror","输入错误"));
                            return false;
                        }
                        WriteWebLog("修改用户密码:用户="+user+",旧密码:"+loginPass+",新密码:"+pass1);
                        var res=obj.ChangePassword(loginPass,pass1);
                        if(res=="0" || res==0)
                        {
                            loginPass=pass1;
                            alert(GetDefaultLang("lang_modifyok","修改用户密码成功！"),GetDefaultLang("lang_modifyokmsg","修改成功"));
                            WriteWebLog("修改用户密码成功");
                            return false;
                        }else
                        {
                            switch(res)
                            {
                                default:
                                {
                                    alert(GetDefaultLang("lang_modifyerror41","修改用户密码失败！"),GetDefaultLang("lang_modifyerrormsg","修改失败"));
                                }
                                break;
                            }
                            return false;
                        }
                }//handle
            }]
        });
        
        passmodifyplan=new Ext.Panel(
        {
            region:'center',
            id:'modifypassform',
            title:GetDefaultLang("lang_modifypasstitle", '修改密码'),
            align:'middle',
            layoutConfig: 
            {
                padding:'5',
                pack:'center',
                align:'middle'
            },
            defaults:{margins:'0 5 0 0'},
            layout:'hbox',
            height:180,
            width:modifywidth,
            items:[
               modifyPassPanel
           ]
        });        
    }
    
    try
    {
        $("mdpassword").setAttribute("maxLength",31);
        $("mdnewpass1").setAttribute("maxLength",31);
        $("mdnewpass2").setAttribute("maxLength",31);
    }catch(eee){}
    
    return passmodifyplan;
 }
 