http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / userapps / broadcom / cfm / html / lancfg2.html
index 05c4047..7dfcc0c 100755 (executable)
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<!--
-       (c) 2005 U.S. Robotics Corporation
--->
 <html>
-<head>
-       <title>LAN &raquo; DHCP Server</title>
-
-       <link href="usr_main.css" rel="stylesheet" type="text/css">
-       <link href="usr_menus.css" rel="stylesheet" type="text/css"><script src="usr_menus.js" type="text/javascript"></script><script src="usr_menus_build.js" type="text/javascript"></script>
-       <script src="usr_common.js" type="text/javascript"></script>
-
-       <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
-
-       <script type="text/javascript" src="util.js"></script>
-       <script type="text/javascript">
+   <head>
+      <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
+      <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
+      <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">
 <!-- hide
-setPageTitle("<%ejGetWlJS(wlInterface)%>");
-
-var state = '<%ejGetJS(lanRefresh)%>';
-if ( state == '1' ) {
-   var code = 'location = "lancfg2.cgi?lanRefresh=0"';
-   eval(code);
-}
-
-var dhcpStart = '<%ejGetJS(dhcpEthStart)%>';
-var dhcpEnd = '<%ejGetJS(dhcpEthEnd)%>';
-var dhcpLease = '<%ejGetJS(dhcpLeasedTime)%>';
-var proto = '<%ejGetOther(sysInfo, noBrPrtcl)%>';
-var ipExt = '<%ejGetOther(sysInfo, pppIpExtension)%>';
-var dhcpEnbl = '<%ejGetJS(enblDhcpSrv)%>';
+parent.helpframe.location.href="hlplansetup.html";
+var randomNum = '<%ejGet(CheckNum)%>';
+var lanIpAddr='<%ejGet(ethIpAddress)%>';
+var lanSubMask='<%ejGet(ethSubnetMask)%>';
+var lan2Status='<%ejGet(enblLan2)%>';
+var lan2IpAddr='<%ejGet(lan2IpAddress)%>';
+var lan2SubMask='<%ejGet(lan2SubnetMask)%>';
+var old_lan2status;
+var BridgeOnly = '<%ejGetOther(sysInfo, PrtclBridgeOnly)%>';
+var hostname='<%ejGet(hostname)%>';
+var domainname='<%ejGet(domainname)%>';
+var lanmtu = '<%ejGet(lanmtu)%>';
+var includemtu = '<%ejGetOther(sysInfo, includemtu)%>';
+var dhcpStart = '<%ejGet(dhcpEthStart)%>';
+var dhcpEnd = '<%ejGet(dhcpEthEnd)%>';
+var dhcpLease = '<%ejGet(dhcpLeasedTime)%>';
+var old_Leasetime=dhcpLease;
+var nat = '<%ejGet(enblNat)%>';
+var dhcpEnbl = '<%ejGet(enblDhcpSrv)%>';
 var natEnbl = '<%ejGetOther(sysInfo, enblNat)%>';
-var enblUpnp = '<%ejGetJS(enblUpnp)%>';
-var enblIgmpSnp = '<%ejGetJS(enblIgmpSnp)%>';
-var buildUpnp = '<%ejGetOther(sysInfo, buildUpnp)%>';
-var enblStp = '<%ejGetJS(enblStp)%>';
-
-function hideStpInfo(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('idStp').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.idStp.style.visibility = status;
-   }
-}
-
-function hideUpnpInfo(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('upnpInfo').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.upnpInfo.style.visibility = status;
-   }
+var old_DhcpStatus;
+var DD;
+var HH;
+var MM;
+
+//for DHCP start
+function viewList(){\r
+  window.open("viewdhcprelist.html","","width=470, height=300, scrollbars=yes");\r
+}\r
+\r
+function showDhcpInfo(){\r
+       document.getElementById('DhcpInfo').innerHTML =\r
+               '<table width="570" border="0" cellspacing="0" cellpadding="0" height="96">'+\r
+               '<tr>'+\r
+               '<td width="195" height="30"><input type="radio" name="dhcpser" id="dhcpenable" onClick="radiobut()">&nbsp;DHCP Server On</td>'+\r
+               '<td width="75" height="30" name="startipstr" id="startipstr">Start IP: </td>'+\r
+               '<td width="280" height="30" align="left">&nbsp;'+\r
+               '<input type="text" name="startIp" id="startIp" size="20"></td>'+\r
+               '</tr>'+\r
+               '<tr>'+\r
+               '<td width="195" height="30">&nbsp;</td>'+\r
+               '<td width="75" height="30" name="endipstr" id="endipstr">End IP: </td>'+\r
+               '<td width="280" height="30">&nbsp;<input type="text" name="endIp" id="endIp" size="20"></td>'+\r
+               '</tr>'+\r
+               '<tr>'+\r
+               '<td width="195" height="30">&nbsp;</td>'+\r
+               '<td width="75" height="30" name="leasetimestr" id="leasetimestr">Lease Time:&nbsp; </td>'+\r
+               '<td width="280" height="30" name="dhmstr" id="dhmstr">&nbsp;<input type="text" name="time_dd" id="time_dd" size="3">&nbsp;'+\r
+               'days&nbsp; <input type="text" name="time_hh" id="time_hh" size="2">&nbsp; hours&nbsp;'+\r
+               '<input type="text" name="time_mm" id="time_mm" size="2">&nbsp; minutes</td>'+\r
+               '</tr>'+\r
+               '<tr>'+\r
+               '<td width="195" height="33">&nbsp;</td>'+\r
+               '<td width="85" height="33">&nbsp;</td>'+\r
+               '<td width="280" height="33">&nbsp;'+\r
+               '<input type="button" value="Reserved IP Address List" name="resbut" id="resbut" onClick="viewList()"></td>'+\r
+               '</tr>'+\r
+               '<tr>'+\r
+               '<td width="550" height="42" colspan="3">'+\r
+               '<table width="550" border="0" cellspacing="0" cellpadding="0" height="42">'+\r
+               '<tr>'+\r
+               '<td><input type="radio" name="dhcpser" id="dhcprelay" onClick="radiobut()"> Relay On</td>'+\r
+               '<td name="relaystr" id="relaystr">&nbsp;Relay to Server IP:</td>'+\r
+               '<td><input type="text" name="relayIp" id="relayIp" size="20"></td>'+\r
+               '</tr>'+\r
+               '</table>'+\r
+               '</td></tr>'+\r
+               '<tr>'+\r
+               '<td width="550" height="30" colspan="3" align="left">'+\r
+               '<input type="radio" name="dhcpser" id="dhcpdisable" onClick="radiobut()"> Server and Relay Off</td>'+\r
+               '</tr>'+\r
+               '</table>';\r
+}\r
+\r
+function setvalue(){\r
+       if (document.getElementById("dhcpenable").checked==true){\r
+               document.getElementById("dhcpenable").checked=true;\r
+               document.getElementById("dhcprelay").checked=false;\r
+               document.getElementById("dhcpdisable").checked=false;\r
+               document.getElementById("startipstr").style.color="#000000";\r
+               document.getElementById("endipstr").style.color="#000000";\r
+               document.getElementById("leasetimestr").style.color="#000000";\r
+               document.getElementById("dhmstr").style.color="#000000";\r
+               document.getElementById("relaystr").style.color="#666666";\r
+               document.getElementById("startIp").disabled=false;\r
+               document.getElementById("endIp").disabled=false;\r
+               document.getElementById("time_dd").disabled=false;\r
+               document.getElementById("time_hh").disabled=false;\r
+               document.getElementById("time_mm").disabled=false;\r
+               document.getElementById("resbut").disabled=false;\r
+               document.getElementById("relayIp").disabled=true;\r
+       } else if (document.getElementById("dhcprelay").checked==true){\r
+               document.getElementById("dhcpenable").checked=false;\r
+               document.getElementById("dhcprelay").checked=true\r
+               document.getElementById("dhcpdisable").checked=false;\r
+               document.getElementById("startipstr").style.color="#666666";\r
+               document.getElementById("endipstr").style.color="#666666";\r
+               document.getElementById("leasetimestr").style.color="#666666";\r
+               document.getElementById("dhmstr").style.color="#666666";\r
+               document.getElementById("relaystr").style.color="#000000";\r
+               document.getElementById("startIp").disabled=true;\r
+               document.getElementById("endIp").disabled=true;\r
+               document.getElementById("time_dd").disabled=true;\r
+               document.getElementById("time_hh").disabled=true;\r
+               document.getElementById("time_mm").disabled=true;\r
+               document.getElementById("resbut").disabled=true;\r
+               document.getElementById("relayIp").disabled=false;\r
+       } else {\r
+               document.getElementById("dhcpenable").checked=false;\r
+               document.getElementById("dhcprelay").checked=false;\r
+               document.getElementById("dhcpdisable").checked=true;\r
+               document.getElementById("startipstr").style.color="#666666";\r
+               document.getElementById("endipstr").style.color="#666666";\r
+               document.getElementById("leasetimestr").style.color="#666666";\r
+               document.getElementById("dhmstr").style.color="#666666";\r
+               document.getElementById("relaystr").style.color="#666666";\r
+               document.getElementById("startIp").disabled=true;\r
+               document.getElementById("endIp").disabled=true;\r
+               document.getElementById("time_dd").disabled=true;\r
+               document.getElementById("time_hh").disabled=true;\r
+               document.getElementById("time_mm").disabled=true;\r
+               document.getElementById("resbut").disabled=true;\r
+               document.getElementById("relayIp").disabled=true;\r
+}\r
+       document.getElementById("startIp").value=dhcpStart;\r
+       document.getElementById("endIp").value=dhcpEnd;\r
+               dhcpLease=old_Leasetime;\r
+               DD = Math.floor(dhcpLease/86400);\r
+               dhcpLease%=86400;\r
+               HH = Math.floor(dhcpLease/3600);\r
+               dhcpLease%=3600;\r
+               MM = Math.floor(dhcpLease/60);\r
+       document.getElementById("time_dd").value=DD;\r
+       document.getElementById("time_hh").value=HH;\r
+       document.getElementById("time_mm").value=MM;\r
+       document.getElementById("relayIp").value=dhcpStart;\r
+               old_DhcpStatus = dhcpEnbl;\r
+       }\r
+\r
+function radiobut(){\r
+       setvalue();\r
 }
-
-function hideIgmpSnpInfo(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('IGMPSnooping').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.iIGMPSnooping.style.visibility = status;
-   }
-}
-
-function hideDhcpInfo(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('dhcpInfo').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.dhcpInfo.style.visibility = status;
-   }
-}
-
-function disableDhcpSrv() {
-   with ( document.forms[0] ) {
-      dhcpSrvType[1].checked = false;
-      dhcpEthStart.disabled = 1;
-      dhcpEthEnd.disabled = 1;
-      dhcpLeasedTime.value = '';
-      dhcpLeasedTime.disabled = 1;
-   }
-}
-
-function enableDhcpSrv(formLoad) {
-   with ( document.forms[0] ) {
-      dhcpSrvType[1].checked = true;
-      dhcpEthStart.disabled = 0;
-      dhcpEthEnd.disabled = 0;
-      if (formLoad == 0)
-         setDhcpAddresses(ethIpAddress.value);
-      else {
-         dhcpEthStart.value = dhcpStart;
-         dhcpEthEnd.value = dhcpEnd;
-      }
-      dhcpLeasedTime.value = dhcpLease;
-      dhcpLeasedTime.disabled = 0;
-   }
-}
-
-function hideRelayInfo(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('relayInfo').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.relayInfo.style.visibility = status;
-   }
-}
-
-function disableDhcpSrvRelay() {
-   with ( document.forms[0] ) {
-      dhcpSrvType[2].checked = false;
-      dhcpSrvAddr.disabled = 1;
-   }
-}
-
-function enableDhcpSrvRelay() {
-   with ( document.forms[0] ) {
-      dhcpSrvType[2].checked = true;
-      if (dhcpEthStart.value != "")
-         dhcpSrvAddr.value = dhcpEthStart.value;
-      else
-         dhcpSrvAddr.value = dhcpStart;
-      dhcpSrvAddr.disabled = 0;
-   }
-}
-
-function typeClick() {
-   with ( document.forms[0] ) {
-      // if any protocol has NAT enabled then
-      // don't show DHCP relay
-      if ( natEnbl == '1' ) {
-         if ( dhcpSrvType[0].checked == true )
-            disableDhcpSrv();
-         else
-            enableDhcpSrv(0);
-      } else {
-         if ( dhcpSrvType[0].checked == true ) {
-            disableDhcpSrv();
-            disableDhcpSrvRelay();
-         } else if ( dhcpSrvType[1].checked == true ) {
-            enableDhcpSrv(0);
-            disableDhcpSrvRelay();
-         } else {
-            enableDhcpSrvRelay();
-            disableDhcpSrv();
-         }
-      }
-   }
-}
-
-function frmLoad() {
-   with ( document.forms[0] ) {
-      ethIpAddress.value = '<%ejGetJS(ethIpAddress)%>';
-      ethSubnetMask.value = '<%ejGetJS(ethSubnetMask)%>';
-
-      if ( natEnbl == '1' && buildUpnp == '1' ) {
-         if ( enblUpnp == '1' )
-            chkUpnp.checked = true;
-         else
-            chkUpnp.checked = false;
-         hideUpnpInfo(0);
-      } else
-         hideUpnpInfo(1);
-
-      if ( enblIgmpSnp == '1' )
-        chkIgmpSnp.checked = true;
-      else
-        chkIgmpSnp.checked = false;
-      hideIgmpSnpInfo(0);
-
-
-      // if protocol is Bridge or PPP IP extension
-      // then don't show DHCP info
-      if (proto == 'Bridge' || ipExt == '1')
-         hideDhcpInfo(1);
-      else {
-         hideDhcpInfo(0);
-         // if any protocol has NAT enabled then
-         // don't show DHCP relay
-         if ( natEnbl == '1' ) {
-            hideRelayInfo(1);
-            if ( dhcpEnbl == '1' )
-               enableDhcpSrv(1);
-            else {
-               dhcpSrvType[0].checked = true;
-               disableDhcpSrv();
-            }
-         } else {
-            hideRelayInfo(0);
-            if ( dhcpEnbl == '1' ) {
-               enableDhcpSrv(1);
-               disableDhcpSrvRelay();
-            } else if ( dhcpEnbl == '2' ) {
-               enableDhcpSrvRelay();
-               disableDhcpSrv();
-            } else {
-               dhcpSrvType[0].checked = true;
-               disableDhcpSrv();
-               disableDhcpSrvRelay();
-            }
-         }
-         lan2IpAddress.value = '<%ejGetJS(lan2IpAddress)%>';
-         lan2SubnetMask.value = '<%ejGetJS(lan2SubnetMask)%>';
-         if ('<%ejGetJS(enblLan2)%>' == '1') {
-            enblLan2.checked = true;
-            hideLan2Info(0);
-         } else {
-            enblLan2.checked = false;
-            hideLan2Info(1);
+//DHCP end
+
+
+function showlan2(){
+  with(document.forms[0]){
+      if(enblLan2.checked==true){
+          document.getElementById('displaylan2').innerHTML ='<table border="0" cellpadding="0" cellspacing="0">'+
+                    '<tr>'+
+                     '<td width="150">Secondary IP Address:</td>'+
+                     '<td><input type="text" name="lan2IpAddress"></td>'+
+                     '</tr>'+
+                     '<tr>'+
+                     '<td>Subnet Mask:</td>'+
+                     '<td><input type="text" name="lan2SubnetMask"></td>'+
+                     '</tr>'+
+                     '</table>'+
+                     '<br>';
+         if (lan2IpAddr == '0.0.0.0'){
+               lan2IpAddr = '';
+               lan2SubMask = '';
          }
+         lan2IpAddress.value = lan2IpAddr;
+         lan2SubnetMask.value = lan2SubMask;
+      } else {
+        document.getElementById('displaylan2').innerHTML = '';
       }
-      if (enblStp == '1')
-         chkStp.checked = true;
-      else 
-         chkStp.checked = false; 
-   }
-}
-
-function hideLan2Info(hide) {
-   var status = 'visible';
-
-   if ( hide == 1 )
-      status = 'hidden';
-   if (document.getElementById)  // DOM3 = IE5, NS6
-      document.getElementById('lan2Info').style.visibility = status;
-   else {
-      if (document.layers == false) // IE4
-         document.all.lan2Info.style.visibility = status;
-   }
+  }
 }
 
-function lan2CbClick(cb) {
-   if ( cb.checked == true )
-      hideLan2Info(0);
-   else
-      hideLan2Info(1);
+function showLanMTUInfo(){
+       with ( document.forms[0] ) {
+               document.getElementById('LanMtuInfo').innerHTML =
+                       '<table border="0" cellspacing="0" cellpadding="0" height="30">'+
+                       '<tr>'+
+                       '<td width="150" height="30">MTU:</td>'+
+                       '<td height="30"><input type="text" name="lmtu" id="mtu" size="5"> (Default: 1500)</td>'+
+                       '</tr>'+
+                       '</table>';
+                       
+                       lmtu.value=lanmtu;
+       }
 }
 
-function isEndGTEStart(EndIp, StartIp)
-{
-   addrEnd = EndIp.split('.');
-   addrStart = StartIp.split('.');
-   E = parseInt(addrEnd[3]) + 1;
-   S = parseInt(addrStart[3]) + 1;
-   if (E < S) 
-      return false;
-   return true;
+function frmLoad() {
+       with ( document.forms[0] ) {
+               ethIpAddress.value = lanIpAddr;
+               ethSubnetMask.value = lanSubMask;
+               hname.value=hostname;
+               dname.value=domainname;
+
+               if ( BridgeOnly == '0' ){
+                       if (lan2Status == '1') {
+                               enblLan2.checked = true;
+                               showlan2();
+                               old_lan2status=true;
+                       } else {
+                               enblLan2.checked = false;
+                               showlan2();
+                               old_lan2status=false;
+                       }
+               }
+               if (includemtu == '1')
+                       showLanMTUInfo();
+
+               //for DHCP start
+               showDhcpInfo();\r
+               if (dhcpEnbl == '1'){\r
+                       document.getElementById("dhcpenable").checked=true;\r
+                       document.getElementById("dhcprelay").checked=false;\r
+                       document.getElementById("dhcpdisable").checked=false;\r
+               } else if (dhcpEnbl == '2'){\r
+                       document.getElementById("dhcpenable").checked=false;\r
+                       document.getElementById("dhcprelay").checked=true;\r
+                       document.getElementById("dhcpdisable").checked=false;\r
+               } else {\r
+                       document.getElementById("dhcpenable").checked=false;\r
+                       document.getElementById("dhcprelay").checked=false;\r
+                       document.getElementById("dhcpdisable").checked=true;\r
+               }\r
+               setvalue();
+               //DHCP end
+       }
+
+       if (<%ejGet(changeset)%> == 1){
+               parent.footerfrm.location.href="footer.html";
+       }
 }
 
-function btnApply(reboot) {
-   var loc = 'lancfg2.cgi?';
-
-   if (reboot)
-      loc = 'lancfg2Reset.cgi?';
-
-   with ( document.forms[0] ) {
-      if ( isValidIpAddress(ethIpAddress.value) == false ) {
-         alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
-         return;
-      }
-      if ( isValidIpAddress(ethSubnetMask.value) == false ) {
-         alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
-         return;
-      }
-      loc += 'ethIpAddress=' + ethIpAddress.value;
-      loc += '&ethSubnetMask=' + ethSubnetMask.value;
-      if ( buildUpnp == '1' ) {
-         if ( chkUpnp.checked == true )
-            loc += '&enblUpnp=1';
-         else
-            loc += '&enblUpnp=0';
-      }
-      if ( chkStp.checked == true )
-         loc += '&enblStp=1';
-      else
-         loc += '&enblStp=0';
-      
-     if ( chkIgmpSnp.checked == true )
-        loc += '&enblIgmpSnp=1';
-     else
-        loc += '&enblIgmpSnp=0';
-      if ( dhcpSrvType[1].checked == true ) {
-         if (isValidIpAddress(dhcpEthStart.value) == false || 
-               !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthStart.value, ethSubnetMask.value))) {
-            alert('Start IP address "' + dhcpEthStart.value + '" is invalid IP address.');
-            return;
-         }
-         if ( isValidIpAddress(dhcpEthEnd.value) == false ||
-               !(isSameSubNet(ethIpAddress.value, ethSubnetMask.value, dhcpEthEnd.value, ethSubnetMask.value))) {
-            alert('End IP address "' + dhcpEthEnd.value + '" is invalid IP address.');
-            return;
-         }   
-         if (!(isEndGTEStart(dhcpEthEnd.value, dhcpEthStart.value))) {
-            alert("End ip has to be equal or greater than Start Ip address.");
-            return;
-         }
-         if ( isNaN(dhcpLeasedTime.value) == true || dhcpLeasedTime.value <= 0) {
-            alert('Leased time "' + dhcpLeasedTime.value + '" is invalid.');
-            return;
-         }
-         loc += '&dhcpEthStart=' + dhcpEthStart.value;
-         loc += '&dhcpEthEnd=' + dhcpEthEnd.value;
-         loc += '&dhcpLeasedTime=' + dhcpLeasedTime.value;
-         loc += '&enblDhcpSrv=1';
-      } else {
-         if ( natEnbl == '1' )
-            loc += '&enblDhcpSrv=0';
-         else {
-            if ( dhcpSrvType[2].checked == true ) {
-               if ( isValidIpAddress(dhcpSrvAddr.value) == false ) {
-                  alert('DHCP server IP address "' + dhcpSrvAddr.value + '" is invalid IP address.');
-                  return;
-               }
-               loc += '&dhcpEthStart=' + dhcpSrvAddr.value;
-               loc += '&enblDhcpSrv=2';
-            } else
-               loc += '&enblDhcpSrv=0';
-         }
-      }
-      if (enblLan2.checked == true) {
-         if ( isValidIpAddress(lan2IpAddress.value) == false ) {
-            alert('Address "' + lan2IpAddress.value + '" is invalid IP address.');
-            return;
+function do_cgi(){
+       var loc = 'lancfg2.cgi?';
+       loc += 'checkNum=' + randomNum + '&';
+       with ( document.forms[0] ) {
+               if ( isValidIpAddress(ethIpAddress.value) == false ) {
+                       alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
+                   return;
+               }
+               if ( isValidIpAddress(ethSubnetMask.value) == false ) {
+                       alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
+                       return;
+               }
+               loc += 'ethIpAddress=' + ethIpAddress.value;
+               loc += '&ethSubnetMask=' + ethSubnetMask.value;
+               if(hname.value.charAt(0).match("^[0-9]") != null){
+               alert("Host name can not start with a number.");
+               return;
+        }
+        loc += '&hostname=' + encodeUrl(hname.value);
+        if(urlError==1) return;
+        if(dname.value.charAt(0).match("^[0-9]") != null){
+               alert("Domain name can not start with a number.");
+               return;
+        }
+               loc += '&domainname=' + encodeUrl(dname.value);
+               if(urlError==1) return;
+
+
+               if (enblLan2.checked == true) {
+                       if ( isValidIpAddress(lan2IpAddress.value) == false ) {
+                       alert('Address "' + lan2IpAddress.value + '" is invalid IP address.');
+                       return;
+                       }
+                   if ( isValidIpAddress(lan2SubnetMask.value) == false ) {
+                       alert('Subnet mask "' + lan2SubnetMask.value + '" has invalid IP address.');
+                       return;
+                   }
+                   if ( checkLan1andLan2(ethIpAddress.value, ethSubnetMask.value, lan2IpAddress.value, lan2SubnetMask.value)==false){
+                       alert("The primary LAN IP address and secondary LAN IP address MUST belong to different subnets.");
+                       return;
+                   }
+                   loc += '&enblLan2=1';
+                   loc += '&lan2IpAddress=' + lan2IpAddress.value;
+                   loc += '&lan2SubnetMask=' + lan2SubnetMask.value;
+                } else {
+                   loc += '&enblLan2=0';
+                   loc += '&lan2IpAddress=' + '0.0.0.0';
+               loc += '&lan2SubnetMask=' + '255.255.255.255';
          }
-         if ( isValidIpAddress(lan2SubnetMask.value) == false ) {
-            alert('Subnet mask "' + lan2SubnetMask.value + '" has invalid IP address.');
-            return;
-         }
-         if (ethIpAddress.value == lan2IpAddress.value) {
-            alert('The IP address "' + ethIpAddress.value + '" for both LAN interfaces should not be the same.');
-            return;
-         }
-         if (isSameSubNet(ethIpAddress.value, ethSubnetMask.value, lan2IpAddress.value, lan2SubnetMask.value)) {
-            alert('The Subnet can not be the same for both LAN interfaces.');
-            return;
-         }
-         loc += '&enblLan2=1';
-         loc += '&lan2IpAddress=' + lan2IpAddress.value;
-         loc += '&lan2SubnetMask=' + lan2SubnetMask.value;
-      }
-      else
-         loc += '&enblLan2=0';
-   }
-   var code = 'location = "' + loc + '"';
-   eval(code);
-}
-
-function btnReset() {
-     var loc = 'rebootinfo.cgi';
 
-     var code = 'location = "' + loc + '"';
-     eval(code);
+               if (includemtu == '1'){
+                       if (lmtu.value <1000){
+                               alert("Minimum MTU is 1000.");
+                               return;
+                       }
+                       if (lmtu.value >1500){
+                               alert("Maximum MTU is 1500.");
+                               return;
+                       }
+                       loc += '&lanmtu=' + lmtu.value;
+               }
+
+               //for DHCP start        \r
+               if (dhcpser[2].checked == true){\r
+                       loc += '&enblDhcpSrv=0';\r
+               } else if (dhcpser[1].checked == true){\r
+                       if ( isValidIpAddress(relayIp.value) == false ) {\r
+                       alert('Relay IP address "' + relayIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+                       loc += '&enblDhcpSrv=2';\r
+               loc += '&dhcpEthStart=' + relayIp.value;\r
+               } else {\r
+                       if ( isValidIpAddress(startIp.value) == false ) {\r
+                       alert('Start IP address "' +startIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+               if ( isValidIpAddress(endIp.value) == false ) {\r
+                       alert('Stop IP address "' + endIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+               if ( isNaN(time_dd.value) == true || isNaN(time_hh.value) == true ||\r
+                          isNaN(time_mm.value) == true) {\r
+                       alert("Dhcp lease time is invalid.");\r
+                       return;\r
+               }\r
+                       if (checkDhcpIpAddrRange(startIp.value, endIp.value) == false){\r
+                       alert('DHCP IP Address range is Error.');\r
+                       return;\r
+               }\r
+                       loc += '&enblDhcpSrv=1';\r
+                       loc += '&dhcpEthStart=' + startIp.value;\r
+                       loc += '&dhcpEthEnd=' + endIp.value;\r
+                       var leasetime=(time_dd.value*86400)+(time_hh.value*3600)+(time_mm.value*60);\r
+                       loc += '&dhcpLeasedTime=' + leasetime;\r
+               }
+               //DHCP end
+
+               var code = 'window.location.href="/'; // for Mac safari browser compatibility
+               code += loc + '"';
+               eval(code);
+       }
 }
 
-function setDhcpAddresses(lanIp) {
-   with ( document.forms[0] ) {
-      if ( isValidIpAddress(lanIp) == false ) {
-         alert('Address "' + lanIp + '" is invalid IP address.');
-         return;
-      }
-      addrParts = lanIp.split('.');
-      if ( addrParts.length != 4 )
-         return false;
-      t1 = parseInt(addrParts[3]) + 1;
-      if (dhcpEthStart.value != '' && t1 >= 255) {
-         alert("Last portion of IP Address has to be less than 254 for Enabled DHCP Server");
-         return false;
-      }
-      dhcpEthStart.value = dhcpEthEnd.value = "";
-      for (i = 0; i < 3; i++) {
-         dhcpEthStart.value = dhcpEthStart.value + addrParts[i] + ".";
-         dhcpEthEnd.value = dhcpEthEnd.value + addrParts[i] + ".";
-      }
-      dhcpEthStart.value = dhcpEthStart.value + t1;
-      dhcpEthEnd.value = dhcpEthEnd.value + 254;
-   }
+function do_cgi_noIP2(){
+       var loc = 'lancfg2.cgi?';
+       loc += 'checkNum=' + randomNum + '&';
+       with ( document.forms[0] ) {
+               if ( isValidIpAddress(ethIpAddress.value) == false ) {
+                       alert('Address "' + ethIpAddress.value + '" is invalid IP address.');
+                       return;
+               }
+               if ( isValidIpAddress(ethSubnetMask.value) == false ) {
+                       alert('Subnet mask "' + ethSubnetMask.value + '" has invalid IP address.');
+                       return;
+               }
+               loc += 'ethIpAddress=' + ethIpAddress.value;
+               loc += '&ethSubnetMask=' + ethSubnetMask.value;
+               loc += '&hostname=' + encodeUrl(hname.value);
+               if(urlError==1) return;
+               loc += '&domainname=' + encodeUrl(dname.value);
+               if(urlError==1) return;
+               if (includemtu == '1'){
+                       if (lmtu.value <1000){
+                               alert("Minimum MTU is 1000.");
+                               return;
+                       }
+                       if (lmtu.value >1500){
+                               alert("Maximum MTU is 1500.");
+                               return;
+                       }
+                       loc += '&lanmtu=' + lmtu.value;
+               }
+               
+               //for DHCP start        \r
+               if (dhcpser[2].checked == true){\r
+                       loc += '&enblDhcpSrv=0';\r
+               } else if (dhcpser[1].checked == true){\r
+                       if ( isValidIpAddress(relayIp.value) == false ) {\r
+                       alert('Relay IP address "' + relayIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+                       loc += '&enblDhcpSrv=2';\r
+               loc += '&dhcpEthStart=' + relayIp.value;\r
+               } else {\r
+                       if ( isValidIpAddress(startIp.value) == false ) {\r
+                       alert('Start IP address "' +startIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+               if ( isValidIpAddress(endIp.value) == false ) {\r
+                       alert('Stop IP address "' + endIp.value + '" is invalid IP address.');\r
+                       return;\r
+               }\r
+               if ( isNaN(time_dd.value) == true || isNaN(time_hh.value) == true ||\r
+                          isNaN(time_mm.value) == true) {\r
+                       alert("Dhcp lease time is invalid.");\r
+                       return;\r
+               }\r
+                       if (checkDhcpIpAddrRange(startIp.value, endIp.value) == false){\r
+                       alert('DHCP IP Address range is Error.');\r
+                       return;\r
+               }\r
+                       loc += '&enblDhcpSrv=1';\r
+                       loc += '&dhcpEthStart=' + startIp.value;\r
+                       loc += '&dhcpEthEnd=' + endIp.value;\r
+                       var leasetime=(time_dd.value*86400)+(time_hh.value*3600)+(time_mm.value*60);\r
+                       loc += '&dhcpLeasedTime=' + leasetime;\r
+               }
+               //DHCP end
+               
+               var code = 'window.location.href="/'; // for Mac safari browser compatibility
+               code += loc + '"';
+               eval(code);
+       }
 }
 
-function manualModDhcp() {
-   with ( document.forms[0] ) {
-      dhcpStart = dhcpEthStart.value;
-      dhcpEnd = dhcpEthEnd.value;
-   }
-}   
-
+function btnApply() {
+       with ( document.forms[0] ) {
+       if ( BridgeOnly == '0' ){
+               do_cgi();               
+               } else {                
+            do_cgi_noIP2();                    
+               }
+       }
+}
 // done hiding -->
 </script>
-              <base target="_self">
-     </head>
-
-<body onload="initMenu(); frmLoad();">
-
-<script type="text/javascript">
-       writeHeader("LAN", "<%ejGetJS(curUserName)%>", "<%ejGetOther(sysInfo, adslStd)%>", "<%ejGetOther(sysInfo, noBrPrtcl)%>", <%ejGetOther(sysInfo, pppIpExtension)%>, <%ejGetOther(sysInfo, enblFirewall)%>, <%ejGetOther(sysInfo, enblNat)%>, "<%ejGetWlJS(wlInterface)%>", <%ejGetJS(enblQos)%>);
+<base target="_self">
+</head>
+
+<body onLoad='frmLoad()'>
+
+<form class="formpadding">
+<table border="0" cellpadding="0" cellspacing="3" width="98%">
+<tr>
+  <td><b><font class="netgear">LAN IP Setup</font></b></td>
+</tr>
+<tr><td>&nbsp;</td></tr>
+<tr>\r
+  <td background="liteblue.gif" height="12">&nbsp;</td>\r
+</tr>
+</table>
+  <font color="#0099cc"><b>LAN IP Address Configuration</b></font><br><br>
+  Enter the ADSL router IP address and subnet mask for LAN interface.
+  <br><br>
+  <table border="0" cellpadding="0" cellspacing="0">
+     <tr>
+       <td width="150">Primary IP Address:</td>
+       <td><input type='text' name='ethIpAddress'></td>
+     </tr>
+     <tr>
+       <td>Subnet Mask:</td>
+       <td><input type='text' name='ethSubnetMask'></td>
+     </tr>
+     <tr>
+       <td width="150">Host Name:</td>
+       <td><input type='text' name='hname' maxlength="31"></td>
+     </tr>
+     <tr>
+       <td>Domain Name:</td>
+       <td><input type='text' name='dname' maxlength="63"></td>
+     </tr>
+  </table>
+  <br>
+<script language="javascript">
+<!-- hide
+if ( BridgeOnly == '0' ){
+       document.writeln("<table border='0' cellpadding='0' cellspacing='0'>");
+       document.writeln("<tr>");
+               document.writeln("<td valign='middle' align='left' width='24' height='20'><input type='checkbox' name='enblLan2' onClick='showlan2()'></td>");
+               document.writeln("<td>Configure secondary IP address and subnet mask.</td>");
+       document.writeln("</tr>");
+       document.writeln("</table>");
+       document.writeln("<br>");
+}
+// done hiding -->
 </script>
-
-<form>
-<h3>DHCP Server</h3>
-
-<p>Configure the router&rsquo;s IP address and subnet mask for LAN interface.</p>
-
-<table border="0" cellpadding="1" cellspacing="0">
-  <tr>
-     <td><label for="ethIpAddress">IP address:</label></td>
-     <td><input type='text' name='ethIpAddress' id='ethIpAddress'></td>
-  </tr>
+  <table border="0" cellpadding="0" cellspacing="0">
+  <tr><td><div ID="displaylan2"></div></td></tr>
+  </table>
+  <div ID="LanMtuInfo"></div>
+  
+<table border="0" cellpadding="0" cellspacing="3" width="98%">
+<tr>\r
+  <td background="liteblue.gif" height="12">&nbsp;</td>\r
+</tr>
+</table>\r
+<font color="#0099cc"><b>DHCP Server Configuration</b></font><br><br>
+<table border='0' cellspacing="0" cellpadding="0">\r
+  <tr><td width="580">\r
+  Enabling DHCP Server on LAN interface can provide the proper IP address settings to your computer.\r
+  </td></tr></table>\r
+  \r
+  <p ID="DhcpInfo"></p>
+    
+<table border="0" cellpadding="0" cellspacing="3" width="98%">
+<tr>\r
+  <td background="liteblue.gif" height="12">&nbsp;</td>\r
+</tr>
+</table>  
+  <table border="0" width="520">
   <tr>
-     <td><label for="ethSubnetMask">Subnet mask:</label></td>
-     <td><input type='text' name='ethSubnetMask' id='ethSubnetMask'></td>
+  <td align="left" width="50"><input type='button' onClick='btnApply()' value='Apply'></td>
+  <td align="left" width="60"><input type="button" onClick="btnCancel('lancfg2.html')" value="Cancel"></td>
+  <td class="grey_comment" width="410">New settings only take effect after your ADSL router is rebooted. If necessary, reconfigure your PC's IP address to match new settings.</td>
   </tr>
-</table>
-
-<div id='dhcpInfo'>
-       <p>
-               <input type='radio' name='dhcpSrvType' id='optDHCPoff' onClick='typeClick()'> <label for="optDHCPoff">Disable DHCP server</label><br>
-               <input type='radio' name='dhcpSrvType' id='optDHCPon' onClick='typeClick()'> <label for="optDHCPon">Enable DHCP server</label>
-       </p>
-       <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
-               <tr>
-                  <td><label for="dhcpEthStart">Start IP address:</label></td>
-                  <td><input type='text' name='dhcpEthStart' id='dhcpEthStart' onChange='manualModDhcp()'></td>
-               </tr>
-               <tr>
-                  <td><label for="dhcpEthEnd">End IP address:</label></td>
-                  <td><input type='text' name='dhcpEthEnd' id='dhcpEthEnd' onChange='manualModDhcp()'></td>
-               </tr>
-               <tr>
-                  <td><label for="dhcpLeasedTime">Lease time:</label></td>
-                   <td><input type='text' name='dhcpLeasedTime' id='dhcpLeasedTime'> hours</td>
-                 </tr>
-       </table>
-
-       <div id='relayInfo'>
-               <p><input type='radio' name='dhcpSrvType' id='optDHCPrelay' onClick='typeClick()'> <label for="optDHCPrelay">Enable DHCP server relay</label></p>
-               <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
-                  <tr>
-                     <td><label for="dhcpSrvAddr">DHCP server IP address:</label></td>
-                     <td><input type='text' name='dhcpSrvAddr' id='dhcpSrvAddr'></td>
-                  </tr>
-               </table>
-       </div>
-
-       <p><input type='checkbox' name='enblLan2' id='enblLan2' onClick='lan2CbClick(this)'> <label for="enblLan2">Configure the second IP address and subnet mask for LAN interface</label></p>
-       <div id='lan2Info'>
-         <table border="0" cellpadding="1" cellspacing="0" style="margin-left: 2em;">
-            <tr>
-              <td><label for="lan2IpAddress">IP address:</label></td>
-              <td><input type='text' name='lan2IpAddress' id='lan2IpAddress'></td>
-            </tr>
-            <tr>
-               <td><label for="lan2SubnetMask">Subnet mask:</label></td>
-               <td><input type='text' name='lan2SubnetMask' id='lan2SubnetMask'></td>
-            </tr>
-         </table>
-       </div>
-</div>
-
-<div id='IGMPSnooping'>
-<h3>IGMP Snooping</h3>
-<p><input type='checkbox' name='chkIgmpSnp' id='chkIgmpSnp'> <label for="chkIgmpSnp">IGMP Snooping</label></p>
-</div>
-
-<div id='upnpInfo'>
-<h3>Universal Plug-n-Play</h3>
-<p><input type='checkbox' name='chkUpnp' id='chkUpnp'> <label for="chkUpnp">Universal Plug-n-Play (UPnP)</label></p>
-</div>
-
-<div id='idStp'>
-<h3>802.1d</h3>
-<p><input type='checkbox' name='chkStp' id='chkStp'> <label for="chkStp">802.1d spanning tree protocol</label></p>
-</div>
-
-<p><input type='button' onClick='btnApply(0)' value='Apply'> <input type='button' onClick='btnReset()' value='Restart'></p>
-</form>
-
-<script type="text/javascript">
-       writeFooter();
-</script>
-
+  </table>
+  </form>
 </body>
 </html>