﻿Ext.onReady(function(){
    Ext.QuickTips.init();
    Ext.BLANK_IMAGE_URL = "../../images/s.gif";
    var winLogin;
    var winStatu;
    var comboCar;
    var comstore;
     // var serverURL="http://localhost/newsimcom_acxs/";
  var serverURL="http://www.bbznl.com";
  var winAddChild;
  var Tree = Ext.tree;  
  var tree;
  var childFrend_tree;
  var winModifyUserRight;
  var combobox_bianhao2;
  
  var winLoginNamePwd;
  var panelFlash;
  
  var winAddChildFrend;
  
  var childQuyu_tree;
  var winAddChildQuyu;
  var childContent_tree
  var winAddChildContent;
  var winYinshing;
  

  var winChildAnalysisArea;
  
  // var  combobox_duanyu ;
  
   var winHuChu;
    var winSystemState;
    var winGetTrack;
    var winChangeNo;
    var winChangeCarNo;
    var winReInitTerm;
    var ie_version = Get_IE_Version();
    var retHandle = null;				//the return handle of the modelessdialog
    
    var winUrgencyAlarm;
    var winStopMonitor;
    var winNewRectMonitor;
    var winLongMonitor;
    var winGetTrack;
    var winChangeInterval;
    var AlarmNoOld = 0;
   
    
    var addcar_win;   //添加车辆窗口
    var eidt_loginname_win;  //修改登陆名窗口
    var eidt_userpass_win;//修改用户密码窗口
    var edit_chachephone_win;//修改查车手机窗口
    var edit_userinfo_win;//修改用户信息窗口

    Ext.form.Field.prototype.msgTarget = 'side';
    //加载车辆
     comstore =new Ext.data.Store({
//         autoLoad:true,
//         baseParams: {loginKey: login_key},  
         proxy:new Ext.data.HttpProxy({
             url:serverURL+'/aspx/getCarList.aspx',
             method:'POST'
         }),
         reader:new Ext.data.JsonReader({
             id:'id',
             fields:['id','carname','phone']
         }),
         remote:true
     });
     comstore.load({   
        params: {loginKey:login_key},
        callback: function(r, options, success){   
            if(success){   
               if(comstore.getTotalCount() == 1) comboCar.setValue(comstore.getAt(0).get("carname"));
            }
        }
    });   
    
   comboCar = new Ext.form.ComboBox({
        store: comstore,
        id:'comboName',
        displayField:'carname',
        valueField:'phone',
        editable: false,//不允许输入 
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择小孩...',
        selectOnFocus:true,
        width:135,
        heigh:8,
        listeners:{                         
	        select:function(combo, record,index){	  
		    }
        }  
    });
    winStatu = new Ext.Window({
        title: '状态栏',
        resizable:false,	//变大小
        region:'south',
        closeAction:'hide',           
        width: 269,
        height:135,
        layout: 'fit',
        x:0,
        y:450,
        bodyStyle:'padding:5px;',
        buttonAlign:'left',
        html:'<SELECT id=select1 name=select1 style="WIDTH: 245px; HEIGHT: 90px" size=7 multiple><option selected >系统初始化完成！</option></SELECT>'
    });
    

    
 // winStatu.show();
  function _showStatu()
  {
     winStatu.show();
  }
  	
    
if(login_key==""||login_key==null)
{

   // Ext.MessageBox.alert('系统提示','如果您禁用了cookie，请启用cookie并重新登陆！');
  // addStatus('请先登录！如果您禁用了cookie，请启用cookie。');
  
  var tital_ =new Ext.form.Label({		                   
	text:'儿童定位查询系统',
	cls:"stitle",
	//tag: 'h2',
	//align:'center',
//	buttonAlign:'center',
//	 bodyStyle:'padding: 100px 50px 50px 50px',	
	anchor:'80%'
	});
		var win1=new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding: 0px 0px 0px 30px',
					//labelWidth: '5%',
					//margins:'10 10 5 10',
					width:380 ,	
					//height:180,	
					
					closable: false,
					defaults: {width: 180},
					//defaultType: 'textfield',
					items: [
					     //   tital_,
					    //{	height:25,baseCls: 'x-plain'}, //加空行
					    {
					         xtype:'textfield',
							fieldLabel: '帐 号',								
							name: 'loginName',
							id: 'loginName',							
							value:''						
						},
						//{	height:7,baseCls: 'x-plain'}, //加空行
						{
						     xtype:'textfield',
							fieldLabel: '密 码',														
							inputType:'password',
							name: 'loginPwd',
							id: 'loginPwd',
							//anchor:'90%',
							value:''						
						}
						
					],
					keys:[{
					    key:Ext.EventObject.ENTER,
					    fn:loginClick,
					    scope:this
					}],
					buttons: [{
					    text: '登录',
					    handler:loginClick    					
				        },{
					    text: '退出',
					    handler:function(){
                        //winUserBase.hide();
                         //self.location.href = "default.html";
                         window.opener = 'xxx';
                         window.close();
                        }
				    }]
				});
				
     var  panelFlash1= new Ext.Panel({
          width:385,
          height:323,
          region:'west',
          bodyStyle:'padding: 0px 0px 0px 0px',
          layout:"fit",
          renderTo:"OneDiv",
          contentEl:"TwoDiv",              
          collapsible:true    
      });  
        if(!winLogin)
        {
            winLogin=new Ext.Window({  
                title: '用户登录',
                header:false,
                layout: 'column',  
                modal: true,
                width:386,
                resizable:false,	//变大小	
                height:450,
                closable:false,
               // bodyStyle:'padding:5px',
                buttonAlign:'center',  
             //   closeAction:'close',
             // plain: true,                
                items: [panelFlash1,win1]
            });
            
            winLogin.show();
         //   winLogin.on('show',function(){initFocus();});
       
          } 
  
    }else
    {     
        winStatu.show();
    }
    Ext.getDom(OneDiv).style.display = 'none'; 
    function loginClick()
    {
        var loginName=Ext.get('loginName').dom.value;
        var loginPwd=Ext.get('loginPwd').dom.value;
        
         if(loginName=="")
        {
            Ext.MessageBox.alert('系统提示','请输入登录帐号！');
            Ext.getCmp('loginName').focus(true);
            return;
        }
        if(loginPwd=="")
        {
            Ext.MessageBox.alert('系统提示','请输入登录密码！');
            Ext.getCmp('loginPwd').focus(true);
            return;
        }
       
        user_login(loginName,loginPwd,userlogin_callback);
       
    }
    function loginIn()
    {
       if(login_key>0)
       {
        
       }
    }

    function userlogin_callback(result,xml){
       
        if(result.response_code== "0"){		//登录成功！
            cookieFunction.SetCookie("q6_login_key", result.response_login_key);
            login_key=result.response_login_key;
            winLogin.hide();
            winStatu.show();
            addStatus('登录成功！');
            comboCar.clearValue();
            comboCar.store.load({   
                params: {loginKey:result.response_login_key},
                callback: function(r, options, success){   
                    if(success){   
                       if(comstore.getTotalCount() == 1) comboCar.setValue(comstore.getAt(0).get("carname"));
                    }
                }
            });    
         }else{	//在result_text内有登录失败的原因。
	        Ext.MessageBox.alert('系统提示',result.response_result);
        }
    }
    
     var menuSBGL = new Ext.menu.Menu({
        id: 'SBGL',
        items: [
//            {
//                text: '增加孩子信息',              
//                handler: _addChildOnclike
//            },
            {
                text: '管理孩子信息',        
                handler: _onClickModifyUserInfo
            }
        ]
    });
   var menuHYGL = new Ext.menu.Menu({
        id: 'HYGL',
        items: [
            {
                text: '增加好友信息',              
                handler: addChildFrendClick
            }

//            {
//                text: '管理好友信息',        
//                handler: onItemClick
//            }
        ]
    });
    var menuQYGL = new Ext.menu.Menu({
        id: 'QYGL',
        items: [
            {
                text: '增加区域信息',              
                handler: addChildQuyuClick
            }
//            {
//                text: '管理区域信息',        
//                handler: onItemClick
//            }
        ]
    });
    
    var menuCar = new Ext.menu.Menu({
        id: 'car',
        items: [
          //  {
          //      text: '即时位置',              
          //      handler:currentPositionClick         
          //  },
            {
                text: '查看最后位置',              
                handler:lastPositionClick         
            },
            {
                text: '孩子管理',              
                 menu:menuSBGL             
            },
//            {
//                text: '好友管理',        
//                //menu: menuHYGL
//                handler:addChildFrendClick
//            },
//            {
//                text: '区域管理',        
//                //menu: menuQYGL
//                 handler:addChildQuyuClick
//            },
//            {
//                text: '常用短语',        
//                 handler: phrasesContentClick
//            },

//            {
//                text: '主动上发',        
//                 handler:changeInterval_onclick
//            },
            {
                text: '轨迹记录',        
                 handler:getTrack_onclick
            },            
            {
                text: '设置上课隐身',        
                 handler:yinshengClick
            },
//            {
//                text: '分析区域',        
//                 handler: analysisAreaClick
//            },
            {
                text: '发送锁机指令',        
                handler: suojiClick
            },
            {
                text: '发送关机指令',        
                 handler: guanjiClick
            }
            
        ]
    });
    
    var menuSystem = new Ext.menu.Menu({
        id: 'menusystem',
        items: [
            {
                text: '修改用户帐号',              
                handler:btnEdit_LoginName         
            },{
                text: '修改用户密码',              
                handler:btnEdit_UserPassWord         
            }
            
        ]
    });
    
    function systemClick()
    {
        Ext.MessageBox.alert('系统提示','此功能稍后开放！');
    }
    
    
     //加孩子
    function _addChildOnclike()
    {
       if(!winAddChild){
            winAddChild = new Ext.Window({            
			    title: '添加孩子',
                layout:'fit',
                width:270,
                height:180,
                closeAction:'hide',
                plain: true,
                
                items: new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding:5px',
					width: 150,
					
					defaults: {width: 130},
					defaultType: 'textfield',
			
					items: [{
							fieldLabel: '孩子名称',
							name: 'childName',
							id: 'childName'
						//	allowBlank:false
						},{
							fieldLabel: '孩子手机',							
							name: 'childPhoneNo',
							id: 'childPhoneNo'
						//	allowBlank:false
						},{
							fieldLabel: 'IMEI号码',							
							name: 'imei',
							id: 'imei'
						//	allowBlank:false
						}
					],
					
					buttons: [{
						text: '添加',
						handler:saveAddChild
						
					},{
						text: '关闭',
						handler:function(){
                        winAddChild.hide();
                    }
					}]
				})
            });
        }
        winAddChild.show(this);
    }
    function saveAddChild(item)
    {
        var child_name=Ext.get('childName').dom.value;
        var child_phone=Ext.get('childPhoneNo').dom.value;
        var imei_no=Ext.get('imei').dom.value
        
        if(child_name=="")
        {
             Ext.MessageBox.alert('系统提示','请输入孩子名称！');
             return;
        }
        if(child_phone!="")
        {
            if(!check_number(child_phone))
                Ext.MessageBox.alert('系统提示','请输入正确的孩子手机号码！');
        }else
            Ext.MessageBox.alert('系统提示','请输入孩子手机号码！');
        
        if(imei_no.length!=15)
        {
             Ext.MessageBox.alert('系统提示','请输入正确的IMEI号码！');
             return;
        }  
        childInfoAdd(child_name,child_phone,imei_no,login_key,childInfoAdd_callback);
        
    }
    function childInfoAdd_callback(result,xml){
        if(result.response_code== "0"){	
             Ext.MessageBox.alert('系统提示','成功添加一个孩子信息！');
             comboCar.store.reload({baseParams:{loginKey:login_key}});
            allTreeReload();
            
        }else
             Ext.MessageBox.alert('系统提示',result.response_result);
    }
    function allTreeReload()
    {
        if(tree)
            tree.root.reload();
        if(childFrend_tree)
            childFrend_tree.root.reload();
        if(childQuyu_tree)
            childQuyu_tree.root.reload();
        if(childContent_tree)
            childContent_tree.root.reload();
    }
    
    //孩子管理----begin
    function _onClickModifyUserInfo()
    {
        var treePanel = new Ext.Panel({ 
        title: '列表信息',
        region: 'west',
        contentEl: 'tree-div',
        split: true,
        border: true,
        collapsible: true,
        width: 170,
        minSize: 150,
        maxSize: 250 
        });    
        var userRightPanel=new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					region: 'center',
					bodyStyle:'padding:10px',
					width: 300,		
					height:270,			
					defaults: {width: 150},					
					defaultType: 'textfield',			
					items: [{
							fieldLabel: '宝贝',
							name: 'child_name',
							id: 'child_name'						
						},{
							fieldLabel: '帐号',
							name: 'IMEI_no',
							editable:false,
							disabled:true,
							id: 'IMEI_no'					
						},{
							fieldLabel: '手机号码',
							name: 'child_phone',
							id: 'child_phone'					
						},{
							fieldLabel: '添加时间',
							editable:false,
							disabled:true,
							name: 'create_time',
							id: 'create_time'					
						},{
							fieldLabel: 'id',
							editable:false,
							disabled:true,
						    hidden:true,
						    hideLabel:true,
							name: 'child_id',
							id: 'child_id'					
						}						
					],
					
					buttons: [{
						text: '修改',
						handler:modifyChildInfo
						
					},
//					{
//						text: '删除',
//						handler:delChildInfo
//						
//					},
					{
						text: '关闭',
						handler:function(){
                        winModifyUserRight.hide();
                        }
					}]
				});
    
    
        if(!tree) 
        {
            tree = new Tree.TreePanel({
               el:'tree-div',                 
               border : false,
               rootVisible:false,
               autoScroll:true,
               animate:true,
               enableDD:true,
               containerScroll: true,
               loader: new Tree.TreeLoader({
                    //dataUrl:'http://localhost/NewPages/aspx/getUserRight.aspx',
                    dataUrl:serverURL+'/aspx/getUserRight.aspx',
                    baseParams:{userRole:3,userDistrict:login_key},
                    preloadChildren: true

                }),
                root: new Ext.tree.AsyncTreeNode({
                text:'test',
                id:'root',
                expanded:true
                
                }),
                collapseFirst:false   
            });
            var root = new Tree.AsyncTreeNode({
                text: '列表信息',
                draggable:false,
                id:'source'
                });
            tree.setRootNode(root);
            tree.render();
            root.expand();
            
        }
        tree.on('click', function(node){ 
             if(node.text!='孩子列表')
             {
            // alert(node.id);
             getUserRightInfo(node.text,login_key,getChildInfo_callback);
             }
         });
        
        if(!winModifyUserRight)
        {
             winModifyUserRight = new Ext.Window({            
			    title: '孩子管理',         
                width:500,
                height:300,
                closeAction:'hide',
                plain: true,               
                layout: 'border',
                items:[treePanel,
                       userRightPanel
                       ]
              });
        }
        winModifyUserRight.show(this);
    }
    function getChildInfo_callback(result,xml)
    {
     //  alert(result.response_code);
        if(result.response_code==0)
        {
            
            var child_info=result.child_info;         
            var nowtime= child_info[0].create_time;
            nowtime = nowtime.getFullYear() + "-" + (nowtime.getMonth()+1) + "-" + nowtime.getDate() + " " + nowtime.getHours() + ":" + nowtime.getMinutes() + ":" +nowtime.getSeconds();
            
            getLoginName=child_info[0].child_name;
            Ext.get('child_name').dom.value=child_info[0].child_name;     
            Ext.get('child_phone').dom.value=child_info[0].child_phone;
            Ext.get('IMEI_no').dom.value=child_info[0].imei_no;     
            
           Ext.get('child_id').dom.value=child_info[0].child_id;  
           Ext.get('create_time').dom.value=nowtime;                  
        }
        else
        {
            getLoginName="";
            
            Ext.get('child_name').dom.value="";     
            Ext.get('child_phone').dom.value="";     
            Ext.get('create_time').dom.value="";  
             Ext.get('child_id').dom.value=""; 
             Ext.get('IMEI_no').dom.value="";
        }
    }
    function modifyChildInfo()
    {
            if(Ext.get('child_name').dom.value==""){Ext.MessageBox.alert('系统提示',"请输入孩子名称！"); Ext.get('child_name').dom.focus();return;}
            if(Ext.get('child_phone').dom.value==""){Ext.MessageBox.alert('系统提示',"请输入用户手机号码！");Ext.get('child_phone').dom.focus();return;}
            if(Ext.get('IMEI_no').dom.value==""){Ext.MessageBox.alert('系统提示',"请输入用户账号！");Ext.get('IMEI_no').dom.focus();return;}
            modify_child_info(Ext.get('child_name').dom.value,Ext.get('child_phone').dom.value,Ext.get('child_id').dom.value, Ext.get('IMEI_no').dom.value,login_key,modify_child_info_callback);
    }
    function modify_child_info_callback(result,xml)
    {
        if(result.response_code==0)
        {
            Ext.MessageBox.alert('系统提示','修改信息成功！');
            comboCar.store.reload({baseParams:{loginKey:login_key}}); 
            comboCar.setValue(comstore.getAt(0).get("carname"));
            allTreeReload();
//           if(tree)
//                tree.root.reload();
//            if(childFrend_tree)
//                childFrend_tree.root.reload();
//            if(childQuyu_tree)
//                childQuyu_tree.root.reload();
//            if(childContent_tree)
//                childContent_tree.root.reload();
            
        }else if(result.response_code==-1)
        {
            Ext.MessageBox.alert('错误提示',result.response_result);
            window.location.href="main.html";
        }
        else{Ext.MessageBox.alert('错误提示',result.response_result+result.response_code);}
    }
    function delChildInfo()
    {
           Ext.MessageBox.confirm('系统提示', "您确定要删除["+ Ext.get('child_name').dom.value +"]的信息吗?",function(button,text)
            {
                if(button=='yes')
                {
                    del_child_info(Ext.get('child_id').dom.value,login_key,delChildInfo_callback); 
                }
            });
        
    }
    function delChildInfo_callback(result,xml)
    {       
        if(result.response_code==0)
        {
            Ext.MessageBox.alert('系统提示','删除孩子信息成功！');
            comboCar.store.reload({baseParams:{loginKey:login_key}}); 
           // tree.root.reload();   
                               //del用户成功,重新加载树
           allTreeReload();
//             if(tree)
//                tree.root.reload();
//            if(childFrend_tree)
//                childFrend_tree.root.reload();
//            if(childQuyu_tree)
//                childQuyu_tree.root.reload();
//            if(childContent_tree)
//                childContent_tree.root.reload();
            //getLoginName="";
            Ext.get('child_name').dom.value="";
            Ext.get('child_phone').dom.value=""; 
            Ext.get('IMEI_no').dom.value=""; 
            Ext.get('create_time').dom.value="";     
            Ext.get('child_id').dom.value="";     
            
        }
        else if(result.response_code==-1)
        {
           Ext.MessageBox.alert('错误提示',result.response_result);
            window.location.href="main.html";
        }
        else{Ext.MessageBox.alert('错误提示',result.response_result);}
    }
    
    //孩子管理----end-
    
     //主动上发-----begin
      
 Ext.exampledata.hours = [ 
          //  [['0'],['0']],
            [['1'],['1']],
            [['2'],['2']],
			[['3'],['3']],
            [['4'],['4']],
            [['5'],['5']],
			[['6'],['6']],
            [['7'],['7']],
            [['8'],['8']],
			[['9'],['9']],
            [['10'],['10']],
            [['11'],['11']],
			[['12'],['12']],
            [['13'],['13']],
            [['14'],['14']],
			[['15'],['15']],
            [['16'],['16']],
            [['17'],['17']],
			[['18'],['18']],
            [['19'],['19']],
            [['20'],['20']],
			[['21'],['21']],
            [['22'],['22']],
            [['23'],['23']],
            [['24'],['24']]
			
        ];
    var store_hours = new Ext.data.SimpleStore({
        fields: ['hours_id','hours'],
        data : Ext.exampledata.hours 
    });
    var combo_hours = new Ext.form.ComboBox({
        store: store_hours,        
        fieldLabel: '从',
        displayField:'hours',
        valueField:'hours_id',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择时...',
        selectOnFocus:true,
        width:82
    });
     var store_hours2 = new Ext.data.SimpleStore({
        fields: ['hours_id','hours'],
        data : Ext.exampledata.hours 
    });
     var combo_hours2 = new Ext.form.ComboBox({
        store: store_hours2,        
        fieldLabel: '至',
        displayField:'hours',
        valueField:'hours_id',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择时...',
        selectOnFocus:true,
        width:82
    });
	Ext.exampledata.minutes = [ 
        //    [['0'],['0']],
            [['01'],['1']],
            [['02'],['2']],
			[['03'],['3']],
            [['04'],['4']],
            [['05'],['5']],
			[['06'],['6']],
            [['07'],['7']],
            [['08'],['8']],
			[['09'],['9']],
            [['10'],['10']],
            [['11'],['11']],
			[['12'],['12']],
            [['13'],['13']],
            [['14'],['14']],
			[['15'],['15']],
            [['16'],['16']],
            [['17'],['17']],
			[['18'],['18']],
            [['19'],['19']],
            [['20'],['20']],
			[['21'],['21']],
            [['22'],['22']],
            [['23'],['23']],
			[['24'],['24']],
            [['25'],['25']],
            [['26'],['26']],
			[['27'],['27']],
            [['28'],['28']],
            [['29'],['29']],
			[['30'],['30']],
            [['31'],['31']],
            [['32'],['32']],
			[['33'],['33']],
            [['34'],['34']],
            [['35'],['35']],
			[['36'],['36']],
            [['37'],['37']],
            [['38'],['38']],
			[['39'],['39']],
            [['40'],['40']],
            [['41'],['41']],
			[['42'],['42']],
            [['43'],['43']],
            [['44'],['44']],
			[['45'],['45']],
            [['46'],['46']],
            [['47'],['47']],
			[['48'],['48']],
            [['49'],['49']],
            [['50'],['50']],
			[['51'],['51']],
            [['52'],['52']],
            [['53'],['53']],
			[['54'],['54']],
            [['55'],['55']],
            [['56'],['56']],
			[['57'],['57']],
            [['58'],['58']],
            [['59'],['59']],
			 [['60'],['60']]
			
        ];
    var store_minutes = new Ext.data.SimpleStore({
        fields: ['minutes_id','minutes'],
        data : Ext.exampledata.minutes 
    });
    var combo_minutes = new Ext.form.ComboBox({
        store: store_minutes,        
        fieldLabel: '时',
        displayField:'minutes',
        valueField:'minutes_id',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择分...',
        selectOnFocus:true,
        width:82
    });
 var store_minutes2 = new Ext.data.SimpleStore({
        fields: ['minutes_id','minutes'],
        data : Ext.exampledata.minutes 
    });
    var combo_minutes2 = new Ext.form.ComboBox({
        store: store_minutes2,        
        fieldLabel: '时',
        displayField:'minutes',
        valueField:'minutes_id',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择分...',
        selectOnFocus:true,
        width:82
    });
    var timeInterval = new Ext.form.TextField({
        columnWidth : .5,
         labelWidth :100,
      //  fieldLabel: '上发时间间隔',
        name: 'TimeInterval',
        id: 'TimeInterval'
     //   anchor: '100%'
    });
		var labelInterval =new Ext.form.Label({	
		columnWidth : .25,	                   
		text:'上发时间间隔'
		//tag: 'h2',
		//anchor:'100%'
	});
		var labelInterval1 =new Ext.form.Label({	
		columnWidth : .25,	                   
		text:'(分钟)'
		//tag: 'h2',
		//anchor:'100%'
	});
     function changeInterval_onclick()
     {

    
        if(comboCar.getValue() == ""){Ext.MessageBox.alert('系统提示','请先选择车辆!'); return;}
         
        if(!winChangeInterval)
        {
            winChangeInterval=new Ext.Window({            
	            title: '修改主动上发条件',
	            resizable:false,	//变大小
                layout:'fit',
                width:270,
                height:200,
                frame:true,
                modal: true,
                closeAction:'hide',
                bodyStyle:'padding:5px;',  
                buttonAlign:'center',  
                //border : false,
                plain: true,
                items: new Ext.FormPanel({
                   frame: true,
                   bodyStyle:'padding:5px 5px 0',
                   width:190,
                   defaults: {width: 190},
                   items: [
                   {   
                  
                         layout: 'column',
			            //columnWidth:.5,
			            anchor: '100%',
			            baseCls: 'x-plain',
			            items: [{				
				            labelWidth: 10,
				            width: 104,				
				            layout: 'form',
				            baseCls: 'x-plain',				
				            items: combo_hours
			            }, {	
				            //columnWidth:.1,
				            labelWidth: 10,
				            width: 104,				
				            layout: 'form',
				            baseCls: 'x-plain',				
				            items: combo_minutes
			            }
			            ]
                    },{
                        layout: 'column',
			            //columnWidth:.5,
			            anchor: '100%',
			            baseCls: 'x-plain',
			            items: [{				
				            labelWidth: 10,
				            width: 104,				
				            layout: 'form',
				            baseCls: 'x-plain',				
				            items: combo_hours2
			            }, {	
				            //columnWidth:.1,
				            labelWidth: 10,
				            width: 104,				
				            layout: 'form',
				            baseCls: 'x-plain',				
				            items: combo_minutes2
			            }
			            ]
                  },{	height:15,baseCls: 'x-plain'},
                  {
                      layout:'column',
                      width:190,
                      defaults: {width: 190},
                      items:[
                        {
                            columnWidth : .4,
                            width:80,
                            xtype:'label',
                            text:'上发时间间隔:',
                            anchor: '80%'
                        },{
                            width:80,
                            columnWidth : .3,
                            xtype:'textfield',
                            name: 'TimeInterval',
					        id: 'TimeInterval',
					        anchor: '10%'
                     
                       },{
                             width:30,
                            columnWidth : .3,
                             xtype:'label',
                             name:'TimeLabel',
                             id:'TimeLabel',
                            text:'(分钟)'
                       }
                       ]

                  }
               
                  ]

		        }),
    				
		        buttons: [{
			        text: '修改',
			        handler:Common_Auto_Up_Modify
		        },{
			        text: '关闭',
			        handler:function(){
			        delete_ploygon(0);
                    winChangeInterval.hide();
                }
		        }]
            });
        }
        
        winChangeInterval.show(this);
        Common_Auto_Up_Query(comboCar.getValue(),login_key,Common_Auto_Up_Query_callback)

     }
     function Common_Auto_Up_Modify()
     {
       // alert(combobox_changeInterval_type.getValue());
       
           if(!check_number(Ext.get('TimeInterval').dom.value)){
		        Ext.MessageBox.alert('系统提示',"上发时间间隔应为数字!!!");
		    return;
	        }    
//	    if(Ext.get('TimeInterval').dom.value < 5){
//		    Ext.MessageBox.alert('系统提示',"您设置的时间间隔太短，最短时间5分钟");
//		    return;
//	    }

        var reqserialno = 0;
	//    var auto_up=new carto_web_autoup(combobox_changeInterval_type.getValue(),Ext.get('startdt2').dom.value,Ext.get('enddt2').dom.value,Ext.get('TimeInterval').dom.value,Ext.get('DistInterval').dom.value);
    	var begin_time=	parseInt(combo_hours.getValue()+combo_minutes.getValue());
    	var end_time=	parseInt(combo_hours2.getValue()+combo_minutes2.getValue());
	    var parameters = new SOAPClientParameters();
	    	parameters.add("child_name",escape(comboCar.getValue()));
	    	parameters.add("begin_time",parseInt(begin_time));
	    	parameters.add("end_time",parseInt(end_time));
	    	parameters.add("interval",parseInt(Ext.get('TimeInterval').dom.value));
	    	parameters.add("common_id",2);
	    	parameters.add("login_key",login_key);	

     //   alert("child_name:"+comboCar.getValue()+"；begin_time:"+begin_time+"；end_time:"+end_time+"；interval:"+Ext.get('TimeInterval').dom.value+":login_key:"+login_key);
	    acxs_q6_function('Q6CommonSetAutoup',parameters,true,Q6CommonSetAutoup_callback);
     }
        //查询上发条件参数设置回调函数
    function Common_Auto_Up_Query_callback(result,responseXml){
	    var result_flag = -100;		//默认是没有返回结果或者结果出错。
	    var xmlDoc = loadXML(responseXml);
	    var xmlResult = "Q6CommonQueryAutoupResult/";
	    var xPath = xmlResult + "response_code";
	    result_flag = parseInt(getNodeValue(xmlDoc,xPath));
	   //alert(result_flag);
	    if(result_flag == 0){
		    xPath = xmlResult + "auto_up/begin_time";
		    var begin_time = getNodeValue(xmlDoc,xPath);

		    xPath = xmlResult + "auto_up/end_time";
		    var end_time = getNodeValue(xmlDoc,xPath);		   
          
		    xPath = xmlResult + "auto_up/interval";
		    var interval = getNodeValue(xmlDoc,xPath);
		    
//		    alert(begin_time);
//		    alert(end_time);
//		    
	        //begin_time.toString("0000");
	        var begin_h;
	        var begin_m;
	        
	        var end_h;
	        var end_m;
	        
	        if(begin_time.length==3)
	        {
	            begin_h=begin_time.substring(0,1);
	            begin_m=begin_time.substring(1,3);
	        }else if(begin_time.length==4)
            {
                begin_h=begin_time.substring(0,2);
                begin_m=begin_time.substring(2,4);
            }else
            {
                begin_h=0;
                begin_m=0;
            }
            
            if(end_time.length==3)
	        {
	            end_h=end_time.substring(0,1);
	            end_m=end_time.substring(1,3);
	        }else if(end_time.length==4)
            {
                end_h=end_time.substring(0,2);
                end_m=end_time.substring(2,4);
            }else
            {
                end_h=0;
                end_m=0;
            }
	        
//	        alert("begin_h:"+begin_h+";begin_m:"+begin_m);
//	        alert("end_h:"+end_h+";end_m:"+end_m);
	       
	       combo_hours.setValue(begin_h);
	       combo_minutes.setValue(begin_m);
	       
	       combo_hours2.setValue(end_h);
	       combo_minutes2.setValue(end_m);
	        Ext.get('TimeInterval').dom.value=interval;
		  
		   
    		
    //		select1_onchange();                             //同步一下参数
	    }else if(result_flag==1){
		    Ext.MessageBox.alert('错误提示',error_message_web_server)
		    winChangeInterval.hide();
	    }else if(result_flag==-1){
		    Ext.MessageBox.alert('错误提示',error_message_timeout);
	        winChangeInterval.hide();
	    }else if(result_flag==-3){
		    Ext.MessageBox.alert('错误提示',error_carno_no);
		    winChangeInterval.hide();
	    }else if(result_flag==-4||result_flag==-5){
		    Ext.MessageBox.alert('错误提示',error_carno_err);
		    winChangeInterval.hide();
	    }else if(result_flag==-100){
		    Ext.MessageBox.alert('错误提示',error_message_system);
		    winChangeInterval.hide();
	    }
    }
  //修改上发条件参数设置回调函数
    function Q6CommonSetAutoup_callback(result,responseXml){
      //  alert(responseXml);
	    var result_flag = -100;		//默认是没有返回结果或者结果出错。
	    var result_text = error_message_web_server;
        var result_serial_no = -1;
        var request_serial_no = -1;
	    var xmlDoc = loadXML(responseXml);
	    var xmlResult = "Q6CommonSetAutoupResult/";
	    var xPath = xmlResult + "response_code";
	    result_flag = getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "response_result";
	    result_text = getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "response_serial_no";
	    result_serial_no = getNodeValue(xmlDoc,xPath); 
        xPath = xmlResult + "request_serial_no";
        request_serial_no = getNodeValue(xmlDoc,xPath); 
  //     alert("result_flag:"+result_flag);
	    if(result_flag == 0){
	        //window.returnValue=result_serial_no;
	        //self.close();
	      //  add_request(comboCar.getValue(),2,"",result_serial_no);   
	       add_q6_request(comboCar.getValue(),Ext.get('comboName').dom.value,2,"",result_serial_no,new Date());	
	        addStatus("["+comboCar.getValue()+"]开始修改上发条件！");
	        winChangeInterval.hide();
	    }else if(result_flag==1){
		    Ext.MessageBox.alert('错误提示',result_text);
		   winChangeInterval.hide();
	    }else if(result_flag==-1){
		    Ext.MessageBox.alert('错误提示',error_message_timeout);
	        winChangeInterval.hide();
	    }else if(result_flag==-3){
		    Ext.MessageBox.alert('错误提示',error_carno_no);
		    winChangeInterval.hide();
	    }else if(result_flag==-4||result_flag==-5){
		    Ext.MessageBox.alert('错误提示',error_carno_err);
		    winChangeInterval.hide();
	    }else if(result_flag==-100){
		    Ext.MessageBox.alert('错误提示',error_message_system);
		    winChangeInterval.hide();
	    }else if(result_flag==-7){
		    Ext.MessageBox.alert('错误提示',result_text);
		    winChangeInterval.hide();
	    }else if(result_flag==-8){
		    Ext.MessageBox.alert('错误提示',"您没有修改过任何参数！");
		    winChangeInterval.hide();
	    }else{
		    Ext.MessageBox.alert('错误提示',result_text);	
	    }	
    } 
    
//主动上发------end   

//行车纪录---begin
 
  Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var date = field.parseDate(val);

        if(!date){
            return;
        }
        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(date);
            start.validate();
            this.dateRangeMax = date;
        } 
        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(date);
            end.validate();
            this.dateRangeMin = date;
        }
        /*
         * Always return true since we're only using this vtype to set the
         * min/max allowed values (these are tested for after the vtype test)
         */
        return true;
    }
 });
 
 Ext.exampledata.dt_hour = [ 
            [['0'],['0时']],
            [['1'],['1时']],
            [['2'],['2时']],
			[['3'],['3时']],
            [['4'],['4时']],
            [['5'],['5时']],
			[['6'],['6时']],
            [['7'],['7时']],
            [['8'],['8时']],
			[['9'],['9时']],
			[['10'],['10时']],
			[['11'],['11时']],
            [['12'],['12时']],
            [['13'],['13时']],
			[['14'],['14时']],
            [['15'],['15时']],
            [['16'],['16时']],
			[['17'],['17时']],
            [['18'],['18时']],
            [['19'],['19时']],
			[['20'],['20时']],
			[['21'],['21时']],
			[['22'],['22时']],
			[['23'],['23时']]
			
        ];
 var store_hour = new Ext.data.SimpleStore({
        fields: ['dtID','hour'],
        data : Ext.exampledata.dt_hour 
    });
 var combobox_dt_hour = new Ext.form.ComboBox({
        store: store_hour,        
        hideLabel: true,
        displayField:'hour',
        editable: false,//不允许输入 
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        disableKeyFilter:true,
        emptyText:'请选择...',
        selectOnFocus:true,
        width:70,
        listeners:{
            select:function(combo, record,index){
             }
        }
    });   
    
    
 function getTrack_onclick()
 {
    if(comboCar.getValue() == ""){Ext.MessageBox.alert('系统提示','请先选择车辆!'); return;}
    if(!winGetTrack)
    {
        winGetTrack=new Ext.Window({            
	        title: '查询行踪',
	        resizable:false,	//变大小
            layout:'fit',
            width:300,
            height:150,
            frame:true,
            modal: true,
            closeAction:'hide',
            bodyStyle:'padding:5px;',  
            buttonAlign:'center',  
            //border : false,
            plain: true,
            items: new Ext.FormPanel({
               frame: true,
               bodyStyle:'padding:5px 5px 0',
               width: 120,
               defaults: {width: 140},
              // defaultType: 'datefield',
               items: [
               {   
              
                   // layout:'column',
                  //  items:[{
                    //columnWidth : .5,
                    labelWidth : 0,
                      xtype:'datefield',
                      fieldLabel: '请选择查询日期',
                      name: 'startdt',
                      id: 'startdt',
                      vtype: 'daterange'
                    //  endDateField: 'enddt' 
                   // },combobox_dt_hour
                   // ]
                }
//                {
//                  xtype:'datefield',
//                  fieldLabel: '至',
//                  name: 'enddt',
//                  id: 'enddt',
//                  vtype: 'daterange',
//                 startDateField: 'startdt'
//              }
              ]

		    }),
				
		    buttons: [{
			    text: '查询',
			    handler:query_TrackInfo
		    },{
			    text: '关闭',
			    handler:function(){
			    delete_ploygon(0);
                winGetTrack.hide();
            }
		    }]
        });
    }
    
    winGetTrack.show(this);
 }
 function query_TrackInfo()
 {
 
 //   Get_Track_Info(comboCar.getValue(),Ext.get("startdt").dom.value,Ext.get("enddt").dom.value,login_key,Get_Track_Info_Callback);    
    Get_Track_Info(comboCar.getValue(),Ext.get("startdt").dom.value,Ext.get("startdt").dom.value,login_key,Get_Track_Info_Callback);    
 }
 //获取轨迹记录返回值，描绘在地图上
    function Get_Track_Info_Callback(result,responseXml){    
        var result_flag = 1;		//默认是没有返回结果或者结果出错。
        result_flag = parseInt(result.response_code);
        var xmlDoc = loadXML(responseXml);
        var xmlResult = "Q6CommonTrackQueryResult/";
        var carno = result.child_name;
        var car_position_info_list = new Array();
        var i;  
       
	    if(result_flag == 0){	
	        
	        xPath = xmlResult + "track_position_info/q6_web_position_info";
		    var position_info_l = getNodeElements(xmlDoc,xPath);				
		    for(var i=0;i<position_info_l.length;i++){			    
		        var lon = position_info_l[i].childNodes[0].childNodes[0].nodeValue;					
		        var lat = position_info_l[i].childNodes[1].childNodes[0].nodeValue;
		        var speed = 10
		        var nowtime = position_info_l[i].childNodes[2].childNodes[0].nodeValue;
		        var stars = 10
		        var directions = position_info_l[i].childNodes[3].childNodes[0].nodeValue;
		        var current_status = "00000000";	
		        car_position_info_list[i]=new position_info(lon,lat,speed,nowtime,stars,directions,current_status);
		    }	
		    if(car_position_info_list.length>0)	
		    {
		        winGetTrack.hide(); 
		        addStatus("["+carno+"]查询到"+car_position_info_list.length+"个位置信息！");
		        for(i=car_position_info_list.length-1;i>0;i--){
		            if(parseInt(car_position_info_list[i].stars,10) > 3 && parseFloat(car_position_info_list[i].speed) < 180)
		              //  alert(car_position_info_list[i].longitude);
		              //  btnAddCarPositionToMap(carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].speed,car_position_info_list[i].directions,car_position_info_list[i].current_time,car_position_info_list[i].current_status,"false",1);
		               addGpsPosition(car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].directions,car_position_info_list[i].current_status,carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].current_time,car_position_info_list[i].speed,12,1);//地图上描点
    		    }
                i=0;
               // btnAddCarPositionToMap(carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].speed,car_position_info_list[i].directions,car_position_info_list[i].current_time,car_position_info_list[i].current_status,12,1);
               addGpsPosition(car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].directions,car_position_info_list[i].current_status,carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].current_time,car_position_info_list[i].speed,12,1);//地图上描点
              
              showTrackInMap();
                  
            
            }
	    }else if(result_flag == -1){
	        Ext.MessageBox.alert('错误提示',error_message_timeout);
	       winGetTrack.hide();    
	    }else if(result_flag == -2){
	         Ext.MessageBox.alert('错误提示','数据库错误,请与客户服务中心联系！');
	          winGetTrack.hide();     
	    }else if(result_flag == -3){
	    　    Ext.MessageBox.alert('错误提示',"您选择的时间段有错，开始时间不能大于结束时间！");	 	    
	    }else if(result_flag == -4){
	        Ext.MessageBox.alert('错误提示',"查行踪只能按月查询！");	
	    }else if(result_flag == -5){
	         Ext.MessageBox.alert('错误提示',"["+carno+"]没有查询到轨迹记录！");
	      
	    }else{
	        Ext.MessageBox.alert('错误提示',error_message_web_server);
	        winGetTrack.hide();    
	    }
    }
//行车纪录-----end
    
    
 
   //增加孩子好友-----begin 
   
    function addChildFrendClick()
    {
    
        Ext.exampledata.bianhao = [ 
            [['1'],['1']],
            [['2'],['2']],
            [['3'],['3']],
			[['4'],['4']],
            [['5'],['5']],
            [['6'],['6']],
			[['7'],['7']],
            [['8'],['8']],
            [['9'],['9']],
			[['10'],['10']],
			[['11'],['11']],
			[['12'],['12']],
			[['13'],['13']],
			[['14'],['14']],
			[['15'],['15']],
			[['16'],['16']],
			[['17'],['17']],
			[['18'],['18']],
			[['19'],['19']],
			[['20'],['20']]
			
        ];
    var store_bianhao = new Ext.data.SimpleStore({
        fields: ['bianhaoID','bianhao'],
        data : Ext.exampledata.bianhao 
    });
    combobox_bianhao = new Ext.form.ComboBox({
        store: store_bianhao,   
        editable: false,//不允许输入 
       // name:'aa',
       // id:'aa',
       // hideLabel: true,
        fieldLabel:'编号',
        displayField:'bianhao',
       valueField:'bianhaoID',
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        disableKeyFilter:true,
        emptyText:'请选择...',
        selectOnFocus:true,
        hidden:false,
        hideLabel:false,
        width:70,
        listeners:{
            select:function(combo, record,index){
                    if(Ext.get('child_id2').dom.value==''||Ext.get('child_name2').dom.value=='')
                    {
                        Ext.MessageBox.alert('系统提示','请先正确选择小孩名称');
                        return;
                    }
                    getChildFrendByID(Ext.get('child_id2').dom.value,this.getValue(),login_key,getChildFrendByID_callback);
                }
        }
    });
    
    
         var treePanel = new Ext.Panel({ 
        title: '列表信息',
        region: 'west',
        contentEl: 'tree-div2',
        split: true,
        border: true,
        collapsible: true,
        width: 170,
        minSize: 150,
        maxSize: 250 
        });    
        var userRightPanel2=new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					region: 'center',
					bodyStyle:'padding:10px',
					width: 350,		
					height:270,			
					defaults: {width: 150},					
					defaultType: 'textfield',			
					items: [{
							fieldLabel: '孩子名称',
							name: 'child_name2',
							editable:false,
							disabled:true,
							id: 'child_name2'						
						},{
							fieldLabel: '手机号码',
							editable:false,
							disabled:true,
							name: 'child_phone2',
							id: 'child_phone2'					
						},
						combobox_bianhao,
//						{
//							fieldLabel: '朋友编号',
//							name: 'frend_index',
//							id: 'frend_index'					
//						},
						{
							fieldLabel: '朋友名称',
							name: 'frend_name',
							id: 'frend_name'					
						},
						{
							fieldLabel: '朋友号码',
							name: 'frend_phone',
							id: 'frend_phone'					
						},{
							fieldLabel: 'id',
							editable:false,
							disabled:true,
						    hidden:true,
						    hideLabel:true,
							name: 'child_id2',
							id: 'child_id2'					
						}						
					],
					
					buttons: [
//					{
//						text: '添加',
//						handler:andChildFrendInfo
//						
//					},
{
						text: '修改',
						handler:andChildFrendInfo
						
					},{
						text: '删除',
						handler:delChildFrendInfo
						
					},
					{
						text: '关闭',
						handler:function(){
                        winAddChildFrend.hide();
                        }
					}]
				});
    
    
        if(!childFrend_tree) 
        {
            childFrend_tree = new Tree.TreePanel({
               el:'tree-div2',                 
               border : false,
               rootVisible:false,
               autoScroll:true,
               animate:true,
               enableDD:true,
               containerScroll: true,
               loader: new Tree.TreeLoader({
                    //dataUrl:'http://localhost/NewPages/aspx/getUserRight.aspx',
                    dataUrl:serverURL+'/aspx/getUserRight.aspx',
                    baseParams:{userRole:3,userDistrict:login_key},
                    preloadChildren: true

                }),
                root: new Ext.tree.AsyncTreeNode({
                text:'test',
                id:'root',
                expanded:true
                
                }),
                collapseFirst:false   
            });
            var root = new Tree.AsyncTreeNode({
                text: '列表信息',
                draggable:false,
                id:'source'
                });
            childFrend_tree.setRootNode(root);
            childFrend_tree.render();
            root.expand();
            
        }
        childFrend_tree.on('click', function(node){ 
             if(node.text!='孩子列表')
             {getUserRightInfo(node.text,login_key,getUserinfo_callback);}
         });
        
        if(!winAddChildFrend)
        {
             winAddChildFrend = new Ext.Window({            
			    title: '添加孩子朋友信息',         
                width:480,
                height:300,
                closeAction:'hide',
                plain: true,               
                layout: 'border',
                items:[treePanel,
                       userRightPanel2
                       ]
              });
        }
      winAddChildFrend.show(this);
    }
    function getChildFrendByID_callback(result,xml)
    {
      
        if(result.response_code==0)
        {
            var child_friend=result.child_friend_info;
            if(child_friend.length>0)
            {
                Ext.get('frend_name').dom.value=child_friend[0].friend_name;
                Ext.get('frend_phone').dom.value=child_friend[0].friend_phone;
            }else
            {
                
                Ext.get('frend_name').dom.value='';
                Ext.get('frend_phone').dom.value='';
            }
        }
    }
    
    function getUserinfo_callback(result,xml)
    {
       
        if(result.response_code==0)
        {
            var child_info=result.child_info;         
            var nowtime= child_info[0].create_time;
            nowtime = nowtime.getFullYear() + "-" + (nowtime.getMonth()+1) + "-" + nowtime.getDate() + " " + nowtime.getHours() + ":" + nowtime.getMinutes() + ":" +nowtime.getSeconds();
            
            getLoginName=child_info[0].child_name;
            Ext.get('child_name2').dom.value=child_info[0].child_name;     
            Ext.get('child_phone2').dom.value=child_info[0].child_phone; 
            Ext.get('child_id2').dom.value=child_info[0].child_id;  
         }
        else
        {
           // getLoginName="";
            
            Ext.get('child_name2').dom.value="";     
            Ext.get('child_phone2').dom.value="";     
            Ext.get('child_id2').dom.value=""; 
        }
    }
    function andChildFrendInfo()
    {   
        if(check_telephone(Ext.get('frend_phone').dom.value))
        {
            add_child_frend(Ext.get('child_id2').dom.value,combobox_bianhao.getValue(),Ext.get('frend_name').dom.value,Ext.get('frend_phone').dom.value,login_key,add_child_frend_callback);
        }else
            Ext.MessageBox.alert('错误提示','请输入正确的手机号码！');
    }
    function delChildFrendInfo()
    {
         if(Ext.get('child_id2').dom.value==''||Ext.get('child_name2').dom.value=='')
        {
            Ext.MessageBox.alert('系统提示','请先正确选择小孩名称');
            return;
        }
        
        del_child_frend(Ext.get('child_id2').dom.value,combobox_bianhao.getValue(),login_key,del_child_frend_callback);
    }
    function del_child_frend_callback(result,xml)
    {
         if(result.response_code==0)
       {
            Ext.MessageBox.alert('系统提示','删除朋友号码成功！'); 
               Ext.get('frend_name').dom.value='';
                Ext.get('frend_phone').dom.value='';
          // var str="好友:"+combobox_bianhao.getValue()+","+Ext.get('frend_name').dom.value+","+Ext.get('frend_phone').dom.value;       
         // command_(Ext.get('child_phone2').dom.value,str,login_key,command_callback)
       }
       else
             Ext.MessageBox.alert('错误提示',result.response_result);
    }
    function add_child_frend_callback(result,xml)
    {
       
       if(result.response_code==0)
       {
          //   Ext.MessageBox.alert('系统提示','添加朋友号码成功！'); 
          var str="好友:"+combobox_bianhao.getValue()+","+Ext.get('frend_name').dom.value+","+Ext.get('frend_phone').dom.value;       
          command_(Ext.get('child_phone2').dom.value,str,login_key,5,command_callback)
       }
       else
             Ext.MessageBox.alert('错误提示',result.response_result);
    }
    
   //增加孩子好友-----end 
    
    //增加区域名称-----begin
    function addChildQuyuClick()
    {
    
            Ext.exampledata.quyumingcheng = [ 
            
            [['1'],['1']],
            [['2'],['2']],
            [['3'],['3']],
			[['4'],['4']],
            [['5'],['5']],
            [['6'],['6']],
			[['7'],['7']],
            [['8'],['8']],
            [['9'],['9']],
			[['10'],['10']],
			[['11'],['11']],
			[['12'],['12']],
			[['13'],['13']],
			[['14'],['14']],
			[['15'],['15']],
			[['16'],['16']],
			[['17'],['17']],
			[['18'],['18']],
			[['19'],['19']],
			[['20'],['20']]
			
        ];
    var store_quyu = new Ext.data.SimpleStore({
        fields: ['bianhaoID','bianhao'],
        data : Ext.exampledata.quyumingcheng 
    });
    combobox_quyumingcheng = new Ext.form.ComboBox({
        store: store_quyu,   
        editable: false,//不允许输入 
      
        fieldLabel:'区域',
        displayField:'bianhao',
        valueField:'bianhaoID',
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        disableKeyFilter:true,
        emptyText:'请选择...',
        selectOnFocus:true,
        hidden:false,
        hideLabel:false,
        width:70,
        listeners:{
            select:function(combo, record,index){
                    if(Ext.get('child_id3').dom.value==''||Ext.get('child_name3').dom.value=='')
                    {
                        Ext.MessageBox.alert('系统提示','请先正确选择小孩名称');
                        return;
                    }
                    getChildAreaByID(Ext.get('child_id3').dom.value,this.getValue(),login_key,getChildAreaByID_callback);
                }
        }
    });
   
    
        var treePanel = new Ext.Panel({ 
        title: '列表信息',
        region: 'west',
        contentEl: 'tree-div3',
        split: true,
        border: true,
        collapsible: true,
        width: 170,
        minSize: 150,
        maxSize: 250 
        });    
        var userRightPanel2=new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					region: 'center',
					bodyStyle:'padding:10px',
					width: 350,		
					height:270,			
					defaults: {width: 150},					
					defaultType: 'textfield',			
					items: [{
							fieldLabel: '孩子名称',
							name: 'child_name3',
							id: 'child_name3',
							editable:false,
							disabled:true
													
						},{
							fieldLabel: '手机号码',
							name: 'child_phone3',
							id: 'child_phone3',	
							editable:false,
							disabled:true
											
						},combobox_quyumingcheng,
						{
							fieldLabel: '区域名称',
							name: 'area_name',
							id: 'area_name'					
						},{
							fieldLabel: 'id',
							editable:false,
							disabled:true,
						    hidden:true,
						    hideLabel:true,
							name: 'child_id3',
							id: 'child_id3'					
						}						
					],
					
					buttons: [{
						text: '修改',
						handler:andChildQuyuInfo
						
					},{
						text: '删除',
						handler:delChildQuyuInfo
						
					},					
					{
						text: '关闭',
						handler:function(){
                        winAddChildQuyu.hide();
                        }
					}]
				});
    
    
        if(!childQuyu_tree) 
        {
            childQuyu_tree = new Tree.TreePanel({
               el:'tree-div3',                 
               border : false,
               rootVisible:false,
               autoScroll:true,
               animate:true,
               enableDD:true,
               containerScroll: true,
               loader: new Tree.TreeLoader({
                    //dataUrl:'http://localhost/NewPages/aspx/getUserRight.aspx',
                    dataUrl:serverURL+'/aspx/getUserRight.aspx',
                    baseParams:{userRole:3,userDistrict:login_key},
                    preloadChildren: true

                }),
                root: new Ext.tree.AsyncTreeNode({
                text:'test',
                id:'root',
                expanded:true
                
                }),
                collapseFirst:false   
            });
            var root = new Tree.AsyncTreeNode({
                text: '列表信息',
                draggable:false,
                id:'source'
                });
            childQuyu_tree.setRootNode(root);
            childQuyu_tree.render();
            root.expand();
            
        }
        childQuyu_tree.on('click', function(node){ 
             if(node.text!='孩子列表')
             {getUserRightInfo(node.text,login_key,getUserInfo2_callback);}
         });
        
        if(!winAddChildQuyu)
        {
             winAddChildQuyu = new Ext.Window({            
			    title: '修改区域信息',         
                width:480,
                height:300,
                closeAction:'hide',
                plain: true,               
                layout: 'border',
                items:[treePanel,
                       userRightPanel2
                       ]
              });
        }
      winAddChildQuyu.show(this);
    }
    
    
    function getUserInfo2_callback(result,xml)
    {
       
        if(result.response_code==0)
        {
            var child_info=result.child_info;         
            var nowtime= child_info[0].create_time;
            nowtime = nowtime.getFullYear() + "-" + (nowtime.getMonth()+1) + "-" + nowtime.getDate() + " " + nowtime.getHours() + ":" + nowtime.getMinutes() + ":" +nowtime.getSeconds();
            
            Ext.get('child_name3').dom.value=child_info[0].child_name;     
            Ext.get('child_phone3').dom.value=child_info[0].child_phone;     
            Ext.get('child_id3').dom.value=child_info[0].child_id;  
                       
        }
        else
        {
            getLoginName="";
            
            Ext.get('child_name3').dom.value="";     
            Ext.get('child_phone3').dom.value="";     
            Ext.get('child_id3').dom.value=""; 
        }
    }
    function getChildAreaByID_callback(result,xml)
    {
      
        if(result.response_code==0)
        {
            var child_area=result.child_area_info;
            if(child_area.length>0)
            {
                Ext.get('area_name').dom.value=child_area[0].area_name;
            }else
            {   
                Ext.get('area_name').dom.value='';
               
            }
        }
    }
    function andChildQuyuInfo()
    {
        if(Ext.get('child_id3').dom.value==''||Ext.get('child_name3').dom.value=='')
        {
            Ext.MessageBox.alert('系统提示','请先正确选择小孩名称');
            return;
        }
        
//        if(combobox_quyumingcheng.getValue()!=empty)
//        {
//            Ext.MessageBox.alert('系统提示','请先选择区域');
//            return;
//        }
        add_child_quyu(Ext.get('child_id3').dom.value,combobox_quyumingcheng.getValue(),Ext.get('area_name').dom.value,login_key,add_child_quyu_callback);
        
    }
    
    function add_child_quyu_callback(result,xml)
    {
       if(result.response_code==0)
       {
          //   Ext.MessageBox.alert('系统提示','添加朋友号码成功！'); 
          var str="区域:"+combobox_quyumingcheng.getValue()+","+Ext.get('area_name').dom.value;       
          command_(Ext.get('child_phone3').dom.value,str,login_key,2,command_callback)
       }
       else
             Ext.MessageBox.alert('错误提示',result.response_result);
    }
    function delChildQuyuInfo()
    {
        del_child_quyu(Ext.get('child_id3').dom.value,combobox_quyumingcheng.getValue(),login_key,del_child_quyu_callback);
    }
    
    function del_child_quyu_callback(result,xml)
    {
       if(result.response_code==0)
       {
          Ext.MessageBox.alert('系统提示','删除区域成功！'); 
          Ext.get('area_name').dom.value='';
         // var str="区域:"+combobox_quyumingcheng.getValue()+","+"";       
          //command_(Ext.get('child_phone3').dom.value,str,login_key,command_callback)
       }
       else
             Ext.MessageBox.alert('错误提示',result.response_result);
    }
    //---end
    
    //---常用短语---begin---
    function phrasesContentClick()
    {
    
      Ext.exampledata.duanyu = [ 
            [['1'],['1']],
            [['2'],['2']],
            [['3'],['3']],
			[['4'],['4']],
            [['5'],['5']],
            [['6'],['6']],
			[['7'],['7']],
            [['8'],['8']],
            [['9'],['9']],
			[['10'],['10']],
			[['11'],['11']],
			[['12'],['12']],
			[['13'],['13']],
			[['14'],['14']],
			[['15'],['15']],
			[['16'],['16']],
			[['17'],['17']],
			[['18'],['18']],
			[['19'],['19']],
			[['20'],['20']]
			
        ];
    var store_duanyu = new Ext.data.SimpleStore({
        fields: ['bianhaoID','bianhao'],
        data : Ext.exampledata.duanyu 
    });
    
    var combobox_duanyu = new Ext.form.ComboBox({
        store: store_duanyu,        
        fieldLabel: '编号',
        displayField:'bianhao',
        valueField:'bianhaoID',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        emptyText:'请选择编号...',
        selectOnFocus:true,
        width:82,
         listeners:{
            select:function(combo, record,index){
                    //alert(this.getValue());
                    getPhraseById(parseInt(this.getValue()),parseInt(login_key),getPhraseById_callback);
                }
        }
    });
       
         var treePanel = new Ext.Panel({ 
        title: '列表信息',
        region: 'west',
        contentEl: 'tree-div4',
        split: true,
        border: true,
        collapsible: true,
        width: 170,
        minSize: 150,
        maxSize: 250 
        });    
        var userRightPanel2=new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					region: 'center',
					bodyStyle:'padding:10px',
					width: 350,		
					height:270,			
					defaults: {width: 150},					
					defaultType: 'textfield',			
					items: [{
							fieldLabel: '孩子名称',
							name: 'child_name4',
							id: 'child_name4',
							editable:false,
							disabled:true
													
						},{
							fieldLabel: '手机号码',
							name: 'child_phone4',
							id: 'child_phone4',	
							editable:false,
							disabled:true
											
						},combobox_duanyu,
						{
						    xtype: 'textarea',
							fieldLabel: '短语',
							name: 'content',
							id: 'content'					
						},{
							fieldLabel: 'id',
							editable:false,
							disabled:true,
						    hidden:true,
						    hideLabel:true,
							name: 'child_id4',
							id: 'child_id4'					
						}						
					],
					
					buttons: [{
						text: '添加',
						handler:andChildContent
						
					},
					{
						text: '关闭',
						handler:function(){
                        winAddChildContent.hide();
                        }
					}]
				});
    
    
        if(!childContent_tree) 
        {        
            childContent_tree = new Tree.TreePanel({
               el:'tree-div4',                 
               border : false,
               rootVisible:false,
               autoScroll:true,
               animate:true,
               enableDD:true,
               containerScroll: true,
               loader: new Tree.TreeLoader({
                    //dataUrl:'http://localhost/NewPages/aspx/getUserRight.aspx',
                    dataUrl:serverURL+'/aspx/getUserRight.aspx',
                    baseParams:{userRole:3,userDistrict:login_key},
                    preloadChildren: true

                }),
                root: new Ext.tree.AsyncTreeNode({
                text:'test',
                id:'root',
                expanded:true
                
                }),
                collapseFirst:false   
            });
            var root = new Tree.AsyncTreeNode({
                text: '列表信息',
                draggable:false,
                id:'source'
                });
            childContent_tree.setRootNode(root);
            childContent_tree.render();
            root.expand();
            
        }
        childContent_tree.on('click', function(node){ 
             if(node.text!='孩子列表')
             {getUserRightInfo(node.text,login_key,getUserInfo3_callback);}
         });
        
        if(!winAddChildContent)
        {
           
             winAddChildContent = new Ext.Window({            
			    title: '常用短语设置',         
                width:480,
                height:300,
                closeAction:'hide',
                plain: true,               
                layout: 'border',
                items:[treePanel,
                       userRightPanel2
                       ]
              });
        }
      winAddChildContent.show(this);
    }
    function getUserInfo3_callback(result,xml)
    {  
        if(result.response_code==0)
        {
            var child_info=result.child_info;         
            var nowtime= child_info[0].create_time;
            nowtime = nowtime.getFullYear() + "-" + (nowtime.getMonth()+1) + "-" + nowtime.getDate() + " " + nowtime.getHours() + ":" + nowtime.getMinutes() + ":" +nowtime.getSeconds();
            getLoginName=child_info[0].child_name;
            Ext.get('child_name4').dom.value=child_info[0].child_name;     
            Ext.get('child_phone4').dom.value=child_info[0].child_phone;     
            Ext.get('child_id4').dom.value=child_info[0].child_id;  
        }
        else
        {
            getLoginName="";
            
            Ext.get('child_name4').dom.value="";     
            Ext.get('child_phone4').dom.value="";     
            Ext.get('child_id4').dom.value=""; 
        }
    }
    function getPhraseById_callback (result,xml)
    {   
        if(result.response_code==0)
        {
            if(result.common_phrases==null)
                Ext.get('content').dom.value="";
            else
                Ext.get('content').dom.value=result.common_phrases;
                
        }else
            Ext.get('content').dom.value="";
    }
    
    function andChildContent()
    {
        if( Ext.get('child_phone4').dom.value!="")
        {
            if(Ext.get('content').dom.value!='')
            {
                var str= "短语:" + Ext.get('content').dom.value;
                command_(Ext.get('child_phone4').dom.value,str,login_key,3,command_callback)
            }else
                Ext.MessageBox.alert('系统提示','请输入短语！');
        }else
            Ext.MessageBox.alert('系统提示','请先选择正确的小孩名称！');
    }
    //---常用短语---end---
    
    
    //----隐身指令---begin
    RadioBoxField = new Ext.form.RadioGroup({ 
        id:'InputRadio', 
        fieldLabel: '隐身', 
        columns: 1, 
        vertical: true, 
        items: [ 
        {boxLabel: '开', name: 'rdd', id:'kai',inputValue: 1,checked: true}, 
        {boxLabel: '关', name: 'rdd', id:'guan',inputValue: 2}
        ] 
        });
    function yinshengClick()
    {
        if(Ext.get('comboName').dom.value=='请选择孩子...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value ==''&&comboCar.getValue()=='' )
        {Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        
        if(!winYinshing){
            winYinshing = new Ext.Window({            
			    title: '隐身设置',
                layout:'fit',
                width:270,
                height:160,
                closeAction:'hide',
                plain: true,
                
                items: new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding:5px',
					width: 150,
					
					defaults: {width: 130},
				//	defaultType: 'textfield',
			       
					items: [
					   RadioBoxField
					],
					
					buttons: [{
						text: '确定',
						handler:saveYinsheng
						
					},{
						text: '关闭',
						handler:function(){
                        winYinshing.hide();
                    }
					}]
				})
            });
        }
        winYinshing.show(this);
    }
    function saveYinsheng()
    {
        var str="";
        // alert(Ext.get())
        if(Ext.get('kai').dom.checked)
            str="隐身:开";
         else
            str="隐身:关";
       
        
        Ext.MessageBox.confirm('系统提示', "您确定要对["+ Ext.get('comboName').dom.value +"]手机进行设置吗?",function(button,text)
            {
                if(button=='yes')
                {
                    command_(Ext.get('comboName').dom.value,str,login_key,4,command_callback);
                     winYinshing.hide();
                }
            });
    }
 //----隐身指令---end

    
    function guanjiClick()
    {
        if(Ext.get('comboName').dom.value=='请选择小孩...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value !=''&&comboCar.getValue()!='' )
        {
            Ext.MessageBox.confirm('系统提示', "您确定设置["+ Ext.get('comboName').dom.value +"]关机吗?",function(button,text)
            {
                if(button=='yes')
                {   
                    var str='关机:';
                    command_(Ext.get('comboName').dom.value,str,login_key,7,command_callback);
                }
            });
        }else
            Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');
    }
    //分析区域
    function analysisAreaClick()
    {
         if(Ext.get('comboName').dom.value=='请选择小孩...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value ==''&&comboCar.getValue()=='' )
        {Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        
        
    
        Ext.exampledata.quyu2 = [ 
            [['1'],['1']],
            [['2'],['2']],
            [['3'],['3']],
			[['4'],['4']],
            [['5'],['5']],
            [['6'],['6']],
			[['7'],['7']],
            [['8'],['8']],
            [['9'],['9']],
			[['10'],['10']],
			[['11'],['11']],
			[['12'],['12']],
			[['13'],['13']],
			[['14'],['14']],
			[['15'],['15']],
			[['16'],['16']],
			[['17'],['17']],
			[['18'],['18']],
			[['19'],['19']],
			[['20'],['20']]
			
        ];
    var store_duanyu2 = new Ext.data.SimpleStore({
        fields: ['bianhaoID','bianhao'],
        data : Ext.exampledata.quyu2 
    });
    
    var combobox_quyu22 = new Ext.form.ComboBox({
        store: store_duanyu2,        
        fieldLabel: '区域',
        displayField:'bianhao',
        valueField:'bianhaoID',
        editable: false,//不允许输入
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
      //  emptyText:'请选择编号...',
        selectOnFocus:true,
        width:82,
         listeners:{
            select:function(combo, record,index){
                    //alert(this.getValue());
                 //
                }
        }
    });
    
     if(!winChildAnalysisArea){
            winChildAnalysisArea = new Ext.Window({            
			    title: '分析区域',
                layout:'fit',
                width:270,
                height:160,
                closeAction:'hide',
                plain: true,
                
                items: new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding:5px',
					width: 150,
					
					defaults: {width: 130},
					//defaultType: 'textfield',
			
					items: [combobox_quyu22
					],
					
					buttons: [{
						text: '分析',
						handler:analysisArea
						
					},{
						text: '关闭',
						handler:function(){
                        winChildAnalysisArea.hide();
                    }
					}]
				})
            });
        }
        winChildAnalysisArea.show(this);
    }
    function analysisArea()
    {
        Ext.MessageBox.alert("系统提示",'此功能稍候开放！');
//         Ext.MessageBox.confirm('系统提示', "您确定分析["+ Ext.get('comboName').dom.value +"]区域"+combobox_quyu22.getValue()+"吗?",function(button,text)
//            {
//                if(button=='yes')
//                {   
//                    var str='分析:'+combobox_quyu22.getValue();
//                    command_(comboCar.getValue(),str,login_key,command_callback);
//                }
//            });
    }
    
    function command_callback(result,xml)
    {
        if (result.response_code==0)
        {
             Ext.MessageBox.alert('系统提示','已成功下发指令！');
//             if(result.common_id==1)
//             {
//                add_q6_request(comboCar.getValue(),Ext.get('comboName').dom.value,1,"",0,new Date());	
//                addStatus("["+Ext.get('comboName').dom.value+"]正在查询即时位置！");
//             }
         }else
           Ext.MessageBox.alert('错误提示',result.response_result);
    }
    //查询即时位置
    function currentPositionClick()
    {
        if(Ext.get('comboName').dom.value=='请选择小孩...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value ==''&&comboCar.getValue()=='' )
        {Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        
         Ext.MessageBox.confirm('系统提示', "您确定要查询["+ Ext.get('comboName').dom.value +"]的即时位置吗?",function(button,text)
        {
            if(button=='yes')
            {   
//               for(i=0;i<q6_request_array.length;i++){
//                    if(q6_request_array[i].respserialno_ >= 0){
//                       }
//               }
             
             
                q6CommonCurrentPosition(Ext.get('comboName').dom.value,login_key,1,q6CommonCurrentPosition_callback);
            }
        });
    }
    function q6CommonCurrentPosition_callback(result,xml)
    {
      //  alert(result.response_result);
        if (result.response_code==0)
        {
            var response_no=result.response_serial_no;
            add_q6_request(comboCar.getValue(),Ext.get('comboName').dom.value,1,"",response_no,new Date());	
            addStatus("["+Ext.get('comboName').dom.value+"]正在查询即时位置！");
         }else
           Ext.MessageBox.alert('错误提示',result.response_result);
    }
    //查询最后位置
    function lastPositionClick()
    {
        if(Ext.get('comboName').dom.value=='请选择小孩...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value ==''&&comboCar.getValue()=='' )
        {Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        
         LastPositionQuery('10000',Ext.get('comboName').dom.value,login_key,LastPositionQuery_Callback);  
        
    }
    function LastPositionQuery_Callback(result,xml)
    {
    // alert(result.response_code);
       var result_flag = -1;		//默认是没有返回结果或者结果出错。
	    result_flag = parseInt(result.response_code);
        var phone_no = result.phone_no;	
        var lon,lat,current_time,precision;
    
   	    if(result_flag == 0){	
            lon = result.position_info.longitude;
            lat = result.position_info.latitude;
            current_time = result.position_info.current_time;
            
            precision=parseInt(result.position_info.precision);
           
            addGpsPosition(lon,lat,'','0000000000',Ext.get('comboName').dom.value,current_time,0,12,0);//地图上描点    ////          
            if(precision == 0)
             {   addStatus("["+Ext.get('comboName').dom.value+"]返回最后大概位置！");}
	        else 
	         {  addStatus("["+Ext.get('comboName').dom.value+"]返回最后精确位置！");}
	    }else if(result_flag==-1){
	       window.alert(error_message_timeout);	  
	    }else if(result_flag == -2){
	        addStatus("您操作的人员错误！");
	        return;	
	    }else if(result_flag==-3){
	       addStatus("["+Ext.get('comboName').dom.value+"]没有查询到最近位置！");
	      return;
	    }else if(result_flag==-4){
	       Ext.MessageBox.alert('错误提示',result.response_result);
	      return;
	    }else{
	        addStatus("连接服务器错误，请与管理员联系！")
		    return;
	    }
        
	    
    }
    
    //锁机
    function suojiClick()
    {
        if(Ext.get('comboName').dom.value=='请选择小孩...')
        { Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        if(Ext.get('comboName').dom.value ==''&&comboCar.getValue()=='' )
        {Ext.MessageBox.alert('系统提示','请输入或选择正确的小孩名称！');return;}
        
         Ext.MessageBox.confirm('系统提示', "您确定设置["+ Ext.get('comboName').dom.value +"]锁机吗?",function(button,text)
            {
                if(button=='yes')
                {   
                    var str='锁机:';
                    command_(Ext.get('comboName').dom.value,str,login_key,6,command_callback);
                }
            });
    }
    
    
     function btnEdit_LoginName()
    {
       if(!eidt_loginname_win){
            eidt_loginname_win = new Ext.Window({            
			    title: '修改登陆帐号',
                layout:'fit',
                resizable:false,	//变大小	
                modal: true,
                width:290,
                height:160,
                closeAction:'hide',
                plain: true,
                
                items: new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding:5px',
					width: 290,
					
					defaults: {width: 150},
					defaultType: 'textfield',
			
					items: [{
							fieldLabel: '旧登陆帐号',
							name: 'old_login_name',
							id: 'old_login_name',
							disabled :true					
						},{
							fieldLabel: '新登陆帐号',							
							name: 'new_login_name',
							id: 'new_login_name'						  
						}									    						
					],	
									
					buttons: [{					
					 text: '检查是否可用',					   				
					 handler:check_used_onclick
					},{
					 text: '修改',
					 handler:eidt_LoginNmae_onclick						
					},{
						text: '关闭',
						handler:function(){
                        eidt_loginname_win.hide();
                    }
					}]
				})
            });           
        }
        
        eidt_loginname_win.show(this);
        Get_Login_Name(login_key,Get_Login_Name_callback);
        
    }
    function Get_Login_Name_callback(result,xml)
    {
       if(result.response_code==0)
       {
           //alert(result.response_login_name);
            Ext.get('old_login_name').dom.value=result.response_login_name;//旧的登陆名
           // Ext.get('login_name').dom.value=result.response_login_name;   //登陆名
            Ext.get('old_login_name').disable=true;         
       }
       else if(result.response_code == -1){Ext.MessageBox.alert('系统提示',"长时间未操作超时，请重新登录！"); self.location="default.html";}
       else if(result.response_code == -2){Ext.MessageBox.alert('系统提示',"没有此用户名，请确认是否已经被删除！");}                  
       else{Ext.MessageBox.alert('系统提示',"服务器错误,请与管理员联系！");}
        
    } 
 
    function eidt_LoginNmae_onclick(item)
    {
        var old_login_name=Ext.get('old_login_name').dom.value;
        var new_login_name=Ext.get('new_login_name').dom.value;
        if(!q6check_username(new_login_name))
        {
            Ext.MessageBox.alert('系统提示',"登录帐号长度至少为6位，且仅能包含字母、数字和下划线。");
            Ext.get('new_login_name').dom.focus();
            return;
        }
      eidt_LoginNmae(login_key,old_login_name,new_login_name,eidt_LoginNmae_Callback);
    }
    function eidt_LoginNmae_Callback(result,xml)
    {
         if(result.response_code==0)
        {           
         Ext.MessageBox.alert('系统提示',result.response_result);           
        }            
        else
        {
          Ext.MessageBox.alert('系统提示',result.response_result);
          
            
        }
    
    }
    function check_used_onclick() 
    {
     var old_login_name=Ext.get('old_login_name').dom.value;
     var new_login_name=Ext.get('new_login_name').dom.value;
        if(old_login_name==new_login_name)
         {
            return;
         }
	    if(!q6check_username(new_login_name))
	    {
	     Ext.MessageBox.alert('系统提示',"登录帐号长度为6位至12位，且仅能包含字母、数字和下划线。");
           Ext.get('new_login_name').dom.focus();
            return;
	    }
	    else
	    {
	        Check_Login_Name(login_key,new_login_name,Check_Login_Name_Callback);
	    }
    }
    function Check_Login_Name_Callback(result,sml)
    {
         if(result.response_code==0)
        {           
         Ext.MessageBox.alert('系统提示',result.response_result);           
        }            
        else
        {
          Ext.MessageBox.alert('系统提示',result.response_result);         
            
        }
    }

   function q6check_username(str)
   {	
	    var i,ch,iLen;
	    iLen = str.length;
	    if(iLen < 6 || iLen > 12) return false;
	    
	    if(str == "")return false;
	    for(i = 0;i < str.length; i++){
		    ch = str.charAt(i);
		    if(!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <='9') || ch == '_')) return false;
	    }
	    return true;
    }
    
    //修改密码  
    function btnEdit_UserPassWord()
    {
       if(!eidt_userpass_win){
            eidt_userpass_win = new Ext.Window({            
			    title: '修改密码',
			    resizable:false,	//变大小	
                modal: true,
                layout:'fit',
                width:290,
                height:220,
                closeAction:'hide',
                plain: true,
                
                items: new Ext.FormPanel({
					labelWidth: 75, // label settings here cascade unless overridden				 
					frame:true,
					bodyStyle:'padding:5px',
					width: 290,
					
					defaults: {width: 150},
					defaultType: 'textfield',
			
					items: [{
							fieldLabel: '用户帐号',
							name: 'login_name',
							id: 'login_name',
							disabled :true					
						},{
							fieldLabel: '旧密码',
							inputType:'password',							
							name: 'old_password',
							id: 'old_password'						  
						},{
							fieldLabel: '新密码',
							inputType:'password',							
							name: 'new_password',
							id: 'new_password'						  
						},{
							fieldLabel: '确认密码',	
							inputType:'password',						
							name: 'ture_password',
							id: 'ture_password'						  
						}											    						
					],	
									
					buttons: [{
					 text: '修改',
					 handler:eidt_userpassword_onclick						
					},{
						text: '关闭',
						handler:function(){
                        eidt_userpass_win.hide();
                    }
					}]
				})
            });           
        }
        
        eidt_userpass_win.show(this);
        Get_Login_Name(login_key,Get_Login_Name_callback1);
        
    }
    function Get_Login_Name_callback1(result,xml)
    {
      
       if(result.response_code==0)
       {
            Ext.get('login_name').dom.value=result.response_login_name;   //登陆名
                
       }
       else if(result.response_code == -1){Ext.MessageBox.alert('系统提示',"长时间未操作超时，请重新登录！"); self.location="default.html";}
       else if(result.response_code == -2){Ext.MessageBox.alert('系统提示',"没有此用户名，请确认是否已经被删除！");}                  
       else{Ext.MessageBox.alert('系统提示',"服务器错误,请与管理员联系！");}
        
    } 
    function eidt_userpassword_onclick(item)
    {
        var old_password=Ext.get('old_password').dom.value;
        var new_password=Ext.get('new_password').dom.value;
        var ture_password=Ext.get('ture_password').dom.value;
        //修改用户密码

	    if (old_password=="" || new_password == "" || ture_password=="")
	    {
	       Ext.MessageBox.alert('系统提示',"密码不能填空！")	      
	       return;
	    }        
	    if(!(new_password == ture_password))
	    {
	       Ext.MessageBox.alert('系统提示',"新密码与确认密码不一致！")	      
	       return;
	    }

      eidt_userpassword(login_key,old_password,new_password,eidt_userpassword_Callback);
    }
    function eidt_userpassword_Callback(result,xml)
    {
         if(result.response_code==0)
        {           
            Ext.MessageBox.alert('系统提示',result.response_result);           
            Ext.get('old_password').dom.value='';
            Ext.get('new_password').dom.value='';
            Ext.get('ture_password').dom.value='';
        }            
        else
        {
          Ext.MessageBox.alert('系统提示',result.response_result);
         
        }
    
    }
    
    
    ////---------q6 END ------
    
    
    
    
    
    function onItemClick(item){}
     
    var tb = new Ext.Toolbar();
    tb.render('toolbar');
    tb.addField(comboCar);
    tb.add(
         '-',
        {
          text: '查询孩子即时位置',              
          handler:currentPositionClick,
           pressed: true
         //   iconCls: 'blist'
        }, '-',
       {
            text: '手机管理',
            iconCls: 'blist',
            menu:menuCar
        },{
            text: '系统管理',
            iconCls: 'blist',
            menu:menuSystem
        }, 
                
        //'-',
//        {
//            text: '帮助',
//            //iconCls: 'blist',
//            pressed: true,
//            handler:systemHelpClick
//        },
        '-',       
        
//        {
//            text: '说  明',
//            enableToggle: true,
//            toggleHandler: shuoming,
//            pressed: true
//        },
        '->',
        {
            text: '退   出',
            enableToggle: true,
            toggleHandler: _logout_click,
            pressed: true
        }
    ) 
    function shuoming()
    {
        Ext.MessageBox.alert('系统提示','本系统依靠GSM基站对跟踪手机进行定位，误差为200~500米，郊区更远，该位置仅供参考，带GPS功能的手机，定位误差在50米左右！');
    }
    
    function systemHelpClick()
    {
        
    }
    
   
    function first_load(){

    }
   
    
    function check_num(str){ //判断是否数字
	var i,ch;
	if(str != ""){	
		for(i = 0;i < str.length; i++){
			ch = str.charAt(i);
			if(!(ch >= '0' && ch <='9')) return false;
		}
		return true;
	}
	else return true;
}
    function check_phone(str){ //判断通讯号码的合法性
	    var i,ch;
	    if(str != ""){	
		    if(str.length != 11) return false;
		    for(i = 0;i < str.length; i++){
			    ch = str.charAt(i);
			    if(!(ch >= '0' && ch <='9')) return false;
		    }
		    return true;
	    }
	    else return true;
    }

    function checkInputValide(str){    //判断输入的内容
	    var i,ch,iLen;
	    iLen = str.length;
	    if(iLen > 300){
		    Ext.MessageBox.alert('系统提示',"您输入的内容太长了，请重新输入！");
		    return false;
	    }
	    if(str != ""){
		    for(i = 0;i < str.length; i++){
			    ch = str.charAt(i);
			    if((ch == 34) || (ch == 39) || (ch == '\\')){
				    Ext.MessageBox.alert('系统提示',"您输入的内容请不要包含英文的[']或[\"]或[\\]标点符号！");
				    return false;
			    }
			    if((ch == '\r' ) || (ch == '\n')){
				    Ext.MessageBox.alert('系统提示',"您输入的内容请不要包含回车符和换行符！");
				    return false;
			    }
		    }
		    return true;
	    }else{
		    return true;
	    }	
    }
    
   
    //修改终端通讯号码-----end
    function check_telephone(str){ //判断通讯号码的合法性
	    var i,ch;
	    if(str != ""){	
		    if(str.length != 11) return false;
		    for(i = 0;i < str.length; i++){
			    ch = str.charAt(i);
			    if(!(ch >= '0' && ch <='9')) return false;
		    }return true;
	    }else return false;
    }
    
//    var time1=new Ext.form.TimeField({
//                        fieldLabel: 'Time',
//                        name: 'time1',
//                        minValue: '8:00am',
//                        maxValue: '6:00pm'
//                    });
//    var time2=new Ext.form.TimeField({
//                        fieldLabel: 'Time',
//                        name: 'time2',
//                        minValue: '8:00am',
//                        maxValue: '6:00pm'
//                    })   ;  
//                    
//                    
//                               
// //行车纪录---begin
// 
//  Ext.apply(Ext.form.VTypes, {
//    daterange : function(val, field) {
//        var date = field.parseDate(val);

//        if(!date){
//            return;
//        }
//        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
//            var start = Ext.getCmp(field.startDateField);
//            start.setMaxValue(date);
//            start.validate();
//            this.dateRangeMax = date;
//        } 
//        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
//            var end = Ext.getCmp(field.endDateField);
//            end.setMinValue(date);
//            end.validate();
//            this.dateRangeMin = date;
//        }
//        /*
//         * Always return true since we're only using this vtype to set the
//         * min/max allowed values (these are tested for after the vtype test)
//         */
//        return true;
//    }
// });
// 
// 
// function query_TrackInfo()
// {
//   // alert(Ext.get("startdt").dom.value);
//    //        var ret_value=null;
//	//    if(ret_value == null) return;
//	//    var timeSet = ret_value.split(',');
//    Get_Track_Info(comboCar.getValue(),Ext.get("startdt").dom.value,Ext.get("enddt").dom.value,login_key,Get_Track_Info_Callback);    
// }
// //获取轨迹记录返回值，描绘在地图上
//    function Get_Track_Info_Callback(result,responseXml){    
//        var result_flag = 1;		//默认是没有返回结果或者结果出错。
//        result_flag = parseInt(result.response_code);
//        var xmlDoc = loadXML(responseXml);
//        var xmlResult = "CommonTrackQueryResult/";
//        var carno = result.car_no;
//        var car_position_info_list = new Array();
//        var i;  
//       
//	    if(result_flag == 0){	
//	        
//	        xPath = xmlResult + "position_info/carto_web_position_info";
//		    var position_info_l = getNodeElements(xmlDoc,xPath);				
//		    for(var i=0;i<position_info_l.length;i++){			    
//		        var lon = position_info_l[i].childNodes[0].childNodes[0].nodeValue;					
//		        var lat = position_info_l[i].childNodes[1].childNodes[0].nodeValue;
//		        var speed = position_info_l[i].childNodes[2].childNodes[0].nodeValue;
//		        var nowtime = position_info_l[i].childNodes[3].childNodes[0].nodeValue;
//		        var stars = position_info_l[i].childNodes[4].childNodes[0].nodeValue;
//		        var directions = position_info_l[i].childNodes[5].childNodes[0].nodeValue;
//		        var current_status = position_info_l[i].childNodes[6].childNodes[0].nodeValue;	
//		        car_position_info_list[i]=new position_info(lon,lat,speed,nowtime,stars,directions,current_status);
//		    }	
//		    if(car_position_info_list.length>0)	
//		    {
//		        winGetTrack.hide(); 
//		        addStatus("["+carno+"]查询到"+car_position_info_list.length+"个位置信息！");
//		        for(i=car_position_info_list.length-1;i>0;i--){
//		            if(parseInt(car_position_info_list[i].stars,10) > 3 && parseFloat(car_position_info_list[i].speed) < 180)
//		              //  alert(car_position_info_list[i].longitude);
//		              //  btnAddCarPositionToMap(carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].speed,car_position_info_list[i].directions,car_position_info_list[i].current_time,car_position_info_list[i].current_status,"false",1);
//		               addGpsPosition(car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].directions,car_position_info_list[i].current_status,carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].current_time,car_position_info_list[i].speed,12,1);//地图上描点
//    		          
//                }
//                i=0;
//               // btnAddCarPositionToMap(carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].speed,car_position_info_list[i].directions,car_position_info_list[i].current_time,car_position_info_list[i].current_status,12,1);
//               addGpsPosition(car_position_info_list[i].longitude,car_position_info_list[i].latitude,car_position_info_list[i].directions,car_position_info_list[i].current_status,carno + ' 第[' + (i+1) + "]个",car_position_info_list[i].current_time,car_position_info_list[i].speed,12,1);//地图上描点
//               showTrackInMap();
//            }
//	    }else if(result_flag == -1){
//	        Ext.MessageBox.alert('错误提示',error_message_timeout);
//	       winGetTrack.hide();    
//	    }else if(result_flag == -2){
//	         Ext.MessageBox.alert('错误提示','数据库错误,请与客户服务中心联系！');
//	          winGetTrack.hide();     
//	    }else if(result_flag == -3){
//	    　    Ext.MessageBox.alert('错误提示',"您选择的时间段有错，开始时间不能大于结束时间！");	 	    
//	    }else if(result_flag == -4){
//	        Ext.MessageBox.alert('错误提示',"查行踪只能按月查询！");	
//	    }else if(result_flag == -5){
//	         Ext.MessageBox.alert('错误提示',"["+carno+"]没有查询到行车记录！");
//	    }else{
//	        Ext.MessageBox.alert('错误提示',error_message_web_server);
//	        winGetTrack.hide();    
//	    }
//    }
////行车纪录-----end
 //查询轨迹
 function queryTrackOnClick()
 {
  //  setMsg('asdfsdaf');
 }
 function CheckOptionCars(functionid){
    if(comboCar.getValue()==""){             //没有该车辆
        Ext.MessageBox.alert('系统提示',error_noCar);
        return false;
    }else if(check_request_is_busy(comboCar.getValue(),functionid)){         //判断该车辆是否正在进行该操作
        if(functionid == 1)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在查询即时位置，请在当前操作中先取消上次查询操作！");
        else if(functionid == 2)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置上发条件，请在当前操作中先取消上次设置操作！");
        else if(functionid == 3)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在恢复出厂设置，请在当前操作中先取消上次设置操作！");
        else if(functionid == 4)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置城区监护，请在当前操作中先取消上次设置操作！");
        else if(functionid == 5)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安，请在当前操作中先取消上次设置操作！");
        else if(functionid == 6)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置停车监护，请在当前操作中先取消上次设置操作！");
        else if(functionid == 7)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置自动应答，请在当前操作中先取消上次设置操作！");
        else if(functionid == 8)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置拨出号码，请在当前操作中先取消上次设置操作！");
        else if(functionid == 9)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域一，请在当前操作中先取消上次设置操作！");
        else if(functionid == 10)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域二，请在当前操作中先取消上次设置操作！");
        else if(functionid == 11)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域三，请在当前操作中先取消上次设置操作！");
        else if(functionid == 12)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域四，请在当前操作中先取消上次设置操作！");
        else if(functionid == 13)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域五，请在当前操作中先取消上次设置操作！");
        else if(functionid == 14)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域六，请在当前操作中先取消上次设置操作！");
        else if(functionid == 15)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域七，请在当前操作中先取消上次设置操作！");
        else if(functionid == 16)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域八，请在当前操作中先取消上次设置操作！");
        else if(functionid == 17)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域九，请在当前操作中先取消上次设置操作！");
        else if(functionid == 18)
            Ext.MessageBox.alert('系统提示',"[" + comboCar.getValue() + "]正在设置长途报平安区域十，请在当前操作中先取消上次设置操作！");
        return false;
    }
    return true;
}
//检查该车辆的此功能是否正在执行，如果正在执行，提示用户
function check_request_is_busy(carno,functionid){
    for(i=0;i<request_array.length;i++){
        if(request_array[i].carno_ == carno && request_array[i].functionid_ == functionid){
           return true;
        }
    }
    return false;
}
//当前操作
function _systemStateOnClick()
{
 //  alert(request_array.length);
   if(!winSystemState)
   {
        
        winSystemState = new Ext.Window({
            title: '当前操作',
            resizable:false,	//变大小
            closeAction:'hide',           
            width: 365,
            height:213,
            modal:true,
            layout: 'fit',
            bodyStyle:'padding:5px;',          
            html:'<SELECT id=selectSystemState name=selectSystemState style="WIDTH: 340px; HEIGHT: 146px" size=7 multiple>	<option selected ></option></SELECT>',
            buttonAlign:'center',
            buttons: [{
                    text:'撤销操作',
                    disabled:false,
                    handler:cancel_onClick
                },{
                    text: '关闭',
                    handler: function(){
                        winSystemState.hide();
                    }
                }]
        });
   }
   winSystemState.show(this);
   var selLen=document.getElementById("selectSystemState").options.length;     //先删除option
   while(selLen!=0)
   {
      for(i=0;i<selLen;i++) 
      { 
         document.getElementById('selectSystemState').options.remove(i); 
          selLen = selLen/2;
      } 
   }    
    for(i=0;i<request_array.length;i++)
    {
        var Element = document.createElement("OPTION");
        if(request_array[i].functionid_==1)
        {
            Element.text ="<"+request_array[i].carno_+">正在查即时的位置！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            //selectSystemState.add(Element,request_array[i].reqserialno_);
            selectSystemState.selectedIndex = i;
            
        }
        else if(request_array[i].functionid_==2)
        {
            Element.text ="<"+request_array[i].carno_+">正在修改上发条件！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }
        else if(request_array[i].functionid_==3)
        {
            Element.text ="<"+request_array[i].carno_+">正在恢复出厂设置！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==4)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置城区监护！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==5)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==6)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置停车监护！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==7)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置自动应答！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==8)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置拨出号码！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==9)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域一！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==10)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域二！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==11)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域三！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==12)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域四！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==13)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域五！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==14)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域六！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==15)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域七！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==16)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域八！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==17)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域九！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }else if(request_array[i].functionid_==18)
        {
            Element.text ="<"+request_array[i].carno_+">正在设置长途报平安区域十！"; 
            Element.value=request_array[i].reqserialno_;
            selectSystemState.add(Element);
            selectSystemState.selectedIndex = i;
        }
        else
        {
            Element.text ="有错误发生！"; 
            selectSystemState.add(Element,0);
            selectSystemState.selectedIndex = 0;
        }
     }
}
  //取消操作
    function cancel_onClick()
    {
        if(selectSystemState.selectedIndex > -1){
        var sRetValue=selectSystemState.value;
        var carno = get_carno_by_request_serial_no(sRetValue);
	    var functionid = get_functionid_by_request_serial_no(sRetValue);
	    var response_serial_no = get_response_serial_no_by_request_serial_no(sRetValue);
	    remove_request_by_request_serialno(sRetValue);
	    
	    Delete_User_Request(response_serial_no);
	    if(carno != "" && functionid != ""){
		    functionid = parseInt(functionid);
		    if(functionid == 1)
	                addStatus("[" + carno + "]撤销了查询即时位置！");
	            else if(functionid == 2)
	                addStatus("[" + carno + "]撤销了设置上发条件！");
	            else if(functionid == 3)
	                addStatus("[" + carno + "]撤销了设置出厂设置！");
	            else if(functionid == 4)
	                addStatus("[" + carno + "]撤销了设置城区监护！");
	            else if(functionid == 5)
	                addStatus("[" + carno + "]撤销了设置长途报平安！");
	            else if(functionid == 6)
	                addStatus("[" + carno + "]撤销了设置停车监护！");
	            else if(functionid == 7)
	                addStatus("[" + carno + "]撤销了设置自动应答！");
	            else if(functionid == 8)
	                addStatus("[" + carno + "]撤销了设置呼出号码！");
	            else if(functionid == 9)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域一！");
	            else if(functionid == 10)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域二！");
	            else if(functionid == 11)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域三！");
	            else if(functionid == 12)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域四！");
	            else if(functionid == 13)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域五！");
	            else if(functionid == 14)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域六！");
	            else if(functionid == 15)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域七！");
	            else if(functionid == 16)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域八！");
	            else if(functionid == 17)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域九！");
	            else if(functionid == 18)
	                addStatus("[" + carno + "]撤销了设置长途报平安区域十！");
	        }
	        selectSystemState.options.remove(selectSystemState.selectedIndex);
        }
    }

function Delete_User_Request(serial_no){
     var parameters = new SOAPClientParameters();
     parameters.add("login_key",login_key);
     parameters.add("serial_no",serial_no);
//     parameters.add("random",Math.random());
     acxs_common_function('DeleteUserRequest',parameters,true,delete_user_request_callback);
}
function delete_user_request_callback(call,responseXml){}
 //取最后位置
function btnGetLasterPos_onclick(){
   
}


//取最后位置回调函数
function Last_Position_Query_Callback(result,xml){
   
}
//查询实时位置
function btnCurrentPos_onclick(){	
    
}
//查询实时位置回调函数
function Current_Position_Query_callback(result,responseXml){
   
}
//取短信返回结果回调
function get_return_result_callback(result,responseXml){   
    response_analysis(result.response_serial_no,result.response_code,result.response_result);
}


function setToolbarTip()
{
   
}
 function _onClick()
 {}
 function _logout()
 {
    self.location.href = "default.html";
 }
 function getCarList()
 {
   //  comboCar.store.reload({params:{loginKey:login_key}});  
 }
 
 
 //----tang begin----------
   //-----------
    // 车辆管理
     //----
     //添加车辆
  
    function btnAddCar_onclick()
    {
       
    } 
     
   function addCar_onclick(item)
    {
       
    }  

function check_telephone(str)  //判断通讯号码的合法性
{ 
	var i,ch;
	if(str != "")
	{	
		if(str.length != 11) return false;
		for(i = 0;i < str.length; i++)
		{
			ch = str.charAt(i);
			if(!(ch >= '0' && ch <='9')) return false;
		}return true;
	}else return false;
}
function check_SerialNo(str) //判断移动终端序列号的合法性
{
	var i,ch;
	if(str != "")
	{	
		if(str.length != 14) return false;
		for(i = 0;i < str.length; i++){
			ch = str.charAt(i);
			if(!(ch >= '0' && ch <='9')) return false;
		}return true;
	}else return false;
}


 function CarInfoAdd_callback(result,xml)
 {    }
 //修改用户信息
 
    
 function User_Info_Query_Callback(result,xml)
 {
	var result_flag = -100;		//默认是没有返回结果或者结果出错。
	var xmlDoc = loadXML(xml);
	var xmlResult = "UserInfoQueryResult/";
	var xPath = xmlResult + "response_code";
	result_flag = parseInt(getNodeValue(xmlDoc,xPath));
   	if(result_flag==0)
   	{
		xPath = xmlResult + "user_info/user_name";
		var username = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/user_phone";
		var userphone = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/link_phone";
		var linkp_hone = getNodeValue(xmlDoc,xPath);	
		xPath = xmlResult + "user_info/link_phone2";
		var link_phone2 = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/email";
		var email_ = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/address";
		var address = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/owner_phone";
		var owner_phone = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/password_type";
		var passwordtype = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/web_title";
		var webtitle = getNodeValue(xmlDoc,xPath);
		xPath = xmlResult + "user_info/cc_service_type";
		var cc_service_type_ = getNodeValue(xmlDoc,xPath);
		Ext.get('user_name').dom.value = username;
		Ext.get('phone').dom.value = linkp_hone;
		Ext.get('phone2').dom.value = link_phone2;
		Ext.get('UserAddress').dom.value = address;
		Ext.get('mytitle').dom.value = webtitle;
		Ext.get('car_phone').dom.value = owner_phone;
		Ext.get('email').dom.value = email_;

		if(passwordtype==0)
		{
			Ext.get('radio_password').dom.checked=true;
		}
		else
		{
			Ext.get('Rond_password').dom.checked=true;
		}
		//取报警联系人及电话		
		xPath = xmlResult + "user_info/alarm_linker/alarm_linker_info";
		var alarm_linker = getNodeElements(xmlDoc,xPath);
		if(alarm_linker != null && alarm_linker.length > 0)
		{
		    if(alarm_linker[0].childNodes[0].childNodes[0] != null)
		    {
		        Ext.get('flinker').dom.value = alarm_linker[0].childNodes[0].childNodes[0].nodeValue;
			    Ext.get('flinkphone').dom.value = alarm_linker[0].childNodes[1].childNodes[0].nodeValue;
			}
		    if(alarm_linker[1].childNodes[0].childNodes[0] != null)
		    {
		        Ext.get('slinker').dom.value = alarm_linker[1].childNodes[0].childNodes[0].nodeValue;
			    Ext.get('slinkphone').dom.value = alarm_linker[1].childNodes[1].childNodes[0].nodeValue;
			}
		}
		
		//取报警开始时、分到结束时、分		
		xPath = xmlResult + "user_info/service_time/cc_service_time";
		var service_time = getNodeElements(xmlDoc,xPath);	 
		if(service_time != null)
		{
            var beginTime = service_time[0].childNodes[0].childNodes[0].nodeValue;
            if(beginTime == "" || beginTime == 0)
            {
               combo_hours.setValue(0);
               combo_minutes.setValue(1);              
            }
            else
            {
               combo_hours.setValue(parseInt(beginTime/60));
               combo_minutes.setValue(beginTime % 60);
                
            }
            var endTime = service_time[0].childNodes[1].childNodes[0].nodeValue;            
            if(endTime==""|| endTime==0)
            {
               combo_hours2.setValue(23);
             
            }
            else
            {              
               combo_hours2.setValue(parseInt(endTime/60));
               combo_minutes2.setValue(endTime % 60);               
            }			
        }
	}
	   else if(result_flag == -1){Ext.MessageBox.alert('系统提示',"长时间未操作超时，请重新登录！"); self.location="default.html";}
       else if(result_flag == -2){Ext.MessageBox.alert('系统提示',"没有此用户名，请确认是否已经被删除！");}                  
       else{Ext.MessageBox.alert('系统提示',"服务器错误,请与管理员联系！");}
}
 
 

//   function check_username(str)
//   {	
//	    var i,ch,iLen;
//	    iLen = str.length;
//	    if(iLen < 6 || iLen > 15) return false;
//	    if(str == "")return false;
//	    for(i = 0;i < str.length; i++){
//		    ch = str.charAt(i);
//		    if(!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <='9') || ch == '_')) return false;
//	    }
//	    return true;
//    }

    
 function check_telephone(str)//判断通讯号码的合法性
 { 
	var i,ch;
	if(str == "") return true;
	if(str.length != 11) return false;
	for(i = 0;i < str.length; i++)
	{
		ch = str.charAt(i);
		if(!(ch >= '0' && ch <='9')) return false;
	}
	str = str.substring(0,3);
    return true;
}
 
 //退出登录
 function  _logout_click()
 {
     Ext.MessageBox.confirm('系统提示', '你确定要退出系统吗?',function(btn)
            {   
                if(btn=='yes')
                {
                    cookieFunction.DelCookie("q6_login_key");
                 //   window.location.href="index.htm";
                 window.opener = 'xxx';
                     window.close();
                }
            }
      );
 }
 
 //----tang end----
     
});
 function addStatus(strStatus){		//添加状态
  //  alert("1");
	var lengthstring = select1.length;
	if(lengthstring >= 100){
		for(i=0;i<10;i++){
			select1.remove(select1.length-1);
		}
	}
	var Element = document.createElement("OPTION");
	Element.text = strStatus;
	select1.add(Element,0);
	select1.selectedIndex = 0;
	//alert("10");
}

//查询实时位置回调函数
function Show_Current_Position_To_Map_Callback(reuslt,responseXml){

   var result_flag = -1;		//默认是没有返回结果或者结果出错。
	var xmlDoc = loadXML(responseXml);
	var xmlResult = "CommonLastPositionQueryResult/";
	var xPath = xmlResult + "response_code";
	result_flag = parseInt(getNodeValue(xmlDoc,xPath));
    xPath = xmlResult + "car_no";
    var carno = getNodeValue(xmlDoc,xPath);	
   
   	if(result_flag == 0){	
	    xPath = xmlResult + "position_info/longitude";
	    var lon=getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "position_info/latitude";
	    var lat=getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "position_info/speed";
	    var speed=getNodeValue(xmlDoc,xPath);
	    
	    xPath = xmlResult + "position_info/current_time";
	    var current_time=getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "position_info/stars";
	    var stars=getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "position_info/directions";
	    var directions=getNodeValue(xmlDoc,xPath);
	    xPath = xmlResult + "position_info/current_status";
	    var current_status=getNodeValue(xmlDoc,xPath);	   
	   
	   
	  //  alert(lon+","+lat+","+speed+","+current_time+","+stars+","+directions+","+current_status);
	     addGpsPosition(lon,lat,directions,current_status,carno,current_time,speed,12,2);//地图上描点
	   // addStatus("["+carno+"]返回即时位置！");
	}else if(result_flag==-1){
	   alert(error_message_timeout);
	   return;
	}else if(result_flag == -2){
	    addStatus("您操作的车牌号码错误！");
	    return;	
	}else if(result_flag==-3){
	   addStatus("["+carno+"]没有查询到有效位置！");
	  return;
	}else{
	    addStatus("连接服务器错误，请与管理员联系！")
		return;
	}		
}

 

 
 function check_number(str){
	var i,ch;
	if(str != ""){
		for(i = 0;i < str.length; i++){
			ch = str.charAt(i);
			if(!(ch >= '0' && ch <='9')) return false;
		}return true;
	}else return false;
}

