 
 //VPN Setting

 function advancemenu(deviceId)
 {
   var actURL="tr069servlet?layout=pageLayout&action=HomeViewAction&id="+deviceId+"&div=loadstatus";
  isc.Window.create({
        title:"Advance"+deviceId,
        align:"center",
        isModal: true,
        autoDraw: true,
        animateMinimize: true,
        autoCenter:true,
        width:825,
        height:250,
        autoDraw:true,
        showBody:true,
        ID:"Advance"+deviceId,
        src:actURL
      });

 }


 function makeRequest_vpn(url,polyline) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { alertContents_vpn(http_request,polyline); };
        http_request.send(null);
    };

    function alertContents_vpn(http_request,polyline) {
      if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          document.getElementById("processing").style.visibility="hidden";
          var xmldoc = http_request.responseXML;
          var roots = xmldoc.getElementsByTagName("root");
          var e = roots[0];
          var id = e.getElementsByTagName("id")[0].firstChild.data;
          var type = e.getElementsByTagName("type")[0].firstChild.data;

          var content = e.getElementsByTagName("content")[0].firstChild.data;
          if(type=="connection"){
          	
          	var clientid = e.getElementsByTagName("clientid")[0].firstChild.data;
            var serverid = e.getElementsByTagName("serverid")[0].firstChild.data;
         
					  clearmyvpnstatus(clientid);
            clearmyvpnstatus(serverid);
            setTimeout(function () { govpnstatus(clientid,"NoInfo");}, 2000);
            setTimeout(function () { govpnstatus(serverid,"NoInfo");}, 10000);  
            if(content=="0" || content=="1"){
            	
              /*map.addOverlay(polyline);*/
              alert("VPN Connection Success.");
              server=null;
              client=null;
              
            }else{
              alert("VPN Connection Fail:\n"+content);
            }
            
            
          }else if(type=="disconnection" ||type=="disconnection_pptp" ||  type=="dropvpn"){
            if(content=="0" || content=="1"){
             
              if(polyline!=null){
                map.removeOverlay(polyline);
              }
              
              alert("VPN Disconnection Success.");
            }else{
              alert("VPN Disconnection Fail:\n"+content);
            }
            var clientid = e.getElementsByTagName("clientid")[0].firstChild.data;
            var serverid = e.getElementsByTagName("serverid")[0].firstChild.data;
            clearmyvpnstatus(clientid);
            clearmyvpnstatus(serverid);
            govpnstatus(clientid,"NoInfo");
            govpnstatus(serverid,"NoInfo");
            
          }else if(type=="getlanip"){
            DynamicForm0.setValue("LanIp",content);
            Window0.show();
          }else if(type=="changelanip"){
            if(content=="0" || content=="1"){
              alert("Change Lan IP Success.");
            }else{
              alert("Change Lan IP Fail:\n"+content);
            }
          }else{
            alert(content);
          }
        } else {
          document.getElementById("processing").style.visibility="hidden";
          alert('There was a problem with the request.');
        }
      }
    };

    //status ajax
    function makeNetworkInfoAndGoDeviceRequest(url,netid,deviceid) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { setmarkerAndGoDevice(http_request,netid,deviceid); };
        http_request.send(null);
    };

    function setmarkerAndGoDevice(http_request,netid,deviceId) {
      if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var xmldoc = http_request.responseXML;
          var devices = xmldoc.getElementsByTagName("devices")[0];
          if(devices==null)
          return;
          var len=devices.childNodes.length;
          var childnode;
          for(var i=0;i<len;i++){
            childnode=devices.childNodes[i];
            var type1=getValue(childnode,'type');
            var lat1=getValue(childnode,'lat');
            var lng1=getValue(childnode,'lng');
            var title1=getValue(childnode,'title');
            var id1=getValue(childnode,'id');


            var tabs = new Array();
            if(type1=="0"){
            //markers.push({type:type1,id:i,networkid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:networkicon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0});
            var zoom1=getValue(childnode,'zoom');
            var mapType1=getValue(childnode,'maptype');
            markers.push({type:type1,id:i,networkid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:networkicon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0,zoom:zoom1,maptype:mapType1});
            }
            else if(type1=="1"){
              var SerialNumber1=getValue(childnode,'serialnumber');
              markers.push({SerialNumber:SerialNumber1,type:type1,id:i,deviceid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:officon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0});
            }
          }
          for(var i = 0; i < markers.length; i++) {
            var gmarker = createMarker(markers[i]);
            map.addOverlay(gmarker);
          }

          var start = http_request.responseText.indexOf("<pzoom>")+7;
          var end = http_request.responseText.indexOf("</pzoom>",start);
          var pzoom = http_request.responseText.substring(start,end);
          map.setZoom(parseInt(pzoom));

          var actURL="AJAXServlet?ajaxact=DeviceInfoAction&id="+deviceId;
          makeDeviceStatusRequest(actURL,gmarkers[parseInt(deviceId)]);
        } else {
          //return 'There was a problem with the request.';
        }
      }
    };
/*
    function setmarker(http_request,netid) {
      if (http_request.readyState == 4) {
        if (http_request.status == 200) {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("devices")[0];
              var childnode;
              if(devices==null)
              return;
              var len=devices.childNodes.length;
              for(var i=0;i<len;i++){
                childnode=devices.childNodes[i];
                var type1=getValue(childnode,'type');
                var lat1=getValue(childnode,'lat');
                var lng1=getValue(childnode,'lng');
                var title1=getValue(childnode,'title');
                var id1=getValue(childnode,'id');



                var tabs = new Array();
                if(type1=="0"){
                  markers.push({type:type1,id:i,networkid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:networkicon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0});
                }else if(type1=="1"){
                  var SerialNumber1=getValue(childnode,'serialnumber');
                  markers.push({SerialNumber:SerialNumber1,type:type1,id:i,deviceid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:officon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0});
                }
              }
              for(var i = 0; i < markers.length; i++) {
                var gmarker = createMarker(markers[i]);
                map.addOverlay(gmarker);
              //  if(markers[i].type=="1")
              //  wmarkers[markers[i].deviceid] = markers[i];
              }
              for(var i = 0; i < markers.length; i++) {
                if(markers[i].type=="1")
                wmarkers[markers[i].deviceid] = markers[i];
              }
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };
*/
function makeNetworkInfoRequest(url,netid) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { setmarker(http_request,netid); };
        http_request.send(null);
    };

    function setmarker(http_request,netid) {
      if (http_request.readyState == 4) {
        if (http_request.status == 200) {
          var xmldoc = http_request.responseXML;
          var devices = xmldoc.getElementsByTagName("devices")[0];
          var childnode;
          if(devices==null)
          return;
          var len=devices.childNodes.length;
          for(var i=0;i<len;i++){
            childnode=devices.childNodes[i];
            var type1=getValue(childnode,'type');
            var lat1=getValue(childnode,'lat');
            var lng1=getValue(childnode,'lng');
            var title1=getValue(childnode,'title');
            var id1=getValue(childnode,'id');



            var tabs = new Array();
            if(type1=="0"){
            var zoom1=getValue(childnode,'zoom');
            var mapType1=getValue(childnode,'maptype');
            markers.push({type:type1,id:i,networkid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:networkicon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0,zoom:zoom1,maptype:mapType1});
            }
            else{
              var SerialNumber1=getValue(childnode,'serialnumber');
              markers.push({SerialNumber:SerialNumber1,type:type1,id:i,deviceid: id1, name:"", title:title1, description:"", lat:lat1, lng:lng1, icon_uri:officon, icon_size_w:32, icon_size_h:32, icon_anchor_x:16, icon_anchor_y:32,icon_infowindow_anchor_x:16, icon_infowindow_anchor_y:0, shadow:null, shadow_size_w:0, shadow_size_h:0});
            }
          }

          for(var i = 0; i < markers.length; i++) {
            var gmarker = createMarker(markers[i]);
            map.addOverlay(gmarker);
            //  if(markers[i].type=="1")
            //  wmarkers[markers[i].deviceid] = markers[i];
          }

          for(var i = 0; i < markers.length; i++) {
            if(markers[i].type=="1")
            wmarkers[markers[i].deviceid] = markers[i];
          }

          var start = http_request.responseText.indexOf("<pzoom>")+7;
          var end = http_request.responseText.indexOf("</pzoom>",start);
          var pzoom = http_request.responseText.substring(start,end);
          map.setZoom(parseInt(pzoom));

        } else {
          //return 'There was a problem with the request.';

        }
      }

    };

    function getValue(childnode,tagName){

      return  childnode.getElementsByTagName(tagName).item(0).firstChild.nodeValue;
    };


    function makeDeviceStatusRequest(url,marker) {
        var http_request = false;
        var gmarker = marker;
        if (window.XMLHttpRequest) {
          http_request = new XMLHttpRequest();
          if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { showinfo(http_request,gmarker); };
        http_request.send(null);
    };

    function showinfo(http_request,gmarker) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var xmldoc = http_request.responseXML;
              var device = xmldoc.getElementsByTagName("device");

		var id = device[0].getElementsByTagName("id")[0].firstChild.data;
		var name = device[0].getElementsByTagName("name")[0].firstChild.data;
                var ip = device[0].getElementsByTagName("ip")[0].firstChild.data;
                var port = device[0].getElementsByTagName("port")[0].firstChild.data;
		var uri = device[0].getElementsByTagName("uri")[0].firstChild.data;
                var manufacturer = device[0].getElementsByTagName("manufacturer")[0].firstChild.data;
                var oui = device[0].getElementsByTagName("oui")[0].firstChild.data;
		var serialnumber = device[0].getElementsByTagName("serialnumber")[0].firstChild.data;
                var specversion = device[0].getElementsByTagName("specversion")[0].firstChild.data;
                var hardwareversion = device[0].getElementsByTagName("hardwareversion")[0].firstChild.data;
                var tab="<div style='width:370px;height:150px'><p align='center'><strong>"+name+"</strong><br /></p><hr /><strong>IP:"+ip+"<br />Port:"+port+"<br />Uri:"+uri+"<br />Manufacturer:"+manufacturer+"<br />Oui:"+oui+"<br />SerialNumber:"+serialnumber+"<br />Spec:"+specversion+"<br />Hardware:"+hardwareversion+"<br /></strong>";
                gmarker.openInfoWindowHtml(tab);
            } else {
              //return 'There was a problem with the request.';

            }
        }

    };

    function generalRequest(url,callbackfun,gmarker) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { callbackfun(http_request,gmarker); };
        http_request.send(null);
    };

    function statusgeneralRequest(url,callbackfun,deviceid,windowscallbackfun,dotype) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() {
         if (http_request.readyState == 4) {
            if (http_request.status == 200) {
            var data  = callbackfun(http_request,deviceid,1);
            windowscallbackfun(dotype,data);
            }
            }
        };
        http_request.send(null);
    };

    function VPNStatus_vpn(http_request,gmarker) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {

            //  gmarker.openInfoWindowHtml(http_request.responseText);
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                if(gmarker.statusType!="AllVpnConnection" && gmarker.statusType!="NoInfo"){
                  gmarker.openInfoWindowHtml("No VPN Connections");
                }
                return;
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=80% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=12%><b>VPN</b></td><td width=7%><b>Type</b></td><td width=5%><b>Remote IP</b></td><td width=5%><b>Virtual Network</b></td><td width=5%><b>Tx Pkts</b></td><td width=5%><b>Tx Rate</b></td><td width=5%><b>Rx Pkts</b></td><td width=5%><b>Rx Rate</b></td><td width=5%><b>UpTime</b></td><td></td></tr>";
              for(var i=0;i<len;i++){
                childnode=devices.childNodes[i];
                var name=getValue(childnode,'name');
                var type=getValue(childnode,'type');
                var enc=getValue(childnode,'enc');
                var auth=getValue(childnode,'auth');
                var remoteip=getValue(childnode,'remoteip');
                var vituralnetwork=getValue(childnode,'vituralnetwork');
                var txpkts=getValue(childnode,'txpkts');
                var txrate=getValue(childnode,'txrate');
                var rxpkts=getValue(childnode,'rxpkts');
                var rxrate=getValue(childnode,'rxrate');
                var uptime=getValue(childnode,'uptime');
                var peerid=getValue(childnode,'peerid');
                var button="<input type=button value='Drop' onClick=drop('"+name+"',"+gmarker.id+","+peerid+")>";
                if(type == 'PPTP')
                data = data + "<tr align=center ><td><font color=\"#00FF00\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td>"+button+"</td></tr>";
                else if (type == 'IPSec_Tunnel')
                data = data + "<tr align=center ><td><font color=\"#0000ff\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td>"+button+"</td></tr>";
                else
                data = data + "<tr align=center ><td><font color=\"#770000\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td>"+button+"</td></tr>";
                drawline_vpn(gmarker,peerid,type,name);
              }
              data = data +"</table>";
              if(gmarker.statusType!="AllVpnConnection" && gmarker.statusType!="NoInfo"){
                gmarker.openInfoWindowHtml(data);
              }
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };

    function VPNStatus(http_request,gmarker) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {

            //  gmarker.openInfoWindowHtml(http_request.responseText);
              var data = formatVPNStatus(http_request,gmarker.id,0,gmarker);
              /*
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                gmarker.openInfoWindowHtml("No VPN Connections");
                return;
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=80% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=12%><b>VPN</b></td><td width=7%><b>Type</b></td><td width=5%><b>Remote IP</b></td><td width=5%><b>Virtual Network</b></td><td width=5%><b>Tx Pkts</b></td><td width=5%><b>Tx Rate</b></td><td width=5%><b>Rx Pkts</b></td><td width=5%><b>Rx Rate</b></td><td width=5%><b>UpTime</b></td><td>&nbsp;</td></tr>";
              for(var i=0;i<len;i++){
                childnode=devices.childNodes[i];
                var name=getValue(childnode,'name');
                var type=getValue(childnode,'type');
                var enc=getValue(childnode,'enc');
                var auth=getValue(childnode,'auth');
                var remoteip=getValue(childnode,'remoteip');
                var vituralnetwork=getValue(childnode,'vituralnetwork');
                var txpkts=getValue(childnode,'txpkts');
                var txrate=getValue(childnode,'txrate');
                var rxpkts=getValue(childnode,'rxpkts');
                var rxrate=getValue(childnode,'rxrate');
                var uptime=getValue(childnode,'uptime');
                var peerid=getValue(childnode,'peerid');
                var index = name+"_"+type+"_"+remoteip+"_"+vituralnetwork;
                if(type == 'PPTP')
                data = data + "<tr align=center ><td><font color=\"#00FF00\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+gmarker.id+",1,'"+index+"')></td></tr>";
                else if (type == 'IPSec_Tunnel')
                data = data + "<tr align=center ><td><font color=\"#0000ff\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+gmarker.id+",1,'"+index+"')></td></tr>";
                else
                data = data + "<tr align=center ><td><font color=\"#770000\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+gmarker.id+",1,'"+index+"')></td></tr>";
                drawline(gmarker,peerid,type);
              }
              data = data +"</table>";
              */
              gmarker.openInfoWindowHtml(data);
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };



    function formatVPNStatus(http_request,deviceid,isFromChild,gmarker)
    {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                return "No VPN Connections";
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=80% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=12%><b>VPN</b></td><td width=7%><b>Type</b></td><td width=5%><b>Remote IP</b></td><td width=5%><b>Virtual Network</b></td><td width=5%><b>Tx Pkts</b></td><td width=5%><b>Tx Rate</b></td><td width=5%><b>Rx Pkts</b></td><td width=5%><b>Rx Rate</b></td><td width=5%><b>UpTime</b></td><td>&nbsp;</td></tr>";
              for(var i=0;i<len;i++){
                childnode=devices.childNodes[i];
                var name=getValue(childnode,'name');
                var type=getValue(childnode,'type');
                var enc=getValue(childnode,'enc');
                var auth=getValue(childnode,'auth');
                var remoteip=getValue(childnode,'remoteip');
                var vituralnetwork=getValue(childnode,'vituralnetwork');
                var txpkts=getValue(childnode,'txpkts');
                var txrate=getValue(childnode,'txrate');
                var rxpkts=getValue(childnode,'rxpkts');
                var rxrate=getValue(childnode,'rxrate');
                var uptime=getValue(childnode,'uptime');
                var peerid=getValue(childnode,'peerid');
                var index = name+"-"+type+"-"+remoteip+"-"+vituralnetwork;
                if(type == 'PPTP')
                data = data + "<tr align=center ><td><font color=\"#00FF00\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+deviceid+",1,'"+index+"')></td></tr>";
                else if (type == 'IPSec_Tunnel')
                data = data + "<tr align=center ><td><font color=\"#0000ff\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+deviceid+",1,'"+index+"')></td></tr>";
                else
                data = data + "<tr align=center ><td><font color=\"#770000\" size=\"1\">"+name+"</font></td><td>"+type+"&nbsp;"+enc+"&nbsp;"+auth+"</td><td>"+remoteip+"</td><td>"+vituralnetwork+"</td><td>"+txpkts+"</td><td>"+txrate+"</td><td>"+rxpkts+"</td><td>"+txrate+"</td><td>"+uptime+"</td><td><input type=button value='ThroughPut' onClick=Graph('"+name+"',"+deviceid+",1,'"+index+"')></td></tr>";

                if(isFromChild==1)
                {
                  data = data.replaceAll("Graph","parent.Graph");
                }
                if(gmarker!=null)
                drawline(gmarker,peerid,type);
              }
              data = data +"</table>";
              return data;
    }

    function LANStatus(http_request,gmarker) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var data = formatLANStatus(http_request,gmarker.id,0);
              gmarker.openInfoWindowHtml(data);
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };

    function formatLANStatus(http_request,deviceid,isFromChild)
    {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                return "No LAN Status";
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=50% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=10%><b>Interface</b></td><td width=15%><b>BytesSent</b></td><td width=15%><b>BytesReceived</b></td><td>&nbsp;</td></tr>";
              for(var i=1;i<=len;i++){
                childnode=devices.childNodes[i-1];
                var txsends=getValue(childnode,'bytessent');
                var rxsends=getValue(childnode,'bytesreceived');
                var ip=getValue(childnode,'ip');
                var index = ip+"_lan_"+i;

                data = data + "<tr align=center ><td><size=\"1\">LAN_"+i+"</td><td><font color=\"#00ff00\" size=\"1\">"+txsends+"</font></td><td><font color=\"#0000ff\" size=\"1\">"+rxsends+"</font>&nbsp;</td><td><input type=button value='ThroughPut' onClick=GraphLan('LAN"+i+"',"+deviceid+",1,'"+index+"')></td></tr>";
              }
              data = data +"</table>";
              if(isFromChild==1)
              {
                  data = data.replaceAll("GraphLan","parent.GraphLan");
              }

              return data;
    }

    function WANStatus(http_request,gmarker) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {

            //  gmarker.openInfoWindowHtml(http_request.responseText);
              var data = formatWANStatus(http_request,gmarker.id,0);
              gmarker.openInfoWindowHtml(data);
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };

    function formatWANStatus(http_request,deviceid,isFromChild)
    {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                return "No WAN Status";
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=50% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=10%><b>Interface</b></td><td width=15%><b>BytesSent</b></td><td width=15%><b>BytesReceived</b></td><td>&nbsp;</td></tr>";
              for(var i=1;i<=len;i++){
                childnode=devices.childNodes[i-1];
                var txsends=getValue(childnode,'bytessent');
                var rxsends=getValue(childnode,'bytesreceived');
                var ip=getValue(childnode,'ip');
                var index = ip+"_wan_"+i;
                data = data + "<tr align=center ><td><size=\"1\">WAN_"+i+"</td><td><font color=\"#00ff00\" size=\"1\">"+txsends+"</font></td><td><font color=\"#0000ff\" size=\"1\">"+rxsends+"</font>&nbsp;</td><td><input type=button value='ThroughPut' onClick=GraphWan('WAN"+i+"',"+deviceid+",1,'"+index+"')></td></tr>";
              }
              data = data +"</table>";
              if(isFromChild==1)
              {
                data =data.replaceAll("GraphWan","parent.GraphWan");
              }
              return data;
    }

    function VOIPStatus(http_request,gmarker) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var data = formatVoIPStatus(http_request,gmarker.id);
              gmarker.openInfoWindowHtml(data);
            } else {
              //return 'There was a problem with the request.';
            }
        }
    };

    function formatVoIPStatus(http_request,deviceid)
    {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("roots")[0];
              if(devices == null)
              {
                return "No VOIP Connections";
              }
              var childnode;
              var len=devices.childNodes.length;
              var data="<table width=80% border=1 cellpadding=1 cellspacing=1 align=center><tr align=center><td width=12%><b>Port</b></td><td width=7%><b>Elapse</b></td><td width=5%><b>Tx Pkts</b></td><td width=5%><b>Rx Pkts</b></td><td width=5%><b>Rx Losts</b></td><td width=5%><b>Rx Jitter</b></td><td width=5%><b>In Calls</b></td><td width=5%><b>Out Calls</b></td></tr>";
              for(var i=0;i<len;i++){
                childnode=devices.childNodes[i];
                var port=getValue(childnode,'port');
                var elapse=getValue(childnode,'elapse');
                var txpkts=getValue(childnode,'txpkts');
                var rxpkts=getValue(childnode,'rxpkts');
                var rxlosts=getValue(childnode,'rxlosts');
                var rxjitter=getValue(childnode,'rxjitter');
                var incalls=getValue(childnode,'incalls');
                var outcalls=getValue(childnode,'outcalls');
                data = data + "<tr align=center ><td>"+port+"</td><td>"+elapse+"</td><td>"+txpkts+"</td><td>"+rxpkts+"</td><td>"+rxlosts+"</td><td>"+rxjitter+"</td><td>"+incalls+"</td><td>"+outcalls+"</td></tr>";
              }
              data = data +"</table>";
              return data;
    }
    function drawline_vpn(marker,id,type,name)
    {
      var tomarker = gmarkers[id];
      if(tomarker)
      {
        if(isMarkerExist(marker.id,id,type)==1)
        {
          return;
        }
        //alert("marker.getPoint()="+marker.getPoint() +"tomarker.getPoint()="+tomarker.getPoint());
        var polyline;
        if(type=="PPTP")
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#00ff00", 5);
        else if (type=="IPSec_Tunnel")
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#0000ff", 5);
        else
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#770000", 5);
        polyline.type = type;
        polyline.src = marker.id;
        polyline.dst = id;
        GEvent.addListener(polyline, "click", function() {
          if(flag_contextmenu==isDisconnection){
            var answer = confirm("Are you sure to disconnect this?");
            if (answer){
              /*   */
              /*map.removeOverlay(polyline);*/
              makeRequest_vpn('AJAXServlet?ajaxact=VPNAction&type=disconnection&clientId='+id+'&serverId='+marker.id+'&vpn_name='+name,polyline);
              document.getElementById("processing").style.visibility="visible";

            }
            flag_contextmenu=flag_defaut;
          }
        });
        /*
        GEvent.addListener(polyline, "click", function() {
          alert("This VPN type is "+polyline.type);
        });
        */
        map.addOverlay(polyline);
        var i;
        for(i=0;i>=0;i++)
        {
          if(vpnmarkers[i]==null)
          {
            vpnmarkers[i] = polyline;
            //alert("add markers in i="+i+" vpnmarkers[i].src="+vpnmarkers[i].src);
            return;
          }
        }
        //alert("No create polyline marker");
      }
      else
      {
        // alert("other vpn");
      }
    }

    function drawline(marker,id,type)
    {
      var tomarker = gmarkers[id];
      if(tomarker)
      {
        if(isMarkerExist(marker.id,id,type)==1)
        {
          return;
        }
        //alert("marker.getPoint()="+marker.getPoint() +"tomarker.getPoint()="+tomarker.getPoint());
        var polyline;
        if(type=="PPTP")
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#00ff00", 5);
        else if (type=="IPSec_Tunnel")
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#0000ff", 5);
        else
        polyline = new GPolyline([marker.getPoint(),tomarker.getPoint()], "#770000", 5);
        polyline.type = type;
        polyline.src = marker.id;
        polyline.dst = id;

        GEvent.addListener(polyline, "click", function() {
            alert("This VPN type is "+polyline.type);
        });
        map.addOverlay(polyline);
        var i;
        for(i=0;i>=0;i++)
        {
          if(vpnmarkers[i]==null)
          {
            vpnmarkers[i] = polyline;
            //alert("add markers in i="+i+" vpnmarkers[i].src="+vpnmarkers[i].src);
            return;
          }
        }
        //alert("No create polyline marker");
      }
        else
      {
        // alert("other vpn");
      }
    }

    function Graph(name,id,isstart,fileindex)
    {
        var page;
        page = "GetRateGraphServlet?id="+id+"&action=getgraph&index="+fileindex;
        var tempwindow;
      if(isstart==1)
      {
        page = "GetRateGraphServlet?id="+id+"&actionthread=RrdTr069ActionThread&action=register&regname=GetRateGraphAction&index="+fileindex;
        //alert(page);
        makeRequest2(page);
        page = "GetRateGraphServlet?id="+id+"&action=getgraph&index="+fileindex;
        tempwindow = isc.Window.create({
        title:"Flow Chart-"+id+"-"+name,
        align:"center",
        isModal: false,
        autoDraw: true,
        animateMinimize: true,
        top:120,
        left:"22%",
        width:630,
        height:330,
        autoDraw:true,
        showBody:true,
        ID:"FlowChart"+"_"+id+"_"+name,
        src:""+page,
        closeClick : function (){
          page = "GetRateGraphServlet?id="+id+"&action=unregister&regname=GetRateGraphAction&index="+fileindex;
          //alert("page="+page);
          makeRequest2(page);
          this.Super('closeClick');
          this.title = "off";
        }
      });
      tempwindow.minimize();
      tempwindow.restore();
      setTimeout(function () { Graph(name,id,0,fileindex);}, 15000);
      }
      else
      {
        page = "GetRateGraphServlet?id="+id+"&action=getgraph&index="+fileindex;
       var window1 = window["FlowChart"+"_"+id+"_"+name];
       if(window1.title!="off")
        {
          window1.setSrc(page);
          setTimeout(function () { Graph(name,id,0,fileindex);}, 15000);
        }
      }
    }


    function GraphWan(name,id,isstart,fileindex)
    {
        var page;
        page = "GetRateGraphServlet?id="+id+"&action=getwangraph&index="+fileindex;
        var tempwindow;
      if(isstart==1)
      {
        page = "GetRateGraphServlet?id="+id+"&actionthread=RrdTr069WanActionThread&action=register&regname=GetWANRateGraphAction&index="+fileindex;
        //alert(page);
        makeRequest2(page);
        page = "GetRateGraphServlet?id="+id+"&action=getwangraph&index="+fileindex;
        tempwindow = isc.Window.create({
        title:"Flow Chart-"+id+"-"+name,
        align:"center",
        isModal: false,
        autoDraw: true,
        animateMinimize: true,
        top:120,
        left:"22%",
        width:630,
        height:330,
        autoDraw:true,
        showBody:true,
        ID:"FlowChart"+"_"+id+"_"+name,
        src:""+page,
        closeClick : function (){
          page = "GetRateGraphServlet?id="+id+"&action=unregister&regname=GetWANRateGraphAction&index="+fileindex;
          //alert("page="+page);
          makeRequest2(page);
          this.Super('closeClick');
          this.title = "off";
        }
      });
      tempwindow.minimize();
      tempwindow.restore();
      setTimeout(function () { GraphWan(name,id,0,fileindex);}, 15000);
      }
      else
      {
        page = "GetRateGraphServlet?id="+id+"&action=getwangraph&index="+fileindex;
       var window1 = window["FlowChart"+"_"+id+"_"+name];
       if(window1.title!="off")
        {
          window1.setSrc(page);
          setTimeout(function () { GraphWan(name,id,0,fileindex);}, 15000);
        }
      }
    }

    function GraphLan(name,id,isstart,fileindex)
    {
        var page;
        page = "GetRateGraphServlet?id="+id+"&action=getlangraph&index="+fileindex;
        var tempwindow;
      if(isstart==1)
      {
        page = "GetRateGraphServlet?id="+id+"&actionthread=RrdTr069LanActionThread&action=register&regname=GetLANRateGraphAction&index="+fileindex;
        //alert(page);
        makeRequest2(page);
        page = "GetRateGraphServlet?id="+id+"&action=getlangraph&index="+fileindex;
        tempwindow = isc.Window.create({
        title:"Flow Chart-"+id+"-"+name,
        align:"center",
        isModal: false,
        autoDraw: true,
        animateMinimize: true,
        top:120,
        left:"22%",
        width:630,
        height:330,
        autoDraw:true,
        showBody:true,
        ID:"FlowChart"+"_"+id+"_"+name,
        src:""+page,
        closeClick : function (){
          page = "GetRateGraphServlet?id="+id+"&action=unregister&regname=GetLANRateGraphAction&index="+fileindex;
          //alert("page="+page);
          makeRequest2(page);
          this.Super('closeClick');
          this.title = "off";
        }
      });
      //tempwindow.centerInPage();
      tempwindow.minimize();
      tempwindow.restore();
      setTimeout(function () { GraphLan(name,id,0,fileindex);}, 15000);
      }
      else
      {
        page = "GetRateGraphServlet?id="+id+"&action=getlangraph&index="+fileindex;
       var window1 = window["FlowChart"+"_"+id+"_"+name];
       if(window1.title!="off")
        {
          window1.setSrc(page);
          setTimeout(function () { GraphLan(name,id,0,fileindex);}, 15000);
        }
      }
    }

    function isMarkerExist(srcid,dstid,type) {
    var i;
    var length = vpnmarkers.length;
    //alert("D current length="+length);
        for(i=0;i<length;i++)
        {
          if( (vpnmarkers[i]!=null) && (vpnmarkers[i].src == srcid) && (vpnmarkers[i].dst ==dstid) && (vpnmarkers[i].type==type))
          {
            //alert("marker exits");
            return 1;
          }
        }
        return 0;
    }

    function makeRequest(url) {

        var http_request = false;

        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { alertContents(http_request); };
        http_request.send(null);
        setTimeout("makeRequest('"+url+"')", 60000);
    };

    function alertContents(http_request) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var xmldoc = http_request.responseXML;
              var roots = xmldoc.getElementsByTagName("root");
		var e = roots[0];
		var id = e.getElementsByTagName("id")[0].firstChild.data;
		var content = e.getElementsByTagName("content")[0].firstChild.data;
                document.getElementById(id).innerHTML=content;

              if(content=="up"){
                document.getElementById(id).style.backgroundColor="#00FF00";
              }else if(content=="down"){
                //document.getElementById("map_canvas");
                document.getElementById(id).style.backgroundColor="#FF00FF";
              }else{
                document.getElementById(id).style.backgroundColor="#FF0000";
              }

              //return http_request.responseText;

            } else {
              //return 'There was a problem with the request.';

            }
        }

    };

    function makeRequest1(url) {

        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, true);
        http_request.onreadystatechange =function() { alertContents1(http_request); };
        http_request.send(null);
        setTimeout("makeRequest1('"+url+"')", 60000);
    };
    function alertContents1(http_request) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              /*
              var xmldoc = http_request.responseXML;

              var roots = xmldoc.getElementsByTagName("root");
              var e = roots[0];
              var id = e.getElementsByTagName("id")[0].firstChild.data;
              var content = e.getElementsByTagName("content")[0].firstChild.data;
              */
              var data = http_request.responseText;
              var start = data.indexOf("<id>")+4;
              var end = data.indexOf("</id>",start);
              var id = data.substring(start,end);
              var start = data.indexOf("<content>")+9;
              var end = data.indexOf("</content>",start);
              var content = data.substring(start,end);
              if(content=="up"){
                var icon = gmarkers[id].getIcon();
                if(icon.image!= upicon)
                {
                  var newmarker = wmarkers[id];
                  newmarker.icon_uri = upicon;
                  map.removeOverlay(gmarkers[id]);

                  var newgmarker = createMarker(newmarker);
                  gmarkers[id]=newgmarker;
                  wmarkers[id]=newmarker;
                  map.addOverlay(newgmarker);
                }
                //document.getElementById(id).style.backgroundColor="#00FF00";
              }else if(content=="down"){
                var icon = gmarkers[id].getIcon();
                if(icon.image!= downicon)
                {
                  var newmarker = wmarkers[id];
                  newmarker.icon_uri = downicon;
                  map.removeOverlay(gmarkers[id]);

                  var newgmarker = createMarker(newmarker);
                  gmarkers[id]=newgmarker;
                  wmarkers[id]=newmarker;
                  map.addOverlay(newgmarker);
                }
                //document.getElementById("map_canvas");
                //document.getElementById(id).style.backgroundColor="#FF00FF";
              }else{
                //document.getElementById(id).style.backgroundColor="#FF0000";
              }

              //return http_request.responseText;

            } else {
              //return 'There was a problem with the request.';

            }
        }

    };

    function makeRequest2(url) {

        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.open('GET', url, false);
        http_request.onreadystatechange =function() {
        //  alert(http_request.responseText);
        };
        http_request.send(null);
        //setTimeout("makeRequest1('"+url+"')", 60000);
    };


    function handleDeviceStatus_vpn(http_request) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("devices")[0];
              var childnode;

              if(devices==null){
                return;
              }
              var len=devices.childNodes.length;

              for(var i=0;i<len;i++){

                childnode=devices.childNodes[i];

                var status1=getValue(childnode,'status');
                var id1=getValue(childnode,'id');


                if(gmarkers[id1]==null)
                continue;

                if(status1=="up"){
                  var icon = gmarkers[id1].getIcon();
                  if(icon.image!= upicon)
                  {
                    var newmarker = wmarkers[id1];
                    newmarker.icon_uri = upicon;
                    map.removeOverlay(gmarkers[id1]);

                    var newgmarker = createMarker(newmarker);
                    gmarkers[id1]=newgmarker;
                    wmarkers[id1]=newmarker;
                    map.addOverlay(newgmarker);


                    govpnstatus(newgmarker.id,"AllVpnConnection");


                  }
                }else if(status1=="down"){
                  var icon = gmarkers[id1].getIcon();
                  if(icon.image!= downicon)
                  {
                    var newmarker = wmarkers[id1];
                    newmarker.icon_uri = downicon;
                    map.removeOverlay(gmarkers[id1]);

                    var newgmarker = createMarker(newmarker);
                    gmarkers[id1]=newgmarker;
                    wmarkers[id1]=newmarker;
                    map.addOverlay(newgmarker);
                  }
              }else if(status1=="off"){

              }

              }
              //return http_request.responseText;

            } else {
              //return 'There was a problem with the request.';

            }
        }

    };

	function handleDeviceStatus(http_request) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
              var xmldoc = http_request.responseXML;
              var devices = xmldoc.getElementsByTagName("devices")[0];
              var childnode;
              if(devices==null){
                return;
              }

              var len=devices.childNodes.length;

              for(var i=0;i<len;i++){

                childnode=devices.childNodes[i];

                var status1=getValue(childnode,'status');
                var id1=getValue(childnode,'id');


                if(gmarkers[id1]==null)
                continue;

                if(status1=="up"){
                  var icon = gmarkers[id1].getIcon();
                  if(icon.image!= upicon)
                  {
                    var newmarker = wmarkers[id1];
                    newmarker.icon_uri = upicon;
                    map.removeOverlay(gmarkers[id1]);

                    var newgmarker = createMarker(newmarker);
                    gmarkers[id1]=newgmarker;
                    wmarkers[id1]=newmarker;
                    map.addOverlay(newgmarker);


                  }
                }else if(status1=="down"){
                  var icon = gmarkers[id1].getIcon();
                  if(icon.image!= downicon)
                  {
                    var newmarker = wmarkers[id1];
                    newmarker.icon_uri = downicon;
                    map.removeOverlay(gmarkers[id1]);

                    var newgmarker = createMarker(newmarker);
                    gmarkers[id1]=newgmarker;
                    wmarkers[id1]=newmarker;
                    map.addOverlay(newgmarker);
                  }
              }else if(status1=="off"){

              }

              }
              //return http_request.responseText;

            } else {
              //return 'There was a problem with the request.';

            }
        }

    };


   function Start(url) {
      setTimeout("makeRequest('"+url+"')", 1);
    };
  function Start1(url) {
      setTimeout("makeRequest1('"+url+"')", 1);
    };
   function StartNetworkDeviceMonitor()
   {
     var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        var actURL="AJAXServlet?ajaxact=NetworkStatusAction&id="+currentid;
        http_request.open('GET', actURL, true);
        http_request.onreadystatechange =function() { handleDeviceStatus(http_request); };
        http_request.send(null);
        setTimeout("StartNetworkDeviceMonitor()", 60000);
   }



     function StartNetworkDeviceMonitor_vpn()
   {
     var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        var actURL="AJAXServlet?ajaxact=NetworkStatusAction&id="+currentid;
        http_request.open('GET', actURL, true);
        http_request.onreadystatechange =function() { handleDeviceStatus_vpn(http_request); };
        http_request.send(null);
        setTimeout("StartNetworkDeviceMonitor_vpn()", 60000);
   }
