//Note: The options array initialized in menu.html follows
//      the MENU_OPTION order defined here.	Both sides must
//      be in the same order.
var MENU_OPTION_USER              = 0;
var MENU_OPTION_STANDARD          = 1;
var MENU_OPTION_PROTOCOL          = 2;
var MENU_OPTION_FIREWALL          = 3;
var MENU_OPTION_NAT               = 4;
var MENU_OPTION_IP_EXTENSION      = 5;
var MENU_OPTION_WIRELESS          = 6;
var MENU_OPTION_VOICE             = 7;
var MENU_OPTION_SNMP              = 8;
var MENU_OPTION_UPNP              = 9;
var MENU_OPTION_DDNSD             = 10;
var MENU_OPTION_SNTP              = 11;
var MENU_OPTION_EBTABLES          = 12;
var MENU_OPTION_BRIDGE            = 13;
var MENU_OPTION_TOD               = 14;
var MENU_OPTION_SIPROXD           = 15;
var MENU_OPTION_DHCPEN            = 16;
var MENU_OPTION_QOS               = 17;
var MENU_OPTION_PORTMAP           = 18;
var MENU_OPTION_IPP               = 19;
var MENU_OPTION_WIRELESS_SES      = 20;
var MENU_OPTION_RIP               = 21;
var MENU_OPTION_IPSEC             = 22;
var MENU_OPTION_CERT              = 23;
var MENU_OPTION_WL_QOS            = 24;
var MENU_OPTION_TR69C             = 25;
var MENU_OPTION_VDSL              = 26;
var MENU_OPTION_URLFILTER         = 27;
var MENU_OPTION_IPV6_SUPPORT      = 28;
var MENU_OPTION_IPV6_ENABLE       = 29;
var MENU_OPTION_DNSPROXY          = 30;
var MENU_OPTION_POLICY_ROUTING    = 31;
var MENU_OPTION_OMCI              = 32;
var MENU_OPTION_CHIPID            = 33;
var MENU_OPTION_WIRELESS_NUM_ADAPTOR =34;
var MENU_OPTION_DIAG_P8021AG      =35;
var MENU_OPTION_ETHWAN            =36;
var MENU_OPTION_PTMWAN            =37;
var MENU_OPTION_PWRMNGT           =39;
var MENU_OPTION_VOICE_NTR         =40;
var MENU_OPTION_ATMWAN            =41;
var MENU_OPTION_MOCAWAN           =42;
var MENU_OPTION_VOICE_DECT        =43;
var MENU_OPTION_DSL_BONDING       =44;
var MENU_OPTION_MULTICAST         =45;
var MENU_OPTION_VPN               =46;
var MENU_OPTION_STORAGESERVICE    =47;
var MENU_OPTION_SUPPORT_MOCA      =48;
var MENU_OPTION_STANDBY           =49;
var MENU_OPTION_DLNA              =50;
var MENU_OPTION_WIRELESS_WAPI_AS  =51;
var MENU_OPTION_AUTODETECTION	  =52;
var MENU_OPTION_GPONWAN           =53;
var MENU_OPTION_POLICE_ENABLE     =54;
var MENU_OPTION_MODSW_WEBUI       =55;
var MENU_OPTION_EPONWAN           =56;
var MENU_OPTION_SAMBA             =57;
var MENU_OPTION_BMU               =58;
var MENU_OPTION_BUILD_VDSL        =59;
var MENU_OPTION_SUPPORT_LAN_VLAN  =60;
var MENU_OPTION_OPTICAL           =61;
var MENU_OPTION_WIFIWAN           =62;
var MENU_OPTION_MODSW_WEBUI_ADMIN =63;
var MENU_OPTION_MODSW_WEBUI_SUPPORT =64;
var MENU_OPTION_MODSW_BASELINE    =65;
var MENU_OPTION_MODSW_OSGIEE      =66;
var MENU_OPTION_MODSW_LINUXEE     =67;
var MENU_OPTION_MODSW_LINUXPFP    =68;
var MENU_OPTION_SUPPORT_ETHPORTSHAPING =69;
var MENU_OPTION_DIAGNOSTICS_TOOLS  = 70;
var MENU_OPTION_BUILD_TMS         =71;
var MENU_OPTION_WAN_USB_MODEM_CFG     =72;
var MENU_OPTION_L2TP_VPN         =73;
var MENU_OPTION_L2TPNS         =74;
var MENU_OPTION_PPTP_VPN         =75;
var MENU_OPTION_BUILD_SPDSVC      =76;
var MENU_OPTION_SUPPORT_HOMEPLUG  =77;
var MENU_OPTION_XMPP              =78;
var MENU_OPTION_JQPLOT            =79;
var MENU_OPTION_WEB_SOCKETS       =80;
var MENU_OPTION_DPI               =81;
var MENU_OPTION_SUPPORT_IEEE1905  =82;
var MENU_OPTION_SUPPORT_WEBSOCKETS=83;
var MENU_OPTION_SUPPORT_WLVISUALIZATION =84;
var MENU_OPTION_VOICE_SIP_CCTK    =85;
var MENU_OPTION_BUILD_USB_HOSTS   =86;
var MENU_OPTION_QRCODE_SAMPLE      =87;
var MENU_OPTION_SUPPORT_WLPASSPOINT =88;
var MENU_OPTION_SUPPORT_CELLULAR  =89;
var MENU_OPTION_NFC               =90;
var MENU_OPTION_EPON_LOID         =91;
var MENU_OPTION_INGRESS_FILTERS   =92;
var MENU_OPTION_STATS_QUEUE       =93;
var MENU_OPTION_AUTO_UPDATE = 94;
var MENU_OPTION_MULTINAT                = 95;
var MENU_OPTION_SRV_IP_CNTR = 96;
var MENU_OPTION_ETH_SPEED_MODE = 97;
var MENU_OPTION_IPERF   =98;
var MENU_OPTION_SYSUSER                   = 99;
var MENU_OPTION_SPTUSER                   = 100;
var MENU_OPTION_USRUSER                   = 101;

var wlItemsCgiCmd = new Array(
 	                    'wlswitchinterface1.wl',
                           'wlswitchinterface0.wl',
                           'wlswitchinterface2.wl',
                           'wlswitchinterface3.wl'
                          );

 var wlmenuTitle = new Array(
                           '2.4 GHz',
                           '5 GHz',
                           'wl2',
                           'wl3'
                          );
function menuAdmin(options) {
   var std = options[MENU_OPTION_STANDARD];
   var proto = options[MENU_OPTION_PROTOCOL];
   var firewall = options[MENU_OPTION_FIREWALL];
   var ipExt = options[MENU_OPTION_IP_EXTENSION];
   var wireless = options[MENU_OPTION_WIRELESS];
   var voice = options[MENU_OPTION_VOICE];
   var snmp = options[MENU_OPTION_SNMP];
   var ddnsd = options[MENU_OPTION_DDNSD];
   var sntp = options[MENU_OPTION_SNTP];
   var ebtables = options[MENU_OPTION_EBTABLES];
   var bridge = options[MENU_OPTION_BRIDGE];
   var tod = options[MENU_OPTION_TOD];
   var QosEnabled = options[MENU_OPTION_QOS];
   var vlanconfig = options[MENU_OPTION_PORTMAP];
   var ipp = options[MENU_OPTION_IPP];
   var dlna = options[MENU_OPTION_DLNA];
   var wireless_ses = options[MENU_OPTION_WIRELESS_SES];
   var rip = options[MENU_OPTION_RIP];
   var ipsec = options[MENU_OPTION_IPSEC];
   var certificate = 0;//options[MENU_OPTION_CERT];
   var wlqos = options[MENU_OPTION_WL_QOS];
   var tr69c = options[MENU_OPTION_TR69C];
   var ipv6Support = options[MENU_OPTION_IPV6_SUPPORT];
   var ipv6Enable = options[MENU_OPTION_IPV6_ENABLE];
   var upnp = options[MENU_OPTION_UPNP];
   var urlfilter = options[MENU_OPTION_URLFILTER];
   var dnsproxy = options[MENU_OPTION_DNSPROXY];
   var pr = options[MENU_OPTION_POLICY_ROUTING];
   var omci = options[MENU_OPTION_OMCI];
   var numWl = options[MENU_OPTION_WIRELESS_NUM_ADAPTOR];
   var ethwan = options[MENU_OPTION_ETHWAN];
   var ptm = options[MENU_OPTION_PTMWAN];
   var pwrmngt = 0;//options[MENU_OPTION_PWRMNGT];
   var standby = options[MENU_OPTION_STANDBY];
   var voiceNtr = options[MENU_OPTION_VOICE_NTR];
   var atm = options[MENU_OPTION_ATMWAN];
   var mocawan = options[MENU_OPTION_MOCAWAN];
   var gponwan = options[MENU_OPTION_GPONWAN];
   var eponwan = options[MENU_OPTION_EPONWAN];
   var dect = options[MENU_OPTION_VOICE_DECT];
   var dslbonding = options[MENU_OPTION_DSL_BONDING];
   var multicast = options[MENU_OPTION_MULTICAST];
   var vpn = options[MENU_OPTION_VPN];
   var storageservice = options[MENU_OPTION_STORAGESERVICE];
   var sambaservice = options[MENU_OPTION_SAMBA];
   var mocaCfg = options[MENU_OPTION_SUPPORT_MOCA];
   var wireless_wapi = options[MENU_OPTION_WIRELESS_WAPI_AS];
   var autoDetection = options[MENU_OPTION_AUTODETECTION];
   var policeEnable = options[MENU_OPTION_POLICE_ENABLE];
   var isDsl = 0;
   var modsw_webui = options[MENU_OPTION_MODSW_WEBUI];
   var modsw_webui_admin = options[MENU_OPTION_MODSW_WEBUI_ADMIN];
   var modsw_baseline = options[MENU_OPTION_MODSW_BASELINE];
   var modsw_linuxpfp = options[MENU_OPTION_MODSW_LINUXPFP];
   var bmu = options[MENU_OPTION_BMU];
   var buildVdsl = options[MENU_OPTION_BUILD_VDSL];
   var lanvlanEnable = options[MENU_OPTION_SUPPORT_LAN_VLAN];
   var wifiwan = options[MENU_OPTION_WIFIWAN]; 	
   var supportEthPortShaping = options[MENU_OPTION_SUPPORT_ETHPORTSHAPING];
   var buildTms = options[MENU_OPTION_BUILD_TMS];
   var buildSpdsvc = options[MENU_OPTION_BUILD_SPDSVC];
   var homeplug = options[MENU_OPTION_SUPPORT_HOMEPLUG];
   var xmpp = options[MENU_OPTION_XMPP];
   var jqplot = options[MENU_OPTION_JQPLOT];
   var websockets = options[MENU_OPTION_WEB_SOCKETS];
   var dpi = options[MENU_OPTION_DPI];
   var ieee1905 = options[MENU_OPTION_SUPPORT_IEEE1905];
   var support1905TopologyWeb = options[MENU_OPTION_SUPPORT_WEBSOCKETS];
   var wlVisualization= options[MENU_OPTION_SUPPORT_WLVISUALIZATION];
   var sipCctk = options[MENU_OPTION_VOICE_SIP_CCTK];
   var wlPasspoint= '0';//options[MENU_OPTION_SUPPORT_WLPASSPOINT];
   var cellularwan = options[MENU_OPTION_SUPPORT_CELLULAR];
   var nfc = options[MENU_OPTION_NFC];
   var eponLoid = options[MENU_OPTION_EPON_LOID];
   var ingressFilters = options[MENU_OPTION_INGRESS_FILTERS];
   var anywan = (ptm == '1' || atm == '1' || mocawan == '1' || cellularwan == '1' ||
       ethwan == '1' || wifiwan == '1' || gponwan == '1' || eponwan == '1');
   var l2tpvpn = options[MENU_OPTION_L2TP_VPN];
   var l2tpns = options[MENU_OPTION_L2TPNS];
   var pptpvpn = options[MENU_OPTION_PPTP_VPN];
   var wan_usbmodem_cfg = options[MENU_OPTION_WAN_USB_MODEM_CFG];
   var diagnosticsTools = options[MENU_OPTION_DIAGNOSTICS_TOOLS];
   var autoupdate = options[MENU_OPTION_AUTO_UPDATE];
   var multinat = options[MENU_OPTION_MULTINAT];
   var srvIpcntr = options[MENU_OPTION_SRV_IP_CNTR];
   var ethSpeedMode = options[MENU_OPTION_ETH_SPEED_MODE];
   var iperf = 0;//options[MENU_OPTION_IPERF];
   
	// Configure advanced setup/layer 2 interface 
	if (atm == '1' ) {
		isDsl = 1;
		nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'layer2atm.html'));
		nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'layer2atm.html'));
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_DSL_ATM_INTERFACE), 'layer2atm.html'));		
	} 
	if (ptm == '1') {
		isDsl = 1;
		if (atm != '1') {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'layer2ptm.html'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'layer2ptm.html'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_DSL_PTM_INTERFACE), 'layer2ptm.html'));		
	}	
	if (gponwan == '1' ) {
		if (!(atm == '1' || ptm == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'gponwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'gponwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_GPONWAN_INTERFACE), 'gponwan.cmd'));
	}
	if (eponwan == '1' ) {
		if (!(atm == '1' || ptm == '1' || gponwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'eponwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'eponwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_EPONWAN_INTERFACE), 'eponwan.cmd'));
	}	
	if (ethwan == '1' ) {
		if (!(atm == '1' || ptm == '1' || gponwan == '1' || eponwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'layer2eth.html'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'layer2eth.html'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_ETH_INTERFACE), 'layer2eth.html'));
	}
	if (wifiwan == '1' ) {
		if (!(atm == '1' || ptm == '1' || gponwan == '1' || eponwan == '1' || ethwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'wifiwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'wifiwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_WIFI_INTERFACE), 'wifiwan.cmd'));
	}	
	if (mocawan == '1') {
		if (!(atm == '1' || ptm == '1' || ethwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'mocawan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'mocawan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_MOCA_INTERFACE), 'mocawan.cmd'));
	}  
	
	if (anywan)
		insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_WAN),'wancfgview.html'));
	else
		nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'lancfg2.html'));

 	if ( wan_usbmodem_cfg == '1')
	    insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_WAN_USB_MODEM_CFG),'wanusbmodem_cfgview.html'));

	if(l2tpvpn == '1' || l2tpns == '1' || pptpvpn == '1' || ipsec == '1') {
		if (l2tpvpn == '1') {
			nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'l2tpwanview.html'));
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_VPN_L2TPAC), 'l2tpwanview.html'));
		}
		if (l2tpns == '1') {
			if(l2tpvpn != '1') {
				nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'l2tpnsview.html'));
			}
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_ADVSETUP_L2TPNS), 'l2tpnsview.html'));
		}
		if (pptpvpn == '1') {
			if(l2tpvpn != '1' && l2tpns != '1') {
				nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'pptpwanview.html'));
			}
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_VPN_PPTPAC), 'pptpwanview.html'));
		}
	}

	if(ethSpeedMode == '1')
		nodeEthMod = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_ETHSPEED), 'ethadvcfg.html'));
	
	nodeLAN = insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAN),'lancfg2.html'));
	insDoc(nodeLAN,gFld(getMenuTitle(MENU_LAN4),'lancfg2.html'));

      if ( ipv6Enable == '1' ) {
               insDoc(nodeLAN, gLnk('R', getMenuTitle(MENU_LAN6),'ipv6lancfg.html'));
         }

	if ( lanvlanEnable == '1' ) 
               insDoc(nodeLAN, gLnk('R', getMenuTitle(MENU_LAN_VLAN),'lanvlancfg.html'));

   // Configure connection auto detection
   if (autoDetection == '1')
      insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_AUTODETECTION), 'autodetection.cmd?action=view'));

   if ( mocaCfg == '1' ) {
      insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_MOCA_CONFIGURATION),'mocacfg.html'));
   }

   if (anywan) {
      // Configure security menu
      // If firewall is enabled and not in ipExt mode enable firewall menus
      // if (proto != 'Bridge' && ipExt != '1' ) {
      if ( proto != 'Not Applicable' && ipExt != '1' ) {
         // NAT menu is always displayed now
         nodeNat = insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_SC_NAT), 'scvrtsrvview.html'));
         insDoc(nodeNat, gLnk('R', getMenuTitle(MENU_SC_VIRTUAL_SERVER), 'scvrtsrvview.html'));
         insDoc(nodeNat, gLnk('R', getMenuTitle(MENU_SC_PORT_TRIGGER), 'scprttrgview.html'));
         insDoc(nodeNat, gLnk('R', getMenuTitle(MENU_SC_DMZ_HOST), 'scdmz.html'));
         insDoc(nodeNat, gLnk('R', getMenuTitle(MENU_ALGS), 'algcfg.html'));

      if (multinat == '1')
         insDoc(nodeNat, gLnk('R', getMenuTitle(MENU_MULTI_NAT), 'multinat.html'));
 
         // Security menu is always displayed now                   	
         nodeFirewall = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_SC_SECURITY), 'scoutfltview.html'));
         nodeIpFlt = insFld(nodeFirewall, gFld(getMenuTitle(MENU_SC_IP_FILTER), 'scoutfltview.html'));
         insDoc(nodeIpFlt, gLnk('R', getMenuTitle(MENU_SC_OUTGOING), 'scoutfltview.html'));
         insDoc(nodeIpFlt, gLnk('R', getMenuTitle(MENU_SC_INCOMING), 'scinfltview.html'));
         insFld(nodeFirewall, gFld(getMenuTitle(MENU_MAC_FILTER),'scmacfltview.html'));

         if ( tod == '1' ) 
         {
            nodeParentalControl = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_PARENTAL_CNTL),'todmngr.html'));
            insDoc(nodeParentalControl, gFld(getMenuTitle(MENU_TOD),'todmngr.html'));

            if ( urlfilter == '1' )
            {
               insDoc(nodeParentalControl, gFld(getMenuTitle(MENU_URLFILTER),'urlfilter.html'));
            }
         }
         else if ( urlfilter == '1' )
         {
            nodeParentalControl = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_PARENTAL_CNTL),'urlfilter.html'));
            insDoc(nodeParentalControl, gFld(getMenuTitle(MENU_URLFILTER),'urlfilter.html'));
         }
      }

      // Configure QoS class menu
      nodeQos = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_QOS),'qosqmgmt.html'));
      nodeQosQueue = insFld(nodeQos, gFld(getMenuTitle(MENU_QOS_QUEUE),'qosqueueview.html'));
      insDoc(nodeQosQueue, gLnk('R', getMenuTitle(MENU_QUEUE_CFG), 'qosqueueview.html'));
      if ( parseInt(numWl) != 0 )
         insDoc(nodeQosQueue, gLnk('R', getMenuTitle(MENU_WL_QUEUE), 'qosqueuewlview.html'));
      if (policeEnable == '1')
         insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_POLICER), 'qospolicer.cmd?action=view'));
      insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_CLASS), 'qosclsview.html'));
      if (supportEthPortShaping == '1')
      {
         insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_PORT_SHAPING), 'qosportshaping.html'));
      }

      // Configure routing menu
      nodeRouting = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_ROUTING), 'rtdefaultcfg.html'));
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_DEFAULT_ROUTE), 'rtdefaultcfg.html'));
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_STATIC_ROUTE),'rtroutecfg.html'));
   }
   else {
      // Configure routing menu for bridging devices with no WAN interface
      nodeRouting = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_ROUTING), 'rtroutecfg.cmd?action=viewcfg'));
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_STATIC_ROUTE),'rtroutecfg.cmd?action=viewcfg'));
   }

   if (pr == '1' )
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_POLICY_ROUTING),'prmngr.html'));

   if ( (proto == 'PPPoE' && ipExt == '0') ||
        (proto == 'PPPoA' && ipExt == '0') ||
        (proto == 'MER') ||
        (proto == 'IPoA') ) {
      // configure rip
      if ( rip == '1' )
         insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_RIP),'ripcfg.cmd?action=view'));
      // configure dns server
      nodeDnsSetup = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DNS), 'dnscfg.html'));
      insDoc(nodeDnsSetup, gLnk('R', getMenuTitle(MENU_DNS_SETUP), 'dnscfg.html'));
      // configure ddns client
      if ( ddnsd == '1' )
         insDoc(nodeDnsSetup, gLnk('R', getMenuTitle(MENU_DDNS), 'ddnsmngr.cmd'));
   }

   if (isDsl == 1)
   {
      // Configure ADSL Setting Menu based on Annex
      if ( std == 'annex_c' )
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'adslcfgc.html'));
      else if (buildVdsl == '1')
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'xdslcfg.html'));
      else if (buildVdsl == '2')
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'xdslcfg1.html'));
      else
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'adslcfg.html'));

      if (dslbonding == '1')
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL_BONDING), 'dslbondingcfg.html'));
   }

	// Configure upnp
	if (upnp == '1')
	   insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_UPNP), 'upnpcfg.html'));

	
   // Configure dnsproxy
   if (dnsproxy == '1')
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DNSPROXY), 'dnsproxycfg.html'));

   // Configure print server
   if ( ipp == '1' )
      insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_IPP), 'ippcfg.html'));

   // Configure dlna
   if ( dlna == '1' )
      insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DLNA), 'dlnacfg.html'));

   // Configure wireless menu

   if ( parseInt(numWl) != 0 ) {
      if(numWl != '1')
         wlanMenu = insFld(foldersTree, gFld(getMenuTitle(MENU_WIRELESS_SETTINGS), 'wlcfg1.html'));
 
//      for(i = 0; i < parseInt(numWl); i++)
      {
         // Configure wireless menu
         if(numWl == '1')
            nodeWireless = insFld(foldersTree, gFld(getMenuTitle(MENU_WIRELESS_SETTINGS), 'wlcfg1.html'));
         else
            nodeWireless = insFld(wlanMenu, gFld(wlmenuTitle[0], 'wlcfg1.html'));

         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_BASIC), 'wlcfg1.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SECURITY), 'wlsecurity1.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_MAC_FILTERING), 'wlmacfltview1.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_WDS), 'wlwdsview.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_ADVANCED), 'wlcfgadv1.html'));
         //SUPPORT_SES
         if ( wireless_ses == '1' ) { 
            insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SES), 'wlses.html'));      
         }
      
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_STATION_LIST), 'wlstationlist.html'));
	 
	 if(numWl == '1')
            nodeWireless = insFld(foldersTree, gFld(getMenuTitle(MENU_WIRELESS_SETTINGS), 'wlcfg2.html'));
         else
            nodeWireless = insFld(wlanMenu, gFld(wlmenuTitle[1], 'wlcfg2.html'));

         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_BASIC), 'wlcfg2.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SECURITY), 'wlsecurity2.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_MAC_FILTERING), 'wlmacfltview2.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_WDS), 'wlwdsview.html'));
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_ADVANCED), 'wlcfgadv2.html'));
         //SUPPORT_SES
         if ( wireless_ses == '1' ) { 
            insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SES), 'wlses.html'));      
         }
      
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_STATION_LIST), 'wlstationlist.html'));
      }

      if ( wireless_wapi == '1' ) {      
          if (numWl == '1') {
             insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_WAPI_AS), 'wlwapias.html'));
          }
          else {
             insDoc(wlanMenu, gLnk('R', getMenuTitle(MENU_WL_WAPI_AS), 'wlwapias.html'));
          }
      }
/*
      if(wlVisualization == '1') {
	      if (numWl == '1') {
		      wlVisualNode = insFld(nodeWireless, gFld(getMenuTitle(MENU_WL_VISUALIZATION), "wlvis/configure.asp"));
	      } else {
		      wlVisualNode = insFld(wlanMenu, gFld(getMenuTitle(MENU_WL_VISUALIZATION), "wlvis/configure.asp"));
	      }
              insDoc(wlVisualNode, gLnk('R', getMenuTitle(MENU_WL_VISUALIZATION_SITESURVEY), 'wlvis/visindex.asp'));
              insDoc(wlVisualNode, gLnk('R', getMenuTitle(MENU_WL_VISUALIZATION_CHANNELSTAT), 'wlvis/channelcapacity.asp'));
              insDoc(wlVisualNode, gLnk('R', getMenuTitle(MENU_WL_VISUALIZATION_METRICS), 'wlvis/metrics.asp'));
              insDoc(wlVisualNode, gLnk('R', getMenuTitle(MENU_WL_VISUALIZATION_CONFIGURE), 'wlvis/configure.asp'));
      }
*/

   }


     /*Storage Service menu */
   if(storageservice == '1')
   {
      nodeStorage = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_STORAGESERVICE), 'storageservicecfg.html'));
      insDoc(nodeStorage, gLnk('R', getMenuTitle(MENU_STORAGE_INFO), 'storageservicecfg.html'));
      if(sambaservice == '1'){
         insDoc(nodeStorage, gLnk('R', getMenuTitle(MENU_STORAGE_USERACCOUNT), 'storageuseraccountcfg.html'));
      }
   }

   // Configure voice menu
   if ( voice == 'MGCP' ) {
      nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voicemgcp_basic.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_MGCP), 'voicemgcp_basic.html'));
      if( voiceNtr != '2' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_NTR), 'voicentr.html'));
      }
   }
   else if ( voice == 'H.248' ) {
      nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voiceh248_status.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_H248_STATUS), 'voiceh248_status.html'));

      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_H248_BASIC), 'voiceh248_basic.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_H248_ADVANCED), 'voiceh248_advanced.html'));

   }
   else if ( voice == 'SIP' ) {
   	  //mod by huangxc for adding status page, 20100603
      //nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voicesip_basic.html'));
      nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voicesip_status.html'));
	  insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_STATUS), 'voicesip_status.html'));
	  //mod end
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_BASIC), 'voicesip_basic.html'));	  
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_ADVANCED), 'voicesip_advanced.html'));
	   //insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_IMS), 'voicesip_ims.html'));
	  /* add by zhangyajun on 20110429 for Nateks */
	 // insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_DMAP), 'voicesip_digitmap.html'));
	  /* add end */
	  // add starCode setting page, 20151130
	  insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_STARCODE), 'voicesip_starCode.html'));
	  //add end
	  //add by huangxc for adding extra page, 20100602
	  insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_EXTRA), 'voicesip_extra.html'));
	  //add end
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_DEBUG), 'voicesip_debug.html'));
      if(sipCctk == '1'){
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_CCTK), 'voicesip_cctk.html'));
      }
      if( voiceNtr != '2' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_NTR), 'voicentr.html'));
      }
      if( dect == '1' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_DECT), 'voicedect.html'));
      }
   }

   // Configure VLAN port mapping menu
   if ( anywan && vlanconfig == '1' ) {
      insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_INTF_GROUPING),'portmap.html'));
   }

   if ( ipv6Support == '1' ) {
      nodeIpTunnel = insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_IP_TUNNEL),'tunnelcfgview.html'));
      insDoc(nodeIpTunnel, gLnk('R', getMenuTitle(MENU_6IN4_TUNNEL),'tunnelcfgview.html'));
      insDoc(nodeIpTunnel, gLnk('R', getMenuTitle(MENU_4IN6_TUNNEL),'tunnelcfg4in6view.html'));
   }

   if ( ipsec == '1' ) {
      insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_SC_IPSEC), 'ipsecview.html'));
   }
   if (certificate == '1')  {
      nodeCert = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_CERT), 'certlocal.cmd?action=view'));
      insDoc(nodeCert, gLnk('R', getMenuTitle(MENU_CERT_LOCAL), 'certlocal.cmd?action=view'));
      insDoc(nodeCert, gLnk('R', getMenuTitle(MENU_CERT_CA), 'certca.cmd?action=view'));
   }

   // Configure standby menu item 
   if ( standby == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_STANDBY), 'standby.html'));

   // Configure power management 
   if ( pwrmngt == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_PWRMNGT), 'pwrmngt.html'));
  
   if ( bmu == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_BMU), 'bmu.html'));

   if ( multicast == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_MULTICAST), 'multicast.html'));
    
   // Configure epon loid authentication  
   if ( eponLoid == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_OAM_LOID), 'eponloid.html'));
   
   if ( ingressFilters == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_INGRESS_FILTERS), 'ingressFilters.html'));

   // Configure nfc
   if ( nfc == '1' )
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_NFC), 'nfc.html'));

   // Configure homeplug menu
   if (homeplug == '1') {
      nodeHomePlug = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_HOMEPLUG_INFO), 'homeplug.html'));
      insDoc(nodeHomePlug, gLnk('R', getMenuTitle(MENU_HOMEPLUG_PASSWORD), 'homeplugpassword.html'));
   }

   if (ieee1905 == '1') {
      nodeIeee1905 = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_IEEE1905), 'ieee1905cfg.html'));
      insDoc(nodeIeee1905, gLnk('R', getMenuTitle(MENU_IEEE1905_CONFIG), 'ieee1905cfg.html'));
      insDoc(nodeIeee1905, gLnk('R', getMenuTitle(MENU_IEEE1905_STATUS), 'ieee1905sts.cmd'));
      if (support1905TopologyWeb == '1') {
          insDoc(nodeIeee1905, gLnk('R', getMenuTitle(MENU_IEEE1905_TOPOLOGY), 'networkTopology.html'));
      }
   }
  
   // Configure DPI 
   if ( dpi == '1' && websockets == '1' && jqplot == '1') {
      nodeDpi = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DPI), 'dpicharts.html'));
      insDoc(nodeDpi, gLnk('R', getMenuTitle(MENU_DPI_GRAPH),'dpicharts.html'));
      insDoc(nodeDpi, gLnk('R', getMenuTitle(MENU_DPI_APP_INST_TABLE),'dpiappinst.cmd?sort=true'));
   }

   // Configure diagnostics menu
   nodeDiagnostics = insFld(foldersTree, gFld(getMenuTitle(MENU_DIAGNOSTICS), 'diag.html'));
   insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_DIAGNOSTICS),'diag.html'));
   if (buildTms == '1') {
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_DIAGETHOAM),'diagethoam.html'));
   }

   if (buildSpdsvc == '1' ) {
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_SPDSVC), 'speedsvc.html'));
   }
   if(diagnosticsTools == '1')
   {
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_DIAGNOSTICS_PING), 'ping.html'));
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_DIAGNOSTICS_TRACEROUTE), 'traceroute.html'));
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_DIAGNOSTICS_START_STOP_DSL), 'startstopdsl.html'));     	  
   }

   if(iperf == '1')
      insDoc(nodeDiagnostics, gLnk('R', getMenuTitle(MENU_IPERF), 'iperf3.html'));

   // Configure management menu
   nodeMngr = insFld(foldersTree, gFld(getMenuTitle(MENU_MANAGEMENT), 'backupsettings.html'));

   nodeSettings = insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SETTINGS), 'backupsettings.html'));
   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_BACKUP),'backupsettings.html'));
   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_UPDATE),'updatesettings.html'));
   if(autoupdate == '1')
      insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_MNG_AUTO_UPDATE),'autoupdatesettings.html'));
   
   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_DEFAULT), 'defaultsettings.html'));

   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SYSTEM_LOG), 'logintro.html'));
   if ( anywan )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SECURITY_LOG), 'seclogintro.html'));
   if ( snmp == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SNMP), 'snmpconfig.html'));
   if ( tr69c == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TR69C), 'tr69cfg.html'));
   if ( xmpp == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_XMPP_CONN), 'xmppconncfg.cmd?action=view'));
   if ( omci == '1' ) {
      nodeOmci = insFld(nodeMngr, gFld(getMenuTitle(MENU_OMCI_CFG), 'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_SET),'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_CREATE),'omcicreate.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_NEXT),'omcigetnext.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_MACRO),'omcimacro.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_DOWNLOAD),'omcidownload.html'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_SYSTEM),'omcisystem.html'));
   }	  
   if ( sntp == '1' && proto != 'Bridge' && !(proto=='PPPoE' && ipExt=='1') && !(proto=='PPPoA' && ipExt=='1') )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_SNTP), 'sntpcfg.html'));

   nodeAccCntr = insFld(nodeMngr, gFld(getMenuTitle(MENU_ACC_CNTR), 'password.html'));
   insDoc(nodeAccCntr, gLnk('R', getMenuTitle(MENU_ACC_CNTR_PASSWORD), 'password.html'));

   if ( modsw_webui == '1' && modsw_webui_admin == '1' && ( modsw_baseline == '1' || modsw_linuxpfp == '1' ) ) {

      if ( modsw_baseline == '1' ) {
          nodeModSw = insFld(nodeMngr, gFld(getMenuTitle(MENU_MODSW), 'modSwEE.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_EE),'modSwEE.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_DU),'modSwDU.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_EU), 'modSwEU.cmd'));

          if ( modsw_linuxpfp == '1' )
              insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_PFP), 'modSwPFP.cmd'));
      }
      else {
           nodeModSw = insFld(nodeMngr, gFld(getMenuTitle(MENU_MODSW), 'modSwPFP.cmd'));
           insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_PFP), 'modSwPFP.cmd'));
      }

   }

   if(srvIpcntr == '1'){
      insDoc(nodeAccCntr, gLnk('R', getMenuTitle(MENU_ACC_SRVCNTR_IP_LIST), 'scacccntr.html'));
   }

   insDoc(nodeAccCntr, gLnk('R', getMenuTitle(MENU_ACC_CNTR_SRVCNTR), 'scsrvcntr.html'));
   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_UPDATE_SOFTWARE), 'upload.html'));

   insFld(nodeMngr, gFld(getMenuTitle(MENU_RESET_ROUTER), 'resetrouter.html'));
   insFld(foldersTree, gFld(getMenuTitle(MENU_LOGOUT), 'logout.html'));      

}

function menuSupport(options) {
   var std = options[MENU_OPTION_STANDARD];
   var proto = options[MENU_OPTION_PROTOCOL];
   var ipExt = options[MENU_OPTION_IP_EXTENSION];
   var wireless = options[MENU_OPTION_WIRELESS];
   var voice = options[MENU_OPTION_VOICE];
   var snmp = options[MENU_OPTION_SNMP];
   var ddnsd = options[MENU_OPTION_DDNSD];
   var sntp = options[MENU_OPTION_SNTP];
   var QosEnabled = options[MENU_OPTION_QOS];
   var ipp = 0;//options[MENU_OPTION_IPP];
   var rip = options[MENU_OPTION_RIP];
   var tr69c = options[MENU_OPTION_TR69C];
   var ipv6Support = options[MENU_OPTION_IPV6_SUPPORT];
   var ipv6Enable = options[MENU_OPTION_IPV6_ENABLE];
   var upnp = options[MENU_OPTION_UPNP];
   var dnsproxy = options[MENU_OPTION_DNSPROXY];
   var omci = options[MENU_OPTION_OMCI];
   var numWl = options[MENU_OPTION_WIRELESS_NUM_ADAPTOR];
   var wireless_ses = options[MENU_OPTION_WIRELESS_SES];
   var ethwan = options[MENU_OPTION_ETHWAN];
   var ptm = options[MENU_OPTION_PTMWAN];
   var pwrmngt = 0;//options[MENU_OPTION_PWRMNGT];
   var standby = options[MENU_OPTION_STANDBY];
   var voiceNtr = options[MENU_OPTION_VOICE_NTR];
   var atm = options[MENU_OPTION_ATMWAN];
   var mocawan = options[MENU_OPTION_MOCAWAN];
   var gponwan = options[MENU_OPTION_GPONWAN];
   var eponwan = options[MENU_OPTION_EPONWAN];
   var dect = options[MENU_OPTION_VOICE_DECT];
   var dslbonding = options[MENU_OPTION_DSL_BONDING];
   var vpn = options[MENU_OPTION_VPN];
   var storageservice = options[MENU_OPTION_STORAGESERVICE];
   var sambaservice = options[MENU_OPTION_SAMBA];
   var mocaCfg = options[MENU_OPTION_SUPPORT_MOCA];
   var wireless_wapi = options[MENU_OPTION_WIRELESS_WAPI_AS];
   var policeEnable = options[MENU_OPTION_POLICE_ENABLE];
   var bmu = options[MENU_OPTION_BMU];
   var isDsl = 0;
   var modsw_webui = options[MENU_OPTION_MODSW_WEBUI];
   var modsw_webui_support = options[MENU_OPTION_MODSW_WEBUI_SUPPORT];
   var modsw_baseline = options[MENU_OPTION_MODSW_BASELINE];
   var modsw_linuxpfp = options[MENU_OPTION_MODSW_LINUXPFP];
   var buildVdsl = options[MENU_OPTION_BUILD_VDSL];
   var lanvlanEnable = options[MENU_OPTION_SUPPORT_LAN_VLAN];
   var wifiwan = options[MENU_OPTION_WIFIWAN];
   var supportEthPortShaping = options[MENU_OPTION_SUPPORT_ETHPORTSHAPING]; 
   var xmpp = options[MENU_OPTION_XMPP];
   var jqplot = options[MENU_OPTION_JQPLOT];
   var websockets = options[MENU_OPTION_WEB_SOCKETS];
   var wlPasspoint= '0';//options[MENU_OPTION_SUPPORT_WLPASSPOINT];
   var dpi = options[MENU_OPTION_DPI];
   var anywan = (ptm == '1' || atm == '1' || mocawan == '1' ||
       ethwan == '1' || wifiwan == '1' || gponwan == '1' || eponwan == '1');
   var l2tpvpn = options[MENU_OPTION_L2TP_VPN];
   var l2tpns = options[MENU_OPTION_L2TPNS];
   var pptpvpn = options[MENU_OPTION_PPTP_VPN];
   var autoupdate = options[MENU_OPTION_AUTO_UPDATE];
	
	// Configure advanced setup/layer 2 interface 
	if (atm == '1' ) {
		isDsl = 1;
		nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'dslatm.cmd'));
		nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'dslatm.cmd'));
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_DSL_ATM_INTERFACE), 'dslatm.cmd'));		
	} 
	if (ptm == '1') {
		isDsl = 1;
		if (atm != '1') {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'dslptm.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'dslptm.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_DSL_PTM_INTERFACE), 'dslptm.cmd'));		
	}	   	
	if (gponwan == '1' ) {
		if (!(atm == '1' || ptm == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'gponwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'gponwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_GPONWAN_INTERFACE), 'gponwan.cmd'));
	}
	if (eponwan == '1' ) {
		if (!(atm == '1' || ptm == '1') || gponwan == '1' ) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'eponwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'eponwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_EPONWAN_INTERFACE), 'eponwan.cmd'));
	}	
	if (ethwan == '1' ) {
		if (!(atm == '1' || ptm == '1' || gponwan == '1'  || eponwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'ethwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'ethwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_ETH_INTERFACE), 'ethwan.cmd'));
	}
	if (wifiwan == '1' ) {
		if (!(atm == '1' || ptm == '1' || gponwan == '1' || eponwan == '1' || ethwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'wifiwan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'wifiwan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_WIFI_INTERFACE), 'wifiwan.cmd'));
	}	
	if (mocawan == '1') {
		if (!(atm == '1' || ptm == '1' || ethwan == '1')) {
			nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'mocawan.cmd'));
			nodeLayer2Inteface = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAYER2_INTERFACE), 'mocawan.cmd'));
		}
		insDoc(nodeLayer2Inteface, gLnk('R', getMenuTitle(MENU_MOCA_INTERFACE), 'mocawan.cmd'));
	}  
	
	if (anywan)
		insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_WAN),'wancfg.cmd'));
	else
		nodeAdvancedSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_ADVANCED_SETUP), 'lancfg2.html'));

	if(l2tpvpn == '1' || l2tpns == '1' || pptpvpn == '1' ) {
		if (l2tpvpn == '1') {
			nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'l2tpacwan.cmd'));
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_VPN_L2TPAC), 'l2tpacwan.cmd'));
		}
		if (l2tpns == '1') {
			if(l2tpvpn != '1') {
				nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'l2tpns.cmd'));
			}
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_ADVSETUP_L2TPNS), 'l2tpns.cmd'));
		}
		if (pptpvpn == '1') {
			if(l2tpvpn != '1' && l2tpns != '1') {
				nodeVPN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_VPN), 'pptpacwan.cmd'));
			}
			insDoc(nodeVPN, gLnk('R', getMenuTitle(MENU_VPN_PPTPAC), 'pptpacwan.cmd'));
		}
	}
	
	nodeLAN = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_LAN),'lancfg2.html'));
	insDoc(nodeLAN,gFld(getMenuTitle(MENU_LAN4),'lancfg2.html'));	
   
   if ( ipv6Enable == '1' ) {
      insDoc(nodeLAN, gLnk('R', getMenuTitle(MENU_LAN6),'ipv6lancfg.html'));
   }

	if ( lanvlanEnable == '1' ) 
		insFld(nodeLAN, gFld(getMenuTitle(MENU_LAN_VLAN),'lanvlancfg.html'));

   if ( mocaCfg == '1' ) {
      insDoc(nodeAdvancedSetup, gLnk('R', getMenuTitle(MENU_MOCA_CONFIGURATION),'mocacfg.html'));
   }

   if (anywan) {
      // Configure QoS class menu
      nodeQos = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_QOS),'qosqmgmt.html'));
      nodeQosQueue = insFld(nodeQos, gFld(getMenuTitle(MENU_QOS_QUEUE),'qosqueue.cmd?action=view'));
      insDoc(nodeQosQueue, gLnk('R', getMenuTitle(MENU_QUEUE_CFG), 'qosqueue.cmd?action=view'));
      if ( parseInt(numWl) != 0 )
         insDoc(nodeQosQueue, gLnk('R', getMenuTitle(MENU_WL_QUEUE), 'qosqueue.cmd?action=view_wlq'));
      if (policeEnable == '1')
         insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_POLICER), 'qospolicer.cmd?action=view'));
      insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_CLASS), 'qoscls.cmd?action=view'));
      if (supportEthPortShaping == '1')
      {
         insDoc(nodeQos, gLnk('R', getMenuTitle(MENU_QOS_PORT_SHAPING), 'qosportshaping.html'));
      }
   
      // Configure routing menu
      nodeRouting = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_ROUTING), 'rtdefaultcfg.html'));
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_DEFAULT_ROUTE), 'rtdefaultcfg.html'));
      insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_STATIC_ROUTE),'rtroutecfg.cmd?action=viewcfg'));

      if ( (proto == 'PPPoE' && ipExt == '0') ||
           (proto == 'PPPoA' && ipExt == '0') ||
           (proto == 'MER') ||
           (proto == 'IPoA') ) {
         // configure rip
         if ( rip == '1' )
            insDoc(nodeRouting, gLnk('R', getMenuTitle(MENU_RT_RIP),'ripcfg.cmd?action=view'));
         // configure dns server
         nodeDnsSetup = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DNS), 'dnscfg.html'));
         insDoc(nodeDnsSetup, gLnk('R', getMenuTitle(MENU_DNS_SETUP), 'dnscfg.html'));
         // configure ddns client
         if ( ddnsd == '1' )
            insDoc(nodeDnsSetup, gLnk('R', getMenuTitle(MENU_DDNS), 'ddnsmngr.cmd'));
      }
   }
   
   if (isDsl == 1)
   {
      // Configure ADSL Setting Menu based on Annex
      if ( std == 'annex_c' )
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'adslcfgc.html'));
      else if (buildVdsl == '1')
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'xdslcfg.html'));
      else
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL), 'adslcfg.html'));

      if (dslbonding == '1')
         insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DSL_BONDING), 'dslbondingcfg.html'));
   }

	
   // Configure print server
   if ( ipp == '1' )
      insDoc(nodeAdvancedSetup, gFld(getMenuTitle(MENU_IPP), 'ippcfg.html'));
   
   // Configure upnp
   if (upnp == '1')
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_UPNP), 'upnpcfg.html'));

   // Configure dnsproxy
   if (dnsproxy == '1')
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DNSPROXY), 'dnsproxycfg.html'));
   
   // Configure standby menu item 
   if ( standby == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_STANDBY), 'standby.html'));

   // Configure power management 
   if ( pwrmngt == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_PWRMNGT), 'pwrmngt.html'));
  
   if ( bmu == '1' ) 
      insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_BMU), 'bmu.html'));

   // Configure wireless menu
   if ( parseInt(numWl) != 0 ) {

       if(numWl != '1')
           wlanMenu = insFld(foldersTree, gFld(getMenuTitle(MENU_WIRELESS_SETTINGS), wlItemsCgiCmd[0]));
 
       for(i = 0; i < parseInt(numWl); i++)
       {
   // Configure wireless menu
            if(numWl == '1')
                nodeWireless = insFld(foldersTree, gFld(getMenuTitle(MENU_WIRELESS_SETTINGS), wlItemsCgiCmd[0]));
	     else
		  nodeWireless = insFld(wlanMenu, gFld(wlmenuTitle[i], wlItemsCgiCmd[i]));
      insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_BASIC), 'wlcfg.html'));
      insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SECURITY), 'wlsecurity.html'));
      //insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_MAC_FILTERING), 'wlmacflt.cmd?action=view'));
      insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_WDS), 'wlwds.cmd?action=view'));
      insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_ADVANCED), 'wlcfgadv.html'));
      //SUPPORT_SES
      if ( wireless_ses == '1' ) { 
         insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_SES), 'wlses.html'));      
      }
      
      insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_STATION_LIST), 'wlstationlist.cmd'));
   


        }

      if(wlPasspoint == '1') {
	      if (numWl == '1') {
		      wlPassPointNode = insFld(nodeWireless, gFld(getMenuTitle(MENU_WL_PASSPOINT), "wlrouter/passpoint.asp"));
	      } else {
		      wlPassPointNode = insFld(wlanMenu, gFld(getMenuTitle(MENU_WL_PASSPOINT), "wlrouter/passpoint.asp"));
	      }
      }

      if ( wireless_wapi == '1' ) {      
          if (numWl == '1') {
             insDoc(nodeWireless, gLnk('R', getMenuTitle(MENU_WL_WAPI_AS), 'wlwapias.html'));
          }
          else {
             insDoc(wlanMenu, gLnk('R', getMenuTitle(MENU_WL_WAPI_AS), 'wlwapias.html'));
          }
      }
   }

     /*Storage Service menu */
   if(storageservice == '1')
   {
      nodeStorage = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_STORAGESERVICE), 'storageservicecfg.cmd?view'));
      insDoc(nodeStorage, gLnk('R', getMenuTitle(MENU_STORAGE_INFO), 'storageservicecfg.cmd?view'));
      if(sambaservice == '1'){
         insDoc(nodeStorage, gLnk('R', getMenuTitle(MENU_STORAGE_USERACCOUNT), 'storageuseraccountcfg.cmd?view'));
      }
   }

   // Configure voice menu
   if ( voice == 'MGCP' ) {
      nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voicemgcp_basic.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_MGCP), 'voicemgcp_basic.html'));
      if( voiceNtr != '2' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_NTR), 'voicentr.html'));
      }     
   }
   else if ( voice == 'SIP' ) {
      nodeVoice = insFld(foldersTree, gFld(getMenuTitle(MENU_VOICE_SETTINGS), 'voicesip_basic.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_BASIC), 'voicesip_basic.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_ADVANCED), 'voicesip_advanced.html'));
      insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_DEBUG), 'voicesip_debug.html'));
	  insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_SIP_STARCODE), 'voicesip_starCode.html'));
      if( voiceNtr != '2' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_NTR), 'voicentr.html'));
      }
      if( dect == '1' ) {
         insDoc(nodeVoice, gLnk('R', getMenuTitle(MENU_VOICE_DECT), 'voicedect.html'));
      }   
   }

   // Configure DPI 
   if ( dpi == '1' && websockets == '1' && jqplot == '1') {
      nodeDpi = insFld(nodeAdvancedSetup, gFld(getMenuTitle(MENU_DPI), 'dpicharts.html'));
      insDoc(nodeDpi, gLnk('R', getMenuTitle(MENU_DPI_GRAPH),'dpicharts.html'));
      insDoc(nodeDpi, gLnk('R', getMenuTitle(MENU_DPI_APP_INST_TABLE),'dpiappinst.cmd?sort=true'));
   }

    // Configure diagnostics menu
   nodeDiagnostics = insFld(foldersTree, gFld(getMenuTitle(MENU_DIAGNOSTICS), 'diag.html'));

   // Configure management menu
   nodeMngr = insFld(foldersTree, gFld(getMenuTitle(MENU_MANAGEMENT), 'backupsettings.html'));
   nodeSettings = insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SETTINGS), 'backupsettings.html'));
   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_BACKUP),'backupsettings.html'));
   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_UPDATE),'updatesettings.html'));
      if(autoupdate == '1')
      insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_MNG_AUTO_UPDATE),'autoupdatesettings.html'));

   insDoc(nodeSettings, gLnk('R', getMenuTitle(MENU_TL_SETTINGS_DEFAULT), 'defaultsettings.html'));

   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SYSTEM_LOG), 'logintro.html'));
   if ( anywan )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SECURITY_LOG), 'seclogintro.html'));
   if ( snmp == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SNMP), 'snmpconfig.html'));
   if ( tr69c == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_TR69C), 'tr69cfg.html'));
   if ( xmpp == '1' )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_XMPP_CONN), 'xmppconncfg.cmd?action=view'));
   if ( omci == '1' ) {
      nodeOmci = insFld(nodeMngr, gFld(getMenuTitle(MENU_OMCI_CFG), 'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_SET),'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_CREATE),'omcicreate.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_NEXT),'omcigetnext.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_MACRO),'omcimacro.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_DOWNLOAD),'omcidownload.html'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_SYSTEM),'omcisystem.html'));
   }
   if ( sntp == '1' && proto != 'Bridge' && !(proto=='PPPoE' && ipExt=='1') && !(proto=='PPPoA' && ipExt=='1') )
      insFld(nodeMngr, gFld(getMenuTitle(MENU_SNTP), 'sntpcfg.html'));


   if ( modsw_webui == '1' && modsw_webui_support == '1' && ( modsw_baseline == '1' || modsw_linuxpfp == '1' ) ) {

      if ( modsw_baseline == '1' ) {
          nodeModSw = insFld(nodeMngr, gFld(getMenuTitle(MENU_MODSW), 'modSwEE.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_EE),'modSwEE.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_DU),'modSwDU.cmd'));
          insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_EU), 'modSwEU.cmd'));

          if ( modsw_linuxpfp == '1' )
              insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_PFP), 'modSwPFP.cmd'));
      }
      else {
           nodeModSw = insFld(nodeMngr, gFld(getMenuTitle(MENU_MODSW), 'modSwPFP.cmd'));
           insDoc(nodeModSw, gLnk('R', getMenuTitle(MENU_MODSW_PFP), 'modSwPFP.cmd'));
      }

   }


   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_UPDATE_SOFTWARE), 'upload.html'));
   insFld(nodeMngr, gFld(getMenuTitle(MENU_RESET_ROUTER), 'resetrouter.html'));
   insFld(foldersTree, gFld(getMenuTitle(MENU_LOGOUT), 'logout.html'));   
   
}

function menuUser() {
   var snmp = options[MENU_OPTION_SNMP];
   var tr69c = options[MENU_OPTION_TR69C];
   var omci = options[MENU_OPTION_OMCI];
   
   // Configure diagnostics menu
   nodeDiagnostics = insFld(foldersTree, gFld(getMenuTitle(MENU_DIAGNOSTICS), 'diag.html'));

   // Configure management menu
   nodeMngr = insFld(foldersTree, gFld(getMenuTitle(MENU_MANAGEMENT), 'logintro.html'));
   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SYSTEM_LOG), 'logintro.html'));
   //if ( snmp == '1' )
   //insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_SNMP), 'snmpconfig.html'));
   //if ( tr69c == '1' )
      //insFld(nodeMngr, gFld(getMenuTitle(MENU_TR69C), 'tr69cfg.html'));
   if ( omci == '1' ) {
      nodeOmci = insFld(nodeMngr, gFld(getMenuTitle(MENU_OMCI_CFG), 'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_SET),'omcicfg.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_CREATE),'omcicreate.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_GET_NEXT),'omcigetnext.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_MACRO),'omcimacro.cmd?action=view'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_DOWNLOAD),'omcidownload.html'));
      insDoc(nodeOmci, gLnk('R', getMenuTitle(MENU_OMCI_SYSTEM),'omcisystem.html'));
   }
   insFld(nodeMngr, gFld(getMenuTitle(MENU_TL_UPDATE_SOFTWARE), 'upload.html'));
   insFld(foldersTree, gFld(getMenuTitle(MENU_LOGOUT), 'logout.html'));      
   
}

function createBcmMenu(options) {
   var user = options[MENU_OPTION_USER];
   var proto = options[MENU_OPTION_PROTOCOL];
   var ipExt = options[MENU_OPTION_IP_EXTENSION];
   var dhcpen = options[MENU_OPTION_DHCPEN];
   var jqplot = options[MENU_OPTION_JQPLOT];
   var websockets = options[MENU_OPTION_WEB_SOCKETS];
   var mocaStats = options[MENU_OPTION_SUPPORT_MOCA];
   var ptm = options[MENU_OPTION_PTMWAN];
   var atm = options[MENU_OPTION_ATMWAN];
   var mocawan = options[MENU_OPTION_MOCAWAN];
   var ethwan = options[MENU_OPTION_ETHWAN];
   var gponwan = options[MENU_OPTION_GPONWAN];
   var eponwan = options[MENU_OPTION_EPONWAN];
   var optical = options[MENU_OPTION_OPTICAL];
   var wifiwan = options[MENU_OPTION_WIFIWAN]; 
   var cellularwan = options[MENU_OPTION_SUPPORT_CELLULAR]; 
   var buildUsbHosts = options[MENU_OPTION_BUILD_USB_HOSTS];
   var qrcode = options[MENU_OPTION_QRCODE_SAMPLE];
   var statsqueue = options[MENU_OPTION_STATS_QUEUE];
   var sysuser = options[MENU_OPTION_SYSUSER];
   var sptuser = options[MENU_OPTION_SPTUSER];
   var usruser = options[MENU_OPTION_USRUSER];
   
   var anywan = (ptm == '1' || atm == '1' || mocawan == '1' ||
       ethwan == '1' || wifiwan == '1' || gponwan == '1' || eponwan == '1');
   
   foldersTree = gFld('', 'info.html');
   // device info menu
   nodeDeviceInfo = insFld(foldersTree, gFld(getMenuTitle(MENU_DEVICE_INFO), 'info.html'));
   // device summary menu
   insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_DEVICE_SUMMARY), 'info.html'));
   // device wan menu
   if (anywan)
      insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_DEVICE_WAN), 'waninfo.html'));
   // device statistics menu
   nodeSts = insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_STATISTICS), 'statsifc.html'));
   insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_ST_LAN), 'statsifc.html'));
   if (mocaStats == '1')
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_ST_MOCA), 'statsmoca.cmd?choice=LAN'));
   if (anywan)
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_WAN), 'statswan.html'));
   if (ptm == '1' || atm == '1') {
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_ST_ATM), 'statsxtm.html'));
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_ST_ADSL), 'statsadsl.html'));
   }
   if (optical == '1')
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_OPTICAL), 'statsopticifc.html'));
   if (statsqueue == '1')
      insDoc(nodeSts, gLnk('R', getMenuTitle(MENU_ST_QUEUE), 'statsqueue.html'));
   // device route menu
   if (anywan)
      insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_DEVICE_ROUTE), 'routetbl.html'));
   insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_RT_ARP),'arpview.html'));
   // dhcp info
   if (!(ipExt == '1') && dhcpen == '1') {
      insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_DHCPINFO),'dhcpinfo.html'));
   }
   nodeBasicSetup = insFld(foldersTree, gFld(getMenuTitle(MENU_BASIC_SETUP), 'qinetsetup.html'));   
   // cpu & memory info
   if (jqplot == '1' && websockets == '1')
      insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_CPU_MEM_GRAPH),'cpumemcharts.html'));
   // usb hosts info
   if (buildUsbHosts  == '1') {
      insFld(nodeDeviceInfo, gFld(getMenuTitle(MENU_USB_HOSTS),'usbhosts.cmd?action=view'));
   }  

   if (qrcode=='1') {
       insDoc(nodeDeviceInfo, gFld(getMenuTitle(MENU_QRCODE_SAMPLE), 'qrcodesample.html'));
   }

  // cellular info menu
  if (cellularwan == '1')
      insDoc(nodeDeviceInfo, gLnk('R', getMenuTitle(MENU_CELLULAR_INFO), 'cellularinfo.html'));

   if ( user == sysuser )
      menuAdmin(options);
   else if ( user == sptuser )
      menuSupport(options);
   else if ( user == usruser )
      menuUser();
}
