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

function SetStartAudioEnable()
{
    try
    {
        main_but_startaudio.enable();
    }catch(eeee){}
}

function SetStartAudioDisable()
{
    try
    {
        main_but_startaudio.disable();
    }catch(eeee){}
    window.setTimeout("SetStartAudioEnable();",2000);
}
                    
                            
                            
                            
                            
function ReSetPlayPos(eventObj,htmlel,obj)
{
    var gridwidth=eventObj.getWidth(false);
    var width=gridwidth-10
    var height=eventObj.getHeight(false)-48;
    var playwidth=width/2;
    var playheigh=height/2;
    var idx=0;
    var playtable=GetPlayerById("playlisttable"); 
    if(playtable)
    {                
        playtable.style.width=""+(width+6)+"px";
        playtable.style.height=""+(height+6)+"px";
    }
    if(__now_Play_ShowCount==1)
    {
        idx=1;                            
        try
        {
            var nowplayer=GetPlayerById("player"+idx);
            var nowplayerbordre=GetPlayerById("player"+idx+"div");
            var playtd=GetPlayerById("player"+idx+"td");
            nowplayer.width=""+(playwidth*2)+"px";
            nowplayer.height=""+(playheigh*2+10)+"px";
            nowplayer.SetDrawBorder(0);
            nowplayerbordre.style.width=""+(playwidth*2+2)+"px";
            nowplayerbordre.style.height=""+(playheigh*2+2)+"px";
            playtd.style.width=""+(playwidth*2+6)+"px";
            playtd.style.height=""+(playheigh*2+12)+"px";
            nowplayerbordre.style.display="block";
            playtd.style.display="block";
        }catch(ee){}
            
        for(idx=2;idx<=Max_play_Count;idx++)
        {
            try
            {
                var nowplayer=GetPlayerById("player"+idx);
                var nowplayerbordre=GetPlayerById("player"+idx+"div");
                var playtd=GetPlayerById("player"+idx+"td");
                nowplayer.width=""+(1)+"px";
                nowplayer.height=""+(1)+"px";
                nowplayerbordre.style.display="none";
                playtd.style.display="none";
            }catch(ee){}
        }
    }else
    {
        for(idx=1;idx<=Max_play_Count;idx++)
        {
            try
            {
                var nowplayer=GetPlayerById("player"+idx);
                var nowplayerbordre=GetPlayerById("player"+idx+"div");
                var playtd=GetPlayerById("player"+idx+"td");
                nowplayer.width=""+(playwidth)+"px";
                nowplayer.height=""+(playheigh+1)+"px";
                nowplayer.SetDrawBorder(0);
                nowplayerbordre.style.width=""+(playwidth+2)+"px";
                nowplayerbordre.style.height=""+(playheigh+2)+"px";
                playtd.style.width=""+(playwidth+6)+"px";
                playtd.style.height=""+(playheigh+6)+"px";
                nowplayerbordre.style.display="block";
                playtd.style.display="block";
            }catch(ee){}
        }
    }
}


function GetRealPlayPanel()
{
    if(realPlayPanel==null)
    {
    
        if(!__LastTimeisAutoLogin)
        {
            main_changeauto_login_but=null;
        }else
        {
            main_changeauto_login_but=new Ext.form.Checkbox({
              id:'main_autologin_field',
              boxLabel:GetDefaultLang("lang_autologin",'自动登录'),
              value:true,
              listeners:
              {
                  check: function()
                  {
                    try
                    {
                         if(!main_changeauto_login_but.checked)
                         {
                            SaveConfigToFile(5,"false");
                         }else
                         {
                            SaveConfigToFile(5,"true");
                         }
                     }catch(eee){}
                  }
              }
            });
        }
                
        main_but_changeplaycount=new Ext.Button({ 
                        //iconCls: 'stopplayer',
                        cls:'x-btn',
                        xtype:'button',
                        text:GetDefaultLang("lang_switch1video",'切换1画面'),
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                
                                if(__now_Play_ShowCount==1)
                                {
                                    __now_Play_ShowCount=4;
                                    main_but_changeplaycount.setText(GetDefaultLang("lang_switch1video",'切换1画面'));
                                }else
                                {
                                    __now_Play_ShowCount=1;
                                    main_but_changeplaycount.setText(GetDefaultLang("lang_switch4video",'切换4画面'));
                                }
                                ReSetPlayPos(GetRealPlayPanel(),htmlel,obj);
                                SaveConfigToFile(6,""+__now_Play_ShowCount);                           
                            }
                        }
                    });
                    
                    
                    if(__now_Play_ShowCount==4)
                    {
                        main_but_changeplaycount.setText(GetDefaultLang("lang_switch1video",'切换1画面'));
                    }else
                    {
                        main_but_changeplaycount.setText(GetDefaultLang("lang_switch4video",'切换4画面'));
                    }
                    
                    
                    main_but_stop=new Ext.Button({ 
                        //iconCls: 'stopplayer',
                        cls:'x-btn',
                        xtype:'button',
                        text:GetDefaultLang("lang_stopplaye",'停止播放'),
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                try
                                {
                                    var loginobj= $("loginobj");
                                    if(playobjDevIdList[selectPlayerId]!=null && playobjDevIdList[selectPlayerId]!="")
                                    {
                                        if(PlayVideoTypeList[selectPlayerId]==="1" || PlayVideoTypeList[selectPlayerId]===1)
                                        {//如果当前正在播放D1
                                            loginobj.StopDeviceMonitor(playobjDevIdList[selectPlayerId],1);
                                            WriteWebLog("停止视频流:CameraId="+playobjDevIdList[selectPlayerId]+",stream type="+1);
                                        }else if(PlayVideoTypeList[selectPlayerId]==="0" || PlayVideoTypeList[selectPlayerId]===0)
                                        {
                                            loginobj.StopDeviceMonitor(playobjDevIdList[selectPlayerId],0);
                                            WriteWebLog("停止视频流:CameraId="+playobjDevIdList[selectPlayerId]+",stream type="+1);
                                        }
                                        if(__userFCom)
                                        {
                                            //loginobj.StopDeviceMonitor(playobjDevIdList[selectPlayerId],1);   
                                            var obj=$("audioobj");
                                            if(LastTackCameraId!="" && LastTackCameraId==playobjDevIdList[selectPlayerId])
                                            {
                                                WriteWebLog("停止对讲"+LastTackCameraId);
                                                var stopret=obj.FCom_StopTalk(LastTackCameraId);
                                                main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                                LastTackCameraId="";
                                            }
                                        }else
                                        {
                                            var obj=loginobj;
                                            if(LastTackCameraId!="" && LastTackCameraId==playobjDevIdList[selectPlayerId])
                                            {
                                                WriteWebLog("停止对讲"+LastTackCameraId);
                                                var stopret=obj.StopTalk(LastTackCameraId);//stop 
                                                if(stopret!=0)
                                                {
                                                    oldAlert(GetDefaultLang("lang_stopaudioerror","停止对讲失败"));
                                                }else
                                                {
                                                    LastTackCameraId="";
                                                    main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                                }
                                            }
                                        }                        
                                        if(__playAudioDevId==playobjDevIdList[selectPlayerId])
                                        {
                                           __playAudioDevId="";
                                           SaveConfigToFile(7,__playAudioDevId);
                                        }                                                                                
                                    }
                                    GetPlayerById(selectPlayerId).SetAudioOn(0); // 停止声音 
                                    GetPlayerById(selectPlayerId).Stop();
                                    playobjDevIdList[selectPlayerId]="";
                                    LastPlayVideoPort[selectPlayerId]="";
                                    var playidvalue=parseInt(selectPlayerId.replace(/[^0-9]+/g,""));
                                    var ret=loginobj.SetPlaySchemeInfo(3,"",playidvalue,"0 0");
                                }catch(ee){}
                            }
                        }
                    });
                    
                    
                    main_but_stopsound=new Ext.Button({
                        xtype:'button',
                        text:GetDefaultLang("lang_playsound", '播放声音'),
                        id:'PlaySound',
                        //iconCls: 'playsound',
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                try
                                {
                                    if(playobjDevIdList[selectPlayerId]=="" || playobjDevIdList[selectPlayerId]==null)
                                    {
                                        return ;
                                    }
                                    var audioOn=0;
                                    var nowplayer=GetPlayerById(selectPlayerId);
                                    if(nowplayer && nowplayer.AudioIsOn)
                                    {//当前有声音，则要停止
                                        audioOn=0;                                        
                                        __playAudioDevId="";
                                    }else
                                    {
                                        if(LastTackCameraId!="")
                                        {
                                            __playAudioDevId="";
                                            var showmsg=GetDefaultLang("lang_notallowsound1","当前视频窗口{playeridx}正处于对讲状态中，不允许播放声音!");
                                            var idx=0;
                                            for(idx=1;idx<=Max_play_Count;idx++)
                                            {
                                                if(playobjDevIdList["player"+idx]==LastTackCameraId)
                                                {
                                                    showmsg=showmsg.replace("{playeridx}",""+(idx));
                                                    break;
                                                }
                                            }
                                            showmsg=showmsg.replace("{playeridx}","1");
                                            oldAlert(showmsg);
                                            return false;
                                        }
                                        audioOn=-1;
                                        __playAudioDevId=playobjDevIdList[selectPlayerId];
                                    }
                                    SaveConfigToFile(7,__playAudioDevId);
                                    for(var idx=1;idx<=Max_play_Count;idx++)
                                    {
                                        try
                                        {
                                            var nowplayid="player"+idx;
                                            if(nowplayid==selectPlayerId)
                                            {
                                                GetPlayerById(nowplayid).SetAudioOn(audioOn);
                                            }else
                                            {
                                                GetPlayerById(nowplayid).SetAudioOn(0);
                                            }
                                        }catch(eee){}
                                    }
                                    if(nowplayer && nowplayer.AudioIsOn)
                                    {//当前有声音，则要停止
                                        audioOn=-1;
                                    }else
                                    {
                                        audioOn=0;
                                    }                                   
                                    if(audioOn===-1)
                                    {
                                        evobj.setText(GetDefaultLang("lang_stopsound","停止声音"));
                                    }else
                                    {
                                        evobj.setText(GetDefaultLang("lang_playsound","播放声音"));
                                    }
                                }catch(ee){}
                            }
                        }
                    });
                    
                    main_but_d1=new Ext.Button({
                        //xtype:'button',
                        width:60,
                        text:GetDefaultLang("lang_switchd1", '切换主码流'),
                        id:'ChangeVideoType',
                        name:'ChangeVideoType',
                        //iconCls: 'playsound',
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                try
                                {
                                    
                                    if(selectPlayerId=="" || GetPlayerById(selectPlayerId)==undefined)
                                    {
                                        return ;
                                    }
                                    if(playobjDevIdList[selectPlayerId]=="" || playobjDevIdList[selectPlayerId]==null)
                                    {
                                        return ;
                                    }
                                   var player=GetPlayerById(selectPlayerId);
                                   var cameraId=playobjDevIdList[selectPlayerId];
                                   
                                   if(cameraId==undefined || cameraId=="")
                                   {
                                        return false;
                                   }                               
                                   var streamId=PlayVideoTypeList[selectPlayerId];
                                   if(streamId===undefined)
                                   {
                                        return false;
                                   }
                                   if(streamId==="0" || streamId===0)
                                   {
                                        streamId=1;
                                   }else
                                   {
                                        streamId=0;
                                   }
                                   var allowshowvideo=GetRightByDevId(cameraId,"video");
                                   if(allowshowvideo!="")
                                   {
                                        oldAlert(allowshowvideo);
                                        //oldAlert("您无权对此设备进行实时监控!");
                                        return false;
                                   }
                                   
                                    //#define VS_VISITSTREAM_NO_FIRBID		0	//不禁止任何码流
                                    //#define VS_VISITSTREAM_FIRBID_0		1	//禁止第0路(CIF)
                                    //#define VS_VISITSTREAM_FIRBID_1		2	//禁止第1路(D1)
                                    //#define VS_VISITSTREAM_FIRBID_BOTH	3	//禁止第0路、第1路
                                    try
                                    {
                                       var realtree=GetRelaTimeTree();
                                       var devid=cameraId;
                                       var node=realtree.root.findChild("Id",""+devid,true);
                                       var allowCifStream=node.attributes["VisitStreamOption"];
                                       allowCifStream=parseInt(allowCifStream);
                                       if( streamId==0  && (allowCifStream==0 || allowCifStream==2) )
                                       {//  允许连接cif   
                                       
                                       }else if( streamId==1  && (allowCifStream==0 || allowCifStream==1) )
                                       {//  允许连接d1    
                                         
                                       }else
                                       {
                                            //if(needshowError)
                                            {
                                                if(streamId==1)
                                                {
                                                    oldAlert(GetDefaultLang("lang_notallowd1","此设备不允许访问高分辨率视频流!"));
                                                }else
                                                {
                                                    oldAlert(GetDefaultLang("lang_notallowcif","此设备不允许访问低分辨率视频流!"));
                                                }
                                            }
                                            return false;
                                       }
                                   }catch(eeee){}
                                   
                                   WriteWebLog("使用["+selectPlayerId+"],播放Camera="+cameraId+",流ID:"+streamId);
                                   player.Stop();
                                   var videoport=player.GetBindPort();
                                   var loginobj=$("loginobj"); 
                                   if(videoport>0 && videoport<65535)
                                   {
                                        if(playobjDevIdList[selectPlayerId]!=null && playobjDevIdList[selectPlayerId]!="")
                                        {
                                            if(PlayVideoTypeList[selectPlayerId]==="1" || PlayVideoTypeList[selectPlayerId]===1)
                                            {//如果当前正在播放D1
                                                loginobj.StopDeviceMonitor(playobjDevIdList[selectPlayerId],1);                                                
                                                WriteWebLog("停止视频流:CameraId="+playobjDevIdList[selectPlayerId]+",stream type="+1);
                                            }else if(PlayVideoTypeList[selectPlayerId]==="0" || PlayVideoTypeList[selectPlayerId]===0)
                                            {
                                                loginobj.StopDeviceMonitor(playobjDevIdList[selectPlayerId],0);
                                                WriteWebLog("停止视频流:CameraId="+playobjDevIdList[selectPlayerId]+",stream type="+0);
                                            }
                                            
                                            if(__userFCom)
                                            {                          
                                                var obj=$("audioobj");
                                                if(LastTackCameraId!="" && LastTackCameraId!=playobjDevIdList[selectPlayerId])
                                                {
                                                    WriteWebLog("停止对讲"+LastTackCameraId);
                                                    var stopret=obj.FCom_StopTalk(LastTackCameraId);
                                                    LastTackCameraId=""; 
                                                    main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                                }
                                            }else
                                            { 
                                                var obj=loginobj;
                                                if(LastTackCameraId!="" && LastTackCameraId==playobjDevIdList[selectPlayerId])
                                                {
                                                    WriteWebLog("停止对讲"+LastTackCameraId);
                                                    var stopret=obj.StopTalk(LastTackCameraId);//stop 
                                                    if(stopret!=0)
                                                    {
                                                        oldAlert(GetDefaultLang("lang_stopaudioerror2","停止对讲失败"));
                                                    }else
                                                    {
                                                        SetStartAudioDisable();
                                                        LastTackCameraId="";
                                                        main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                                    }
                                                }
                                            }                                         
                                        }
                                        WriteWebLog("请求视频流:CameraId="+cameraId+",videoport="+videoport);
                                        $("loginobj").InviteDeviceMonitor(cameraId,streamId,videoport,0);//camid,流id,recvport,轮询id
                                        playobjDevIdList[selectPlayerId]=cameraId;
                                        LastPlayVideoPort[selectPlayerId]=videoport;
                                        PlayVideoTypeList[selectPlayerId]=""+streamId;//流0表cif,1表示d1
                                        var playidvalue=parseInt(selectPlayerId.replace(/[^0-9]+/g,""));
                                        var ret=loginobj.SetPlaySchemeInfo(3,"",playidvalue,""+cameraId+" "+streamId);
                                        if(streamId===1)
                                        {
                                            evobj.setText(GetDefaultLang("lang_switchcif","切换子码流"));
                                        }else
                                        {
                                            evobj.setText(GetDefaultLang("lang_switchd1","切换主码流"));
                                        }
                                   }else
                                   {
                                        WriteWebLog("视频流端口错误:CameraId="+cameraId+",videoport="+videoport);
                                   }
                                }catch(eee)
                                {
                                    
                                }
                            }
                        }
                    });
                    
                    
                               
                    
                    main_but_startaudio=new Ext.Button({
                        xtype:'button',
                        text:GetDefaultLang("lang_startaudio", '启动对讲'),
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                try
                                {
                                
                                    if(playobjDevIdList[selectPlayerId]=="" || playobjDevIdList[selectPlayerId]==null)
                                    {
                                        return ;
                                    }
                                                                        
                                    if(__userFCom)
                                    {
                                        var obj=$("audioobj");
                                        if(LastTackCameraId!="")
                                        {
                                            WriteWebLog("停止对讲"+LastTackCameraId);
                                            var stopret=obj.FCom_StopTalk(LastTackCameraId);
                                            main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                        }
                                    }else
                                    {
                                        var obj=loginobj;
                                        if(LastTackCameraId!="")// && LastTackCameraId==playobjDevIdList[selectPlayerId])
                                        {//如果在对讲，无论如果都先调用停止
                                            WriteWebLog("停止对讲"+LastTackCameraId);
                                            var stopret=obj.StopTalk(LastTackCameraId);//stop 
                                            if(stopret!=0)
                                            {
                                                oldAlert(GetDefaultLang("lang_stopaudioerror3","停止对讲失败"));
                                            }else
                                            {
                                                SetStartAudioDisable();
                                                main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                            }
                                        }
                                    }
                                    var cameraId=playobjDevIdList[selectPlayerId];
                                    if( cameraId!="" && LastTackCameraId!=cameraId)
                                    {//要开启对讲
                                        if(__playAudioDevId!="")
                                        {
                                            LastTackCameraId="";
                                            var showmsg=GetDefaultLang("lang_stopaudioerror4","当前第{playeridx}个播放器正在播放声音中，不允许 启动对讲！");
                                            var idx=0;
                                            for(idx=1;idx<=Max_play_Count;idx++)
                                            {
                                                if(playobjDevIdList["player"+idx]==__playAudioDevId)
                                                {
                                                    showmsg=showmsg.replace("{playeridx}",""+(idx));
                                                    break;
                                                }
                                            }
                                            showmsg=showmsg.replace("{playeridx}","1");
                                            oldAlert(showmsg);
                                            return false;
                                        } 
                                        var audioallow=GetRightByDevId(cameraId,"audio");
                                        if(audioallow!="")
                                        {
                                            //oldAlert(GetRightByDevId(cameraId,"audio"));
                                            oldAlert(audioallow);
                                            return false;
                                        }
                                        if(__userFCom)
                                        {
                                            var playobj=GetPlayerById(selectPlayerId);
                                            var hWnd=playobj.GetHWnd();
                                            var initaudioret=obj.FCom_Init(hWnd);
                                            var startret=obj.FCom_StartTalk(cameraId);
                                            if(startret==0)
                                            {                                        
                                                SetStartAudioDisable();
                                                LastTackCameraId=cameraId;
                                                main_but_startaudio.setText(GetDefaultLang("lang_stopaudio","停止对讲"));
                                            }else
                                            {
                                                LastTackCameraId="";
                                                main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                            }
                                        }else
                                        {
                                            var startret=obj.RequestTalk(cameraId,0,16000,16,2,16000);
                                            if(startret==0)
                                            { 
                                                SetStartAudioDisable();                                       
                                                LastTackCameraId=cameraId;
                                                main_but_startaudio.setText(GetDefaultLang("lang_stopaudio","停止对讲"));
                                            }else
                                            {
                                                LastTackCameraId="";
                                                main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                            }
                                        }
                                    }else
                                    {
                                        LastTackCameraId="";
                                        main_but_startaudio.setText(GetDefaultLang("lang_startaudio","启动对讲"));
                                    }
                                    //oldAlert("当前未实现此功能!");
                                }catch(eee){}
                            }
                        }
                    });
                    
                    main_but_record=new Ext.Button({
                        xtype:'button',
                        text: GetDefaultLang("lang_startrecord",'开始录像'),
                        id:'StartRecordBut',
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                var obj=GetPlayerById(selectPlayerId);
                                if(obj.IsRecording)
                                {
                                    obj.StopRecord();
                                    if(main_but_record)
                                    {
                                        main_but_record.setText(GetDefaultLang("lang_startrecord","开始录像"));
                                    }
                                }else
                                {
					                if(!CheckPlayerIsPlaying(obj))
					                {
					                    oldAlert(GetDefaultLang("lang_startrecorderror5","请在视频开始播放后再进行录像!"));
					                    return false;
					                }
                                    var savedir=GetNowSaveDir();
                                    var res=obj.StartRecord(savedir);
                                    if(res!==0)
                                    {
                                        oldAlert(GetDefaultLang("lang_startrecorderror6","启动录像失败!"));
                                        main_but_record.setText("开始录像");
                                    }else
                                    {
                                        if(main_but_record)
                                        {
                                            main_but_record.setText(GetDefaultLang("lang_stoprecord","停止录像"));
                                        }
                                    }
                                }
                                return ;
                            }
                        }
                    });
                    
                    
                     main_but_capture=new Ext.Button({
                        xtype:'button',
                        text: GetDefaultLang("lang_cappic",'抓图'),
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                try
                                {
                                    getpic();
                                }catch(ee){}
                            }
                        }
                    });
                    
                    
                    
         realPlayPanel= new Ext.Panel({
                id:'showrealtime',
                contentEl: 'realtimediv',
                title:GetDefaultLang("lang_realtimevideo", '实时监控'),
                autoScroll: true,
                listeners:
                {
                    resize:function(eventObj,htmlel,obj)
                    { 
                        ReSetPlayPos(eventObj,htmlel,obj);
                    }
             }//listeners
            ,tbar: [
               main_but_changeplaycount,
                    main_but_stop,
                   main_but_d1,
                    main_but_stopsound
                    ,
                    {
                        xtype:'label',
                        text:GetDefaultLang("lang_soundvol",'音量')
                    }
                     ,new Ext.Slider({
                        width: 100,
                        minValue: 0,
                        maxValue: 100
                        ,value:80
                        ,listeners:
                        {   
                            change:function(thisobj,newValue,oldValue)
                            {
                                try
                                {
                                    if(selectPlayerId=="")
                                    {
                                        return false;
                                    }
                                    var player=GetPlayerById(selectPlayerId);
                                    if(player && player.AudioIsOn)
                                    {
                                        player.SetVolume(newValue);
                                    }
                                }catch(ee){}
                            }
                        }
                    })
                   ,
                    main_but_startaudio,
                    main_but_capture,
                    main_but_record
                    ,
                    {
                        xtype:'label'
                        ,text:GetDefaultLang("lang_savepath",'存储路径:')
                    },
                    {
                        xtype:'label',
                        html:'<div style="width:115px; overflow:hidden; height:20px;display:inline;" ><div id="savedirpath"  style="width:9253px; overflow:hidden;;display:inline;vertical-align:middle;" >c:\\</div></div>'
                    },
                    {
                        text:GetDefaultLang("lang_setsavepath",'设置路径'),
                        listeners:
                        {
                            click:function(evobj,htmlel,obj)
                            {
                                ChangeSaveDir();
                            }
                        }
                    }
//                    ,
//                    {
//                        text:'退出登录',
//                        listeners:
//                        {
//                            click:function(evobj,htmlel,obj)
//                            {
//                                top.location.reload();
//                                //ExitIE();
//                                //treeViewPlan.destroy();                            
//                                //viewport=ShowLoginForm(viewport);
//                            }
//                        }
//                    }
                     //,main_changeauto_login_but
                    ]                
        });
    }
    if(main_changeauto_login_but!=null)
    {
        realPlayPanel.getTopToolbar().addButton(main_changeauto_login_but);
        main_changeauto_login_but.setValue(true);
    }
    return realPlayPanel;
}

