<html>
   <head>
      <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
      <link rel="stylesheet" href='stylemain.css' type='text/css'>
         <link rel="stylesheet" href='colors.css' type='text/css'>
            <script language="javascript" src="util.js"></script>
            <script type="text/javascript" src="lang/b28n.js"></script>
            <script language="javascript"><%ejGetOther(forbidHTMLCode)%></script>
            <script language="javascript">
<!-- hide
var syncNvram = '<%ejGetWl(wlSyncNvram)%>';
 
function initTranslation() {
       var idArray = new Array("wlcfg1", "wlcfg2", "wlcfg3", "wlcfg4", "wlcfg5","wlEnableHspotText", "wlcfgHideAccessPoint", "wlcfgClientsIsolation", "wlcfgDisableWmm", "wlcfgEnableWmf", "wlcfgSsid", "wlcfgBssid", "wlcfgCountry", "wlcfgCountryRegRev", "wlcfgMaxClients", "wlcfg6", "wlcfg7", "wlcfg8","wlcfg9", "wlcfg10", "wlcfg11", "wlcfg12", "wlcfg13", "wlcfg14", "wlcfg15", "wlcfg16","wlcfg17","wlcfg18","wlcfg19",
				"countryRegrev");
       setAllIdValue(idArray);
}
var sessionKey = '<%ejGetOther(sessionKey)%>';

var unitNum = '<%ejGetWl(wlInstance_id)%>';
/*LegacyGuest*/
var ssid_2 = '<%ejGetWl(wlSsid_2)%>';
var enbl_2 = '<%ejGetWl(wlEnbl_2)%>';

var ssid = '<%ejGetWl(wlSsid_wl0v0)%>';
var enbl = '<%ejGetWl(wlEnbl_wl0v0)%>';
var hspotenbl = '<%ejGetWl(wlEnableHspot)%>';
var hide = '<%ejGetWl(wlHide_wl0v0)%>';
var apIsolation= '<%ejGetWl(wlAPIsolation_wl0v0)%>';
var maxAssoc = '<%ejGetWl(wlMaxAssoc_wl0v0)%>';
var disableWme = '<%ejGetWl(wlDisableWme_wl0v0)%>';
var enableWmf = '<%ejGetWl(wlEnableWmf_wl0v0)%>';
var country = '<%ejGetWl(wlCountry)%>';
var regrev = '<%ejGetWl(wlRegRev)%>';
var wlRefresh = '<%ejGetWl(wlRefresh)%>';
var band = '<%ejGetWl(wlBand)%>';
var supportMbss = '<%ejGetWl(wlSupportMbss)%>'
var wme = '<%ejGetWl(wlWme)%>';
var wmf = '<%ejGetWl(wlHasWmf)%>';
var wlInfo = '<%ejGetWl(wlInfo)%>';
var pattern_1ssid = /1ssid/i;
var globalmaxassoc= '<%ejGetWl(wlGlobalMaxAssoc)%>';
var WscMode = '<%ejGetWl(wlWscMode)%>';
var WscVer2 = '<%ejGetWl(wlWscVer2)%>';
var auth_mode = '<%ejGetWl(wlAuthMode)%>';
var enableUre = '<%ejGetWl(wlEnableUre)%>';

var curcountry=country;

if ( wlRefresh == '1' ) {
   var code = 'location="wlcfgrefresh.wl?wlRefresh=0"';
   eval(code);   
}

function removeBSSField(col) {
	var myTD=document.getElementById('wlBSSTbl').getElementsByTagName('tr')[0].getElementsByTagName('td')[col];
	myTD.parentNode.removeChild(myTD);
}

function wlCountryChanged(ct)  {
	var selcountry=getSelect(ct);
	if(selcountry!=curcountry) 
	{
		document.forms[0].wlRegRev.value= 0;
		curcountry=selcountry;
	}
}

function hideWlSecInfo(tohide) {

   with ( document.forms[0] ) {        
      if ( tohide == 1 ) {
         wlHide.disabled = 1;
         wlSsid.disabled = 1;
         wlCountry.disabled = 1;
         wlAPIsolation.disabled = 1;         
         showhide("hspot_cfg", 0);
      } else {
         wlHide.disabled = 0;
         wlSsid.disabled = 0;
         wlCountry.disabled = 0;
         wlAPIsolation.disabled = 0;           
	 if(hspotenbl!=2)
		 showhide("hspot_cfg", 1);
      }
   } 	  
      showhide("wlSecInfo", (!tohide));
      showhide("wlLegacyGuestInfo", ((!tohide)&&((supportMbss==0)&&!(pattern_1ssid.test(wlInfo)))));
      showhide("wlMBSSInfo", ((!tohide)&&(supportMbss!=0)));
}

function wlSecCbClick(cb) {
   if ( cb.checked == true )
      hideWlSecInfo(0);
   else
      hideWlSecInfo(1);
}

function wlLoadCountryList()
{
   var phytype = "b";
   var cur = 0;
   var sel = 0;
   var i = 0;

   if (band == "1") { // 5G
      <%ejGetWl(wlCountryList, a)%>
   } else {
      <%ejGetWl(wlCountryList, b)%>
   }

   for (i=0; i< document.forms[0].wlCountry.options.length; i++) {
      if (document.forms[0].wlCountry.options[i].value == country) {
         document.forms[0].wlCountry.options[i].selected = true;
         break;
      }
   }

   /* set to all(the last one) if not found */
   if( i == document.forms[0].wlCountry.options.length)
      document.forms[0].wlCountry.options[i-1].selected = true;
   
}

function frmLoad() {
  
   wlLoadCountryList();

   with ( document.forms[0] ) {
      if(hspotenbl==2)
      {
        showhide("hspot_cfg",0);
	removeBSSField(7);
      }
      else
      {
	setCheck(wlEnableHspot, hspotenbl);
	/*
	if(auth_mode && (auth_mode!="wpa2"))
	 {
		 setDisable(wlEnableHspot,1);
		 setInnerHtml("wlEnableHspotText","Enable Wireless Hotspot2.0 [WPA2 is required!]"); 
	 }
	 */
	removeBSSField(7);
      }
	  
      setCheck(wlEnbl, enbl);
      if ( enbl == '1' ) {
         hideWlSecInfo(0);
      } else {
         hideWlSecInfo(1);
      }
      setCheck(wlHide, hide);
      setCheck(wlAPIsolation, apIsolation);
      setCheck(wlDisableWme, disableWme);
      setCheck(wlEnableWmf, enableWmf);

      wlMaxAssoc.value = maxAssoc;
      wlRegRev.value= regrev;
      
      //remove wlDisableWme (Disable WMM Advertise) from webui if the product does not use MBSS driver</td>
      wlDisableWme.disabled=1;
      if(supportMbss == '1' && wme != '0' )
           wlDisableWme.disabled=0;   

      wlEnableWmf.disabled=1;
      if(wmf != '0' )
           wlEnableWmf.disabled=0;   
                               
      wlSsid.value = ssid;
      setCheck(wlEnbl_2, enbl_2);
      wlSsid_2.value = ssid_2;
   }
   initTranslation();
}

function invalidCheck()
{
   var duplicated = false;
   var invalid = false;
   var ssidArray = new Array();
   var idx=0;

   with ( document.forms[0] ) {
      ssidArray[idx++]=wlSsid.value;
         
      if(supportMbss==0) {	 
         /*LegacyGuest*/
         if (wlSsid.value == wlSsid_2.value)
            invalid = duplicated = true;
            
      } else {
         /* MBSS */         
         for (var i=0; i < document.forms[0].elements.length; i++){      
            /* SSID check */
            if(document.forms[0].elements[i].name.search('wlSsid_wl'+unitNum+'v') != -1) {
               ssidArray[idx]=document.forms[0].elements[i].value;
               if(ssidArray[idx] == ''|| ssidArray[idx].length > 32) {
                  alert(_("wlcfgAlert1"));
                  invalid = true;
                  break;               
               }
               for(var j = 0; j < idx; j++) {
                  if (ssidArray[idx] == ssidArray[j]) { 
                     invalid = duplicated = true;
                     break;
                  }                     
               }
               idx++;
            }
            if (duplicated)
               break;
            
            /* end of SSID check */   
            /* max assoc check */
            if(document.forms[0].elements[i].name.search('wlMaxAssoc_wl'+unitNum+'v') != -1) {
               var assocNum = parseInt(document.forms[0].elements[i].value);
               if ( isNaN(assocNum) == true || assocNum <= 0 || assocNum > globalmaxassoc ) {
                  alert(_("wlcfgAlert3") +assocNum + _("wlcfgAlert4") + globalmaxassoc);
                  invalid = true;
                  return invalid;
               }
            }
            /* end of  max assoc check */
         }
      }

	if (invalid ==true)
		return invalid;
      
      if ((enableUre == '0') && duplicated) {
         alert(_("wlcfgAlert5"));
	 invalid = true;	
      } else
         invalid = false; /* URE (Range Extender) allows duplicated SSID */
      
      return invalid;
   }
}

function btnApply() {
   var loc = 'wlcfg.wl?';
   var hide_checked = false;
    
   if(invalidCheck())
      return;
   
   with ( document.forms[0] ) {
      loc += 'wlSsidIdx=0';
      
      if ( wlEnbl.checked == false ) {
         loc += '&wlEnbl=0';
         loc += '&wlEnableHspot=0';
         loc += '&wlHide=' + hide;
         loc += '&wlAPIsolation=' + apIsolation;         
         loc += '&wlSsid=' + encodeUrl(ssid);
         loc += '&wlCountry=' + country;
      } else {
         if ( wlSsid.value == '' ) {
            alert(_("wlcfgAlert6"));
            return;
         }

         var str = new String();
         str = wlSsid.value;
         if ( str.length > 32 ) {
            alert(_("wlcfgAlert7") + wlSsid.value + _("wlcfgAlert8"));
            return;
         }
	
	if(str.indexOf('\\') != -1){
            alert(_("wlcfgAlert9") + wlSsid.value + _("wlcfgAlert10"));
            return;
         }	
	
	if(str.indexOf('\'') != -1){
            alert(_("wlcfgAlert11") + wlSsid.value + _("wlcfgAlert12"));
            return;
         }
	if (!inttest(wlMaxAssoc.value))
         {
            alert(_("wlcfgAlert13"));
            return;
         }
         var assocNum = parseInt(wlMaxAssoc.value);
         if ( isNaN(assocNum) == true || assocNum <= 0 || assocNum > globalmaxassoc ) {
            alert(_("wlcfgAlert14") + assocNum + _("wlcfgAlert15") + globalmaxassoc);
            return;
         }
         if ( wlEnableHspot.checked == false ) 
        	 loc += '&wlEnableHspot=0';
         else
        	 loc += '&wlEnableHspot=1';

         loc += '&wlEnbl=1';
         loc += submitCheck(wlHide);
         hide_checked = wlHide.checked;
         loc += submitCheck(wlAPIsolation);         
         if ((encodeUrl(wlSsid.value)=="") ) {
             alert ("Found non-ISO-8859-1 character, Please eliminate before continuing.");
             location.reload(true);
             return;
         }
         else {
             loc += '&wlSsid=' + encodeUrl(wlSsid.value);
         }
         loc += submitSelect(wlCountry);
//         loc += '&wlRegRev=' + encodeUrl(wlRegRev.value);
		if(submitSelect(wlCountry) == '&wlCountry=NZ' && band == 1)
			loc += '&wlRegRev=' + encodeUrl('4');
		else
			loc += '&wlRegRev=' + encodeUrl(wlRegRev.value);
         loc += '&wlMaxAssoc=' + encodeUrl(wlMaxAssoc.value);
         loc += submitCheck(wlDisableWme);
         loc += submitCheck(wlEnableWmf);

	 if(supportMbss==0 && !(pattern_1ssid.test(wlInfo))) {	 
	    /*LegacyGuest*/
	    if ( wlSsid_2.value == '' ) {
               alert(_("wlcfgAlert16"));
               return;
            }            
            loc += submitCheck(wlEnbl_2);
            loc += '&wlSsid_2=' + encodeUrl(wlSsid_2.value);
         } else {
            /* MBSS */           
            for (var i=0; i < document.forms[0].elements.length; i++){
               if(document.forms[0].elements[i].name.search('_wl'+unitNum+'v') != -1) {
                  if (document.forms[0].elements[i].type == 'checkbox') {
                     loc += submitCheck(document.forms[0].elements[i]);
                     //alert(submitCheck(document.forms[0].elements[i]));
                     /* Find checked Hidden box */
                     if (hide_checked == false)	{
                         //alert(document.forms[0].elements[i].name);
                         if ((document.forms[0].elements[i].name.search('wlEnbl_wl'+unitNum+'v') != -1)	&&
                             (document.forms[0].elements[i].checked == true)) {
                             /* Get hidden box */
                             for (var j=i+1; j < document.forms[0].elements.length; j++) {
                                if((document.forms[0].elements[j].name.search('wlHide_wl'+unitNum+'v') != -1) &&				
                                   (document.forms[0].elements[j].checked == true)) {
                                   hide_checked = document.forms[0].elements[j].checked;
                                   //alert(document.forms[0].elements[j].checked);
                                   break;
                                }
                             }						
                         }
                     }
                  }
                  if (document.forms[0].elements[i].type == 'text') {
                     loc += '&'+document.forms[0].elements[i].name + '=' + encodeUrl(document.forms[0].elements[i].value);
                     //alert('&'+document.forms[0].elements[i].name + '=' + encodeUrl(document.forms[0].elements[i].value));
                  }
               }            
            }
         }
      }
   }

   if ((hide_checked == true) && (WscVer2 == 'enabled') && (WscMode == 'enabled')) {
      if (confirm("WPS will be disabled if you choose to Hide Access Point") == false )
         return;
      else
         loc += '&wlWscMode=disabled';
   }

   loc += '&wlSyncNvram=1';

   loc += '&sessionKey=' + sessionKey;
   var code = 'location="' + loc + '"';
   eval(code);
}

// done hiding -->
      </script>
   </head>
   <body onLoad='frmLoad()'>
      <blockquote>
         <form onSubmit='return false'>
            <b id="wlcfg1">Wireless -- Basic</b><br>
            <br>
            <span id="wlcfg2">This page allows you to configure basic features of the wireless LAN interface. 
            You can enable or disable the wireless LAN interface, hide the network from 
            active scans, set the wireless network name (also known as SSID) and restrict 
          the channel set based on country requirements.</span><br>
           <span id="wlcfg3"> Click "Apply/Save" to configure the basic wireless options.</span><br>
            <br>
            <table border="0" cellpadding="4" cellspacing="0">
               <tr>
                  <td valign="middle" align="center" width="30" height="30">
                  
                     <input type='checkbox' id="wlcfg4" name='wlEnbl' onClick='wlSecCbClick(this)' value="ON"></td>
                  <td id="wlcfg5">Enable Wireless</td>
               </tr>
            </table>
            <div id='hspot_cfg'>
               <table border="0" cellpadding="4" cellspacing="0">
               <tr>
                  <td valign="middle" align="center" width="30" height="30">
                     <input type='checkbox' name='wlEnableHspot' value="ON"></td>
                  <td><div id="wlEnableHspotText"> Enable Wireless Hotspot2.0</div></td>
               </tr>
               </table>
	    </div>
            <div id='wlSecInfo'>
               <table border="0" cellpadding="4" cellspacing="0">
                  <tr>
                     <td valign="middle" align="center" width="30" height="30">
                        <input type='checkbox' name='wlHide' value="ON"></td>
                     <td id="wlcfgHideAccessPoint">Hide Access Point</td>
                  </tr>
               <tr>
                     <td valign="middle" align="center" width="30" height="30">
                        <input type='checkbox' name='wlAPIsolation' value="ON"></td>
                     <td id="wlcfgClientsIsolation">Clients Isolation</td>
               </tr>
               <tr>
                     <td valign="middle" align="center" width="30" height="30">
                        <input type='checkbox' name='wlDisableWme' value="ON"></td>
                     <td id="wlcfgDisableWmm">Disable WMM Advertise</td>
               </tr>
               <tr>
                   <td valign="middle" align="center" width="30" height="30">
                       <input type='checkbox' name='wlEnableWmf' value="ON">
                   </td>
                   <td id="wlcfgEnableWmf">Enable Wireless Multicast Forwarding (WMF)</td>
               </tr>
               </table>              
               <table border="0" cellpadding="4" cellspacing="0">
                  <tr>
                     <td width="50" id="wlcfgSsid">SSID:</td>
                     <td>
                        <input type='text' name='wlSsid' maxlength="32" size="32"></td>
                  </tr>
                  <tr>
                     <td width="50" id="wlcfgBssid">BSSID:</td>
                     <td>
                        <%ejGetWl(wlBssid_wl0)%>
                     </td>
                  </tr>
                  <tr>
                     <td id="wlcfgCountry">Country:</td>
                     <td><select name='wlCountry' size="1" onChange="wlCountryChanged(this)">
                        </select></td>
                  </tr>
                  <tr style="display:none;">
                     <td id="countryRegrev">Country RegRev</td>
                     <td>
                        <input type='text' name='wlRegRev' maxlength="3" size="3"></td>
                      </td>
                  </tr>
                  <tr>
                     <td id="wlcfgMaxClients">Max Clients:</td>
                     <td>
                        <input type='text' name='wlMaxAssoc' maxlength="3" size="3"></td>
                  </tr>
                  <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>                                      
               </table>              
            </div>                  
            <div id="wlLegacyGuestInfo">
               <table border="0" cellpadding="4" cellspacing="0">
                  <tr>
                     <td valign="middle" align="center" width="30" height="30">
                        <input type='checkbox' id="wlcfg6" name='wlEnbl_2' value="ON"></td>
                     <td id="wlcfg7">Enable Wireless Guest Network</td>
                  </tr>
               </table>
               <table border="0" cellpadding="4" cellspacing="0">
                  <tr>
                     <td width="100" id="wlcfg8">Guest SSID:</td>
                     <td>
                        <input type='text' name='wlSsid_2' maxlength="32" size="32"></td>
                  </tr>
               </table>
               <br>
               <br>
            </div>            
           <div id="wlMBSSInfo">
              <br><b id="wlcfg9">Wireless - Guest/Virtual Access Points:</b><br>
              <table id="wlBSSTbl" border="0" cellpadding="4" cellspacing="0">
                 <tr> <td>
                 <table border='1' cellpadding='2' cellspacing='0' align="left" >
                    <tr>
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg10">Enabled</td>                    
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg11">SSID</td>
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg12">Hidden</td>                       
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg13">Isolate Clients</td>
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg14">Disable WMM Advertise</td>
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg15">Enable WMF</td>
                       <td class='hd' valign="middle" align="center" width="30" height="30" >Enable HSPOT</td>
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg16">Max Clients</td>                                            
                       <td class='hd' valign="middle" align="center" width="30" height="30" id="wlcfg17">BSSID</td>
                    </tr>
                       <%ejGetWl(wlMbssTbl)%>
                 </table>
                 </td></tr>
              </table>
           <br>
           <br>            
           </div>
           <div id="divApply">           
              <table border="0" cellpadding="4" cellspacing="0">
               <tr> <td>        
               <input type='button' id="wlcfg18" onClick='btnApply()' value='Apply/Save'>
               </td> </tr>
              </table>
           </div>
         </form>
      </blockquote>
   </body>
</html>
