<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 language="javascript" src="gibberish-aes.js"></script>            
            <script type="text/javascript" src="jsencrypt.min.js"></script>		
            <script language="javascript">
<!-- hide
var ipExtension = '<%ejGet(pppIpExtension)%>';
var authMethod = '<%ejGet(pppAuthMethod)%>';
var prtcl = '<%ejGetOther(memInfo, ntwkPrtcl)%>';
var enblIpAddr = '<%ejGet(useStaticIpAddress)%>';
var localIpAddr = '<%ejGet(pppLocalIpAddress)%>';
var pppDebug = '<%ejGet(enblPppDebug)%>';
var pppDemand = '<%ejGet(enblPppDemand)%>';
var pppIdleTime = '<%ejGet(pppIdleTime)%>';
var pppShowAuthErrorRetry = '<%ejGet(pppShowAuthErrorRetry)%>';
var pppAuthErrorRetry = '<%ejGet(pppAuthErrorRetry)%>';
var enetWan = parseInt('<%ejGet(enblEnetWan)%>');
var ppptobr = '<%ejGet(pppToBridge)%>';
var nat = '<%ejGet(enblNat)%>';
var fullcone = '<%ejGet(enblFullcone)%>';
var firewall = '<%ejGet(enblFirewall)%>';
var enblAdvDmz = '<%ejGet(enblAdvDmz)%>';
var serviceId= '<%ejGet(serviceId)%>';
var sessionKey='<%ejGetOther(sessionKey)%>';
var cfgL2tpAc= '<%ejGet(cfgL2tpAc)%>';
var cfgPptpAc= '<%ejGet(cfgPptpAc)%>';
var enblGponWan = '<%ejGetOther(sysInfo, buildGponWan)%>';
var enblPcp = '<%ejGetOther(sysInfo, buildPcp)%>';
var wanL2If = '<%ejGet(wanL2IfName)%>';
var enblIpVer = '<%ejGet(enblIpVer)%>';
var unnumbered = '<%ejGet(unnumberedModel)%>';
var dhcp6cAddress = '<%ejGet(dhcp6cForAddr)%>';
var dhcp6cPd = '<%ejGet(dhcp6cForPd)%>';
var addr6Type = '<%ejGet(wanAddr6Type)%>'; if ( addr6Type == '&nbsp' ) addr6Type = '';
var addr6 = '<%ejGet(wanAddr6)%>';  if (addr6 == '&nbsp') addr6 = '';

var igmpProxySup = '<%ejGet(igmpProxySup)%>';
var mldProxySup = '<%ejGet(mldProxySup)%>';

var supportOpensslAES = '<%ejGetOther(sysInfo, supportOpensslAES)%>';
var PUBLIC_KEY = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv47uL0SnPFkmUinq3R6JMLR9dcGd5MgfuBAfKfjkpdGFim1ISYxGjaV0+FK6A+fpUrsYO2zVEnZVyhvVRAGyp4W+r86yLPLRQsIviD0C08faExQqEAPTMU3hQTrKzUvKgM5V9+NjRTtTWVHxI71pnYuOvcIA8VSj6Im/pgn33xeQmbsQD1H227OHuDjV6DmTTLWuz31A3HqU690UqRlW+h8dB2s25SefvpR+ijdfqDPWT+c+4tNMKPUQjDUB41hICPTmPORhFJqioFaZzCuElct2bYpdjps3Vv4AGYAgduuBJ2z/az3nb4OtHPh6/2bVpX5S5tBgo9WEJgvjPFRdwwIDAQAB';

var supportBuildWarning ='<%ejGetOther(sysInfo, buildVDFWarning)%>';

function hidePppIdleTimeLimit(hide) {
   var status = 'visible';

   if ( hide == 1 )
      status = 'hidden';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppIdleTimeLimit').style.visibility = status;
   else {
      if (document.layers == false) // IE4
         document.all.pppIdleTimeLimit.style.visibility = status;
   }
}

function pppDailOnDemandClick(cb) {
   if (cb.checked == true)
      hidePppIdleTimeLimit(0);
   else
      hidePppIdleTimeLimit(1);
}

function frmLoad() {
   with ( document.forms[0] ) {
      if (enblAdvDmz == 1) {
        var enblAdvancedDmz = '<%ejGet(enableAdvancedDmz)%>';
        var nonDmzIpAddr = '<%ejGet(nonDmzIpAddress)%>';
        var nonDmzIpMsk = '<%ejGet(nonDmzIpMask)%>';
        if ( enblAdvancedDmz == '1' )
          enableAdvancedDmz.checked = true;
        else
          enableAdvancedDmz.checked = false;
        nonDmzIpAddress.value = nonDmzIpAddr;
        nonDmzIpMask.value = nonDmzIpMsk;
      }

      showPppoe(0);

      if (cfgL2tpAc == '1' || cfgPptpAc == '1')
         hidePppToBridgeInfo(1);

      if ( enblIpVer != '2' ) {
         if ( enblIpAddr == '1' && (cfgL2tpAc != '1' || cfgPptpAc != '1')) {
            enblPppIpAddress.checked = true;
            hidePppIpAddressInfo(0);
         } else {
            enblPppIpAddress.checked = false;
            hidePppIpAddressInfo(1);
         }

         if ( fullcone == '1' )
            enblFullcone.checked = true;
         else
            enblFullcone.checked = false; 
         fullConeClick(enblFullcone);
      }
      else
      {
         enblPppIpAddress.checked = false;
         enblPppIpAddress.disabled = true;
         hidePppIpAddressInfo(1);
         enblFullcone.disabled = true;
         enblFullcone.checked = false; 
         fullConeClick(enblFullcone);
         pppIpExtension.disabled = true;
      }
 
      if (serviceId == '1' || cfgL2tpAc == '1'  || prtcl == 'PPPoA' || cfgPptpAc == '1')
        hideIpExtension(1);
      else {
        if ( ipExtension == '1' )
           pppIpExtension.checked = true;
        else
           pppIpExtension.checked = false;
      }
      if ( authMethod == '1' )
         pppAuthMethod.selectedIndex = 2;
      else if ( authMethod == '2' )
         pppAuthMethod.selectedIndex = 3;
      else if ( authMethod == '3' )
         pppAuthMethod.selectedIndex = 4;
      else
         pppAuthMethod.selectedIndex = 1;

      pppUserName.value = '<%ejGet(pppUserName)%>';
      // pppPassword.value = '******';
      pppLocalIpAddress.value = localIpAddr;
      if ( prtcl == 'PPPoE' )
         pppServerName.value = '<%ejGet(pppServerName)%>';

      if ( pppShowAuthErrorRetry == '1' )
         hidePppAuthErrorRetry(0);
      else
         hidePppAuthErrorRetry(1);

      if ( pppAuthErrorRetry == '1' )
         authErrorRetry.checked = true;
      else
         authErrorRetry.checked = false;

      if ( pppDebug == '1' )
         enblPppDebug.checked = true;
      else
         enblPppDebug.checked = false;

	  if (pppDemand == '1') {
	  	enblPppDemand.checked = true;
	  	hidePppIdleTimeLimit(0);
  	  }
	  else {
	  	enblPppDemand.checked = false;
	  	hidePppIdleTimeLimit(1);
  	  } 
	  pppIdleTime.value = '<%ejGet(pppIdleTime)%>';
      
      if (prtcl == 'PPPoE') {
         setCheck(pppToBridge, ppptobr);
      }   
      else {
         setCheck(pppToBridge, 0);
      }
      pppIpExtChange(pppIpExtension);

      if ( enblGponWan == '1' ) {
         hideMcastFilterInfo();
         var setMcastFilter = false;
         if (document.getElementById) {  // DOM3 = IE5, NS6
            if (document.getElementById('McastFilter').style.display == 'block') {
               setMcastFilter = true;
            }
         } else if (document.layers == false) { // IE 4
            if (document.all.McastFilter.style.display == 'block') {
               setMcastFilter = true;
            }
         }
         if ( setMcastFilter == true ) {
            var noMcastVlanFlt = '<%ejGet(noMcastVlanFilter)%>';
            if ( noMcastVlanFlt == '1' )
               noMcastVlanFilter.checked = true;
            else
               noMcastVlanFilter.checked = false;
         }
      }

      if ( enblIpVer != '0' ) {
         if ( addr6Type == 'Static' ) {
            enblPppIp6Address.checked = true;
         } else {
            enblPppIp6Address.checked = false;
         }
      
         if ( unnumbered == '1' )
            enblUnnumbered.checked = true;
         else
            enblUnnumbered.checked = false;

         if ( dhcp6cAddress == '1' )
            enblDhcp6cForAddr.checked = true;
         else
            enblDhcp6cForAddr.checked = false;

         if ( dhcp6cPd == '1' )
            enblDhcp6cForPd.checked = true;
         else
            enblDhcp6cForPd.checked = false;

         hideWan6Info(0);
      } else {
         hideWan6Info(1);
      }

      if ( (enblIpVer == '2') || (igmpProxySup == '0') ) {
         showIgmpInfo(0);
         enblIgmpProxy.checked = false;
         enblIgmpMcastSource.checked = false;
      }
      else {
         var enableIgmp = '<%ejGet(enblIgmp)%>';  
         var enableIgmpMcastSource = '<%ejGet(enblIgmpMcastSource)%>';

         if ( enableIgmp == '1' )
            enblIgmpProxy.checked = true;
         else
            enblIgmpProxy.checked = false;
         if ( enableIgmpMcastSource == '1' )
            enblIgmpMcastSource.checked = true;
         else
            enblIgmpMcastSource.checked = false;
         showIgmpInfo(1);
      }
      igmpProxyClicked(enblIgmpProxy);

      if ( (enblIpVer == '0') || (mldProxySup == '0') ) {
         hideMldInfo(1);
         enblMld.checked = false;
         enblMldMcastSource.checked = false;
      }
      else
      {
         var enableMld = '<%ejGet(enblMld)%>';  
         var enableMldMcastSource = '<%ejGet(enblMldMcastSource)%>';
         if ( enableMld == '1' )
            enblMld.checked = true;
         else
            enblMld.checked = false;
         if ( enableMldMcastSource == '1' )
            enblMldMcastSource.checked = true;
         else
            enblMldMcastSource.checked = false;
         hideMldInfo(0);
      }
      mldProxyClicked(enblMld);

      if ( enblPcp == '1' )
      {
         hidePcpInfo(0);
         pcpmode.selectedIndex = 0;
      }
      else
         hidePcpInfo(1);

      maxMtu.value = '<%ejGet(maxMtu)%>';
      if(serviceId == '0')
         maxMtu.value = 1492;       
	  if(cfgL2tpAc == '1')
	  {
         hideNat(1);	 
		 hideFullconeNat(1);
         hidePppToBridgeInfo(1);
		 hide4VPN(1);
	  } else if(cfgPptpAc == '1')
	  {
         hideNat(1);	 
		 hideFullconeNat(1);
         hidePppToBridgeInfo(1);
		 hide4VPN(1);
	  }	  
   }

   Array.prototype.forEach.call(document.querySelectorAll("input.hiddenPassword"),function(e){
      if(e.name == "pppPassword" && serviceId == "0")return;

      e.value = "******";
      e.addEventListener("focus",function(){
         if(this.value == "******"){
            this.value = "";
         }
      })
      e.addEventListener("blur",function(){
         //Notice!!!  it mean that it can't set to empty.
         //if you know it,and still want to set,you can delete the follows.
         if(this.value == ""){
            this.value = "******";
         }
      })
   })
}

function btnNext() {
   var loc = 'ifcgateway.cgi?';

   if (serviceId == '1' || cfgL2tpAc == '1' || cfgPptpAc == '1')
      loc = 'ntwksum2.cgi?';

   with ( document.forms[0] ) {
      // validate user name
      var len = pppUserName.value.length;
      if ( len > 64 ) {
         msg = 'The length of user name (' + len + ') is too long [0-64].';
         alert(msg);
         return;
      }
      // validate password
      len = pppPassword.value.length;
      if ( len > 32 ) {
         msg = 'The length of password (' + len + ') is too long [0-32].';
         alert(msg);
         return;
      }

      if ((enblIpVer != '2') && (enblAdvDmz == 1)) {
        // validate ppp IP address
        if ( enblPppIpAddress.checked == true ) {
           if ( isValidIpAddress(pppLocalIpAddress.value) == false ) {
              alert('Address "' + pppLocalIpAddress.value + '" is invalid IP address.');
              return;
           }
        }
        // validate non DMZ IP address and Netmask
        if ( enableAdvancedDmz.checked == true ) {
           if ( isValidIpAddress(nonDmzIpAddress.value) == false ) {
              alert('Address "' + nonDmzIpAddress.value + '" is invalid IP address.');
              return;
           }
           if ( isValidIpAddress(nonDmzIpMask.value) == false ) {
              alert('Address "' + nonDmzIpMask.value + '" is invalid Netmask.');
              return;
           }
        }
      }
  
      // validate authentication method
      if ( pppAuthMethod.selectedIndex == 0 ) {
         msg = 'No selection for authentication method.';
         alert(msg);
         return;
      }
      // validate server name
      if ( prtcl == 'PPPoE') {
         len = pppServerName.value.length;
         if ( len > 32 ) {
            msg = 'The length of PPP service (' + len + ') is too long [0-32].';
            alert(msg);
            return;
         }
      }

      loc += 'pppUserName=' + encodeUrl(pppUserName.value);

      var skip_pppPassword = pppPassword.value == "******";

      if(supportOpensslAES == 1)
      {
         var Svalue = RndNum(117);
         var encrypt = new JSEncrypt();
         encrypt.setPublicKey('-----BEGIN PUBLIC KEY-----' + PUBLIC_KEY + '-----END PUBLIC KEY-----');
         var encrypted = encrypt.encrypt(Svalue);
         loc += '&rsavalue=' + encodeUrl(encrypted);
		 
         GibberishAES.size(256);
         inpppPassword = GibberishAES.enc(pppPassword.value,Svalue);
         inpppPassword1 = base64encode(inpppPassword.toString());  
         if(!skip_pppPassword)loc += '&pppPassword=' + encodeUrl(inpppPassword1);
      }
      else
      { 
         if(!skip_pppPassword)loc += '&pppPassword=' + encodeUrl(base64encode(pppPassword.value)); 
      }


      if ( enblPppIpAddress.checked == true ) {
         loc += '&useStaticIpAddress=1';
         loc += '&pppLocalIpAddress=' + pppLocalIpAddress.value;
      } else {
         loc += '&useStaticIpAddress=0';
         loc += '&pppLocalIpAddress=' + localIpAddr;
      }
      if ( pppIpExtension.checked == true ) {
         loc += '&pppIpExtension=1&enblNat=0&enblFirewall=0';
         if (enblAdvDmz == '1') {
             if ( enableAdvancedDmz.checked == true ) {
                loc += '&enableAdvancedDmz=1';
                loc += '&nonDmzIpAddress=' + nonDmzIpAddress.value;
                loc += '&nonDmzIpMask=' + nonDmzIpMask.value;
             } else {
                loc += '&enableAdvancedDmz=0';
             }
         }
      }
      else
      {
         loc += '&pppIpExtension=0';

		 if ( enblNat.checked == true )
	        loc += '&enblNat=1';
	     else
	        loc += '&enblNat=0';

		 if ( enblFirewall.checked == true )
	        loc += '&enblFirewall=1';
	     else
	        loc += '&enblFirewall=0';
      }
	  
      if ( enblFullcone.checked == true )
         loc += '&enblFullcone=1';
      else
         loc += '&enblFullcone=0';
      var idx = pppAuthMethod.selectedIndex;
      loc += '&pppAuthMethod=' + pppAuthMethod.options[idx].value;
      if ( prtcl == 'PPPoE')
         loc += '&pppServerName=' + encodeUrl(pppServerName.value);

      if (isNaN(parseInt(maxMtu.value)) == true)
      {
         msg ="MTU " + ' ' + '(' + maxMtu.value + ')' + ' ' + " is not a valid value.";
         alert(msg);
         return;
      }

      var maxMtuNum = parseInt(maxMtu.value);

      if(enblIpVer != '0')         
      {
         if(maxMtuNum < 1280 || maxMtuNum > 1492)
         {
            msg = "MTU " + ' ' + '(' + maxMtu.value + ')' + ' ' +" is out of range [1280-1492].";
            alert(msg);
            return;
         }
      }
      else if (maxMtuNum < 576 || maxMtuNum > 1492)
      {
         msg = "MTU " + ' ' + '(' + maxMtu.value + ')' + ' ' +" is out of range [576-1492].";
         alert(msg);
         return;
      }

      loc += '&maxMtu=' + maxMtuNum;

      if ( authErrorRetry.checked == true )
         loc += '&pppAuthErrorRetry=1';
      else
         loc += '&pppAuthErrorRetry=0';

      if ( enblPppDebug.checked == true )
         loc += '&enblPppDebug=1';
      else
         loc += '&enblPppDebug=0';

      if ( enblPppDemand.checked == true )
         loc += '&enblPppDemand=1';
      else
         loc += '&enblPppDemand=0';

	  if (pppDemand == '1')
	  	loc += '&pppIdleTime=' + pppIdleTime.value;
         
      loc += submitCheck(pppToBridge);

      if ( enblGponWan == '1' ) {
         if ( noMcastVlanFilter.checked == true )
            loc += '&noMcastVlanFilter=1';
         else
            loc += '&noMcastVlanFilter=0';
      }

      if ( enblIpVer != '0' ) {
         if ( enblPppIp6Address.checked == false )
            loc += '&wanAddr6Type=DHCP';   // auto WAN address
         else {
            loc += '&wanAddr6Type=Static';   // static WAN address
            if (pppLocalIp6Address.value != '' && isValidIpAddress6(pppLocalIp6Address.value) == false) {
               alert('Invalid PPP local IPv6 address.');
               return;
            }
            loc += '&wanAddr6=' + pppLocalIp6Address.value;
         }

         if ( enblUnnumbered.checked == true )
            loc += '&unnumberedModel=1';
         else
            loc += '&unnumberedModel=0';

         if ( enblDhcp6cForAddr.checked == true )
            loc += '&dhcp6cForAddr=1';
         else
            loc += '&dhcp6cForAddr=0';

         if ( enblDhcp6cForPd.checked == true )
            loc += '&dhcp6cForPd=1';
         else
            loc += '&dhcp6cForPd=0';
      }

      if (igmpProxySup == '1')
      {
         if ( enblIgmpProxy.checked == true )
            loc += '&enblIgmp=1';
         else
            loc += '&enblIgmp=0';

         if ( enblIgmpMcastSource.checked ) {
             loc += '&enblIgmpMcastSource=1';
         } else {
             loc += '&enblIgmpMcastSource=0';
         }
      }

      if (mldProxySup == '1')
      {
         if ( enblMld.checked == true ) {
            loc += '&enblMld=1';
         } else {
            loc += '&enblMld=0';
         }
         if ( enblMldMcastSource.checked ) {
             loc += '&enblMldMcastSource=1';
         } else {
             loc += '&enblMldMcastSource=0';
         }

      }

      if ( pcpmode.selectedIndex == 1 )
      {
         if ( isValidIpAddress6(pcpServer.value) == false )
         {
            alert('PCP Server of DSLite "' + pcpServer.value + '" is invalid IP address.');
            return;
         }
         else
         {
            loc += '&pcpMode=1';
            loc += '&pcpServer=' + pcpServer.value;
         }
      }
      else if ( pcpmode.selectedIndex == 2 )
      {
         if ( isValidIpAddress(pcpServer.value) == false )
         {
            alert('PCP Server of NAT444 "' + pcpServer.value + '" is invalid IP address.');
            return;
         }
         else
         {
            loc += '&pcpMode=2';
            loc += '&pcpServer=' + pcpServer.value;
         }
      }
      else
         loc += '&pcpMode=0';
   }
   loc += '&sessionKey=' + sessionKey;
   var code = 'location="' + loc + '"';
   
   eval(code);
}

function btnBack() {
   var loc = 'wansrvc.cmd?';
   loc += 'wanL2IfName=' + wanL2If + '&sessionKey=' + sessionKey;

   if (serviceId == '1')
      loc = 'wancfg.html';
   else if (cfgL2tpAc == '1')
      loc = 'cfgl2tpac.html';
   else if (cfgPptpAc == '1')
   	 loc = 'cfgpptpac.html';
 
   var code = 'location="' + loc + '"';
   eval(code);
}

function showIgmpInfo(vis) {
   var status = 'none';

   if ( vis == 1 )
      status = 'block';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('IgmpInfo').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.IgmpInfo.style.display = status;
   }
}


function showPppoe(show) {
   var status = 'block';
   if ( show == 0 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppoeSN').style.display = status;
   else
      document.all.pppoeSN.style.display = status;
}


function hideIpExtension(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('divIpExtension').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.divIpExtension.style.display = status;
   }
}

function hideMcastFilterInfo() {
   var status = 'block';
   with ( document.forms[0] ) {

      if ( enblGponWan == '0') {
         status = 'none';
      }
      if ((document.getElementsByName('enblIgmpMcastSource')[0].checked == false ) && 
          (document.getElementsByName('enblMldMcastSource')[0].checked  == false )) {
         status = 'none';
      }
      if (document.getElementById)  // DOM3 = IE5, NS6
         document.getElementById('McastFilter').style.display = status;
      else {
         if (document.layers == false) // IE 4
            document.all.McastFilter.style.display = status;
      }
   }
}

function igmpProxyClicked(cb) {
   with ( document.forms[0] ) {

      if ( cb.checked == true )
      {
         if (document.getElementsByName)  // DOM3 = IE5, NS6
         {
            document.getElementsByName('enblIgmpMcastSource')[0].checked = true;
            document.getElementsByName('enblIgmpMcastSource')[0].disabled = true;
         }
      else
         {
            if (document.layers == false) // IE 4
               enblIgmpMcastSource.checked = true;
         }
      }
      else
      {
         if (document.getElementsByName)  // DOM3 = IE5, NS6
         {
            document.getElementsByName('enblIgmpMcastSource')[0].disabled = false;
         } 
        else
         {
            if (document.layers == false) // IE 4
               enblIgmpMcastSource.checked = true;
         }
      }
   }
   hideMcastFilterInfo();
}

function mldProxyClicked(cb) {
   with ( document.forms[0] ) {

      if ( cb.checked == true )
      {
         if (document.getElementsByName)  // DOM3 = IE5, NS6
         {
            document.getElementsByName('enblMldMcastSource')[0].checked = true;
            document.getElementsByName('enblMldMcastSource')[0].disabled = true;
         }
         else
         {
            if (document.layers == false) // IE 4
               enblIgmpMcastSource.checked = true;
         }
      }
      else
      {
         if (document.getElementsByName)  // DOM3 = IE5, NS6
         {
            document.getElementsByName('enblMldMcastSource')[0].disabled = false;
         } 
         else
         {
            if (document.layers == false) // IE 4
               enblIgmpMcastSource.checked = true;
         }
      }
   }
   hideMcastFilterInfo();
}

function advancedDmzClick(cb) {
   with ( document.forms[0] ) {
     setDisable(nonDmzIpAddress, cb.checked != true);
     setDisable(nonDmzIpMask, cb.checked != true);
   }
}

function hidePppIpAddressInfo(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppIpAddressInfo').style.display = status;
   else {
      if (document.layers) { // Netscape 4
         if ( hide == 1 )
            document.forms[0].pppLocalIpAddress.value = '';
         else
            document.forms[0].pppLocalIpAddress.value = '<%ejGet(pppLocalIpAddress)%>';
      } else  // IE 4
         document.all.pppIpAddressInfo.style.display = status;
   }
}

function pppIpAddressClick(cb) {
   if ( cb.checked == true )
      hidePppIpAddressInfo(0);
   else
      hidePppIpAddressInfo(1);
}

function hidePppIp6AddressInfo(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppIp6AddressInfo').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.pppIp6AddressInfo.style.display = status;
   }
}

function pppIp6AddressClick() {
   with ( document.forms[0] ) {
      pppLocalIp6Address.value = addr6;
      if ( enblPppIp6Address.checked == true ) {
         pppLocalIp6Address.value = addr6;
         hidePppIp6AddressInfo(0);
      }
      else {
         pppLocalIp6Address.value = '';
         hidePppIp6AddressInfo(1);
      }
   }
}

function hideWan6Info(hide) {
   var status = 'block';

   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('wan6Info').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.wan6Info.style.display = status;
   }

      pppIp6AddressClick();
}

function hideMldInfo(hide) {
   var status = 'block';

   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('MldInfo').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.MldInfo.style.display = status;
   }
}

function disableWan4Info() {
   with ( document.forms[0] ) {
      enblFullcone.disabled = 1;
      enblOnDemand.disabled = 1;
      pppIpExtension.disabled = 1
      enblPppIpAddress.disabled = 1
      enblIgmpProxy.disabled = 1
   }
}
function hidePppToBridgeInfo(hide) {
   var status = 'block';

   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('divPppToBridge').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.divPppToBridge.style.display = status;
   }
}

function hidePppAuthErrorRetry(hide) {
   var status = 'block';

   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppAuthErrorInfo').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.pppAuthErrorInfo.style.display = status;
   }
}

function pppIpExtChange(item) {
        if ( item.checked == true ) {
            with ( document.forms[0] ) {
              if (enblAdvDmz == '1') {
                setDisable(enableAdvancedDmz, 0);
                setDisable(nonDmzIpAddress, enableAdvancedDmz.checked != true);
                setDisable(nonDmzIpMask, enableAdvancedDmz.checked != true);
              }
            }
        } else {
            with ( document.forms[0] ) {
              if (enblAdvDmz == '1') {				
                setDisable(enableAdvancedDmz,1);
                setDisable(nonDmzIpAddress,1);
                setDisable(nonDmzIpMask,1);
              }
            }
        }

        if (enetWan == '1' || prtcl != 'PPPoE' || item.checked == true)  {
            showhide("divPppToBridge", 0);
        }
        else {
            showhide("divPppToBridge", 1);
        }

		with ( document.forms[0] ) {
			if (item.checked == true)  {
				enblNat.checked = false;
				enblFirewall.checked = false;
				natClick(enblNat);
				hideNat(1);
	        }
	        else {
				hideNat(0);
				if ( nat == '1' ) 
		           enblNat.checked = true;
				else
				   enblNat.checked = false;

				natClick(enblNat);

				if ( firewall == '1' )
		           enblFirewall.checked = true;
				else
				   enblFirewall.checked = false;
	        }
		}
}

function hideFullConeWarning(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';

   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('fullConeWarning').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.fullConeWarning.style.display = status;
   }
}

function fullConeClick(cb)
{
   if (!cb.checked)
      hideFullConeWarning(1);
   else
   	  hideFullConeWarning(0);
}

function hideFullconeNat(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('fullconeNatInfo').style.display = status;
   else {
      if (document.layers) { // Netscape 4
         if ( hide == 1 )
            document.forms[0].enblFullcone.value = '';
         else
            document.forms[0].enblFullcone.value = '<%ejGet(enblFullcone)%>';
      } else  // IE 4
         document.all.fullconeNatInfo.style.display = status;
   }
}

function hideNat(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('natInfo').style.display = status;
   else {
      if (document.layers) { // Netscape 4
         if ( hide == 1 )
            document.forms[0].enblNat.value = '';
         else
            document.forms[0].enblNat.value = '<%ejGet(enblNat)%>';
      } else  // IE 4
         document.all.fullconeNatInfo.style.display = status;
   }
}

function hide4VPN(hide) {
   var status = 'block';
   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('IgmpInfo').style.display = status;
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('McastFilter').style.display = status;
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('static_ipv4_address').style.display = status;
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('ppp_debug').style.display = status;   
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('MldInfo').style.display = status;     
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppoeSN').style.display = status;
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppoe_sn2').style.display = status;   
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('mtuControl').style.display = status;
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pppAuthMethod2').style.display = status;      
}

function natClick(cb) {
   with ( document.forms[0] ) {
	   if ( cb.checked == true )
	   {
	      hideFullconeNat(0);
	      if ( fullcone == '1' )
	         enblFullcone.checked = true;
	      else
	         enblFullcone.checked = false;
	      fullConeClick(enblFullcone);
	   }
	   else
	   {
	      enblFullcone.checked = false;
	      fullConeClick(enblFullcone);
		  hideFullconeNat(1);
	   }
   	}
}

function hidePcpInfo(hide) {
   var status = 'block';

   if ( hide == 1 )
      status = 'none';
   if (document.getElementById)  // DOM3 = IE5, NS6
      document.getElementById('pcpInfo').style.display = status;
   else {
      if (document.layers == false) // IE4
         document.all.pcpInfo.style.display = status;
   }
}

function displayWarning() {
	if(supportBuildWarning == "0")
		return;
	with ( document.forms[0] ) {
		if(enblFirewall.checked == false) {
			var tempValue = confirm("Firewall is disabled, are you sure applying it?");
			if(tempValue == false)
			{
				enblFirewall.checked = true;
				return;
			}
		}
	}
}

// done hiding -->
</script>
   </head>
   <body onLoad='frmLoad()'>
      <blockquote>
         <form>
            <b>PPP Username and Password</b><br>
            <br>
            PPP usually requires that you have a user name and password to establish your 
            connection. In the boxes below, enter the user name and password that your ISP 
            has provided to you.<br>
            <br>
            <div id='pppoeSN'>
               <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
                     <td width="150">PPPoE Service Name:</td>
                     <td>
                        <b><%ejGetOther(memInfo, pppoeServiceName)%></b>
                     </td>
                  </tr>
                  <br>
               </table>
            </div>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td>PPP Username:&nbsp;&nbsp;</td>
                  <td><input type='text' name='pppUserName'></td>
               </tr>
               <tr>
                  <td>PPP Password:&nbsp;&nbsp;</td>
                  <td><input type='password' name='pppPassword' class="hiddenPassword"></td>
               </tr>
<script language="javascript">
<!-- hide
if ( prtcl == 'PPPoE') {
   document.writeln("               <tr id='pppoe_sn2'>");
   document.writeln("                  <td>PPPoE Service Name:&nbsp;&nbsp;</td>");
   document.writeln("                  <td><input type='text' name='pppServerName'></td>");
   document.writeln("               </tr>");
}
// done hiding -->
</script>
               <tr id='pppAuthMethod2'>
                  <td>Authentication Method:&nbsp;&nbsp;</td>
                  <td><select name='pppAuthMethod' size="1">
                        <option value="-1">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
                        <option value="0">AUTO
                        <option value="1">PAP
                        <option value="2">CHAP
                        <option value="3">MSCHAP
                     </select></td>
               </tr>
               <tr id='mtuControl'>
<script language="javascript">
<!-- hide
                  if(enblIpVer != '0')
                  {
                     document.writeln("<td id='pppoe_mtu'>MTU[1280-1492]:&nbsp;&nbsp;</td>");
                  }
                  else
                  {
                     document.writeln("<td id='pppoe_mtu'>MTU[576-1492]:&nbsp;&nbsp;</td>");                     
                  }                  
// done hiding -->
</script>                  
                  <td><input type='text' name='maxMtu'></td>
               </tr>               
            </table>
              <br>
              <div id='natInfo'>
		           <table border="0" cellpadding="0" cellspacing="0">
	                 <tr>
	                   <td width='30' height="30"><input type='checkbox' name='enblNat' onClick='natClick(this)'></td>
		      <td id='enblNatItem'>Enable NAT</td>
	               	 </tr>
		          </table>
		      </div>
              <div id='fullconeNatInfo'>
	              <table border="0" cellpadding="0" cellspacing="0">
	                <tr>
	                  <td width='30' height="30"><input type='checkbox' name='enblFullcone' onClick='fullConeClick(this)'></td>
	                  <td>Enable Fullcone NAT</td>
	                </tr>
	              </table>
	          </div>
              <div id='fullConeWarning'>
                  <table border="0" cellpadding="0" cellspacing="0">
                     <td <font color='red'>&nbsp;&nbsp;&nbsp;ONLY IF REQUIRED -- DISABLES SOME SECURITY</font></td>
		          </table>
              </div>
             <div id='firewallInfo'>
                  <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                    <td width='30' height="30"><input type='checkbox' name='enblFirewall' onClick="displayWarning()"></td>
                    <td id='enableFirewall'>Enable Firewall</td>
                    </tr>
                  </table>
              </div>
            <div id='divIpExtension' style='display:none'>                     
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='pppIpExtension' onClick='pppIpExtChange(this)'></td>
                <td>PPP IP extension</td>
              </tr>
              </table>
            </div>
<script language="javascript">
<!-- hide
if (enblAdvDmz == '1')
{      
   document.writeln("<div id='advancedDmzInfo'>");
   document.writeln("<table border='0' cellpadding='0' cellspacing='0'>");
   document.writeln("<tr>");
   document.writeln("<td width='30' height='30'><input type='checkbox' name='enableAdvancedDmz' onClick='advancedDmzClick(this)'></td>");
   document.writeln("<td>Advanced DMZ</td>");
   document.writeln("</tr>");
   document.writeln("</table>");

   document.writeln("</div>");
   document.writeln("<div id='nonDmzIpAddressInfo'>");
   document.writeln("<table border='0' cellpadding='0' cellspacing='0'>");
   document.writeln("<tr>");
   document.writeln("<td width='140'>Non DMZ IP Address:&nbsp;&nbsp;</td>");
   document.writeln("<td><input type='text' name='nonDmzIpAddress'></td>");
   document.writeln("</tr>");
   document.writeln("<tr>");
   document.writeln("<td width='140'>Non DMZ Net Mask:&nbsp;&nbsp;</td>");
   document.writeln("<td><input type='text' name='nonDmzIpMask'></td>");
   document.writeln("</tr>");
   document.writeln("</table>");
   document.writeln("<br>");
   document.writeln("</div>");
}
// done hiding -->
</script>
             <div id="static_ipv4_address">
              <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblPppIpAddress' onClick='pppIpAddressClick(this)'></td>
                <td>Use Static IPv4 Address</td>
              </tr>
            </table>
            </div>
            <div id='pppIpAddressInfo'>
              <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="160">IPv4 Address:&nbsp;&nbsp;</td>
                <td><input type='text' name='pppLocalIpAddress'></td>
              </tr>
            </table>
            
            </div>
            <div id='wan6Info'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblPppIp6Address' onClick='pppIp6AddressClick()'></td>
                <td>Use Static IPv6 Address</td>
              </tr>
            </table>
            <div id='pppIp6AddressInfo'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="160">IPv6 Address:&nbsp;&nbsp;</td>
                <td><input type='text' name='pppLocalIp6Address'></td>
              </tr>
            </table>
            </div>
            <div id='UnnumberedInfo'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblUnnumbered'></td>
                <td>Enable IPv6 Unnumbered Model</td>
              </tr>
            </table>
            </div>
            <div id='Dhcp6cAddr'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblDhcp6cForAddr'></td>
                <td>Launch Dhcp6c for Address Assignment (IANA)</td>
              </tr>
            </table>
            </div>
            <div id='Dhcp6cPd'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblDhcp6cForPd'></td>
                <td>Launch Dhcp6c for Prefix Delegation (IAPD)</td>
              </tr>
            </table>
            </div>
            </div>
            <div id='pppAuthErrorInfo'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='authErrorRetry'></td>
                <td>Retry PPP password on authentication error</td>
              </tr>
            </table></div>
            <div id='ppp_debug'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblPppDebug'></td>
                <td>Enable PPP Debug Mode</td>
              </tr>
            </table>
            </div>
            <table border="0" cellpadding="0" cellspacing="0" style='display:none'>
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblPppDemand' onClick='pppDailOnDemandClick(this)'></td>
                <td>Enable PPP Dial-On-Demand</td>
              </tr>
            </table>
            <div id='pppIdleTimeLimit'>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="150">Idle Time:</td>
                <td><input type='text' name='pppIdleTime'></td>
              </tr>
            </table>
            </div>
            <div id = 'divPppToBridge'><table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='pppToBridge'></td>
                <td>Bridge PPPoE Frames Between WAN and Local Ports </td>
              </tr>
            </table></div>

            <div id='pcpInfo'>
            
            <td>Port Control Protocol Mode</td>
            <table border="0" cellpadding="0" cellspacing="0">
                <select name='pcpmode'>
                    <option value="0"> Disable </option>
                    <option value="1"> DS-Lite </option>
                    <option value="2"> NAT444  </option>
                </select>
            </table>

            <table border="0" cellpadding="0" cellspacing="0"> 
               <tr>
                  <td>PCP Server</td>
                  <td width='30' height="30"><input type='text' name='pcpServer'></td>
               </tr>
            </table>
            </div>

            <div id='IgmpInfo'>
            <br><br><b>IGMP Multicast</b><br>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width='30' height="30"><input type='checkbox' name='enblIgmpProxy' onClick='igmpProxyClicked(this)'></td>
                  <td>Enable IGMP Multicast Proxy</td>
               </tr>
            </table>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width='30' height="30"><input type='checkbox' name='enblIgmpMcastSource' onClick='hideMcastFilterInfo()'></td>
                  <td>Enable IGMP Multicast Source</td>
               </tr>
            </table>
            </div>
            <div id='McastFilter'>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width='30' height="30"><input type='checkbox' name='noMcastVlanFilter'></td>
                  <td>No Multicast VLAN Filter</td>
               </tr>
            </table>
            </div>
            <div id='MldInfo'>
            <br><br><b>MLD Multicast</b><br>
            <table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width='30' height="30"><input type='checkbox' name='enblMld' onClick='mldProxyClicked(this)'></td>
                <td>Enable MLD Multicast Proxy</td>
              </tr>
            </table>
            <table border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width='30' height="30"><input type='checkbox' name='enblMldMcastSource' onClick='hideMcastFilterInfo()'></td>
                  <td>Enable MLD Multicast Source</td>
               </tr>
            </table>
            </div>
            <center>
               <input type='button' onClick='btnBack()' value='Back'> <input type='button' onClick='btnNext()' value='Next'>
            </center>
         </form>
      </blockquote>
   </body>
</html>
