Advertisement
Guest User

Untitled

a guest
May 11th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var subnet_mask = new Array(0, 128, 192, 224, 240, 248, 252, 254, 255);
  2. var key_num_array = new Array("64", "128");
  3. //var Week = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
  4. var Week = new Array(_Sun, _Mon, _Tue, _Wed, _Thu, _Fri, _Sat);
  5.  
  6.  
  7. function rule_obj(name, prot, public_port, private_port){  
  8.     this.name = name;
  9.     this.prot = prot;       // TCP, UDP
  10.     this.public_port = public_port;
  11.     this.private_port = private_port;
  12. }
  13.  
  14. function appl_obj(name, trigger_prot, trigger_port, public_prot, public_port){
  15.     this.name = name;
  16.     this.trigger_prot = trigger_prot;       // TCP, UDP
  17.     this.trigger_port = trigger_port;
  18.     this.public_prot = public_prot;
  19.     this.public_port = public_port;
  20. }
  21.  
  22. function set_application_option(obj_value, obj_array){
  23.     for (var i = 0; i < obj_array.length; i++){
  24.         var temp_rule = obj_array[i];
  25.         obj_value += "<option>" + temp_rule.name + "</option>";
  26.     }
  27.     return obj_value;
  28. }
  29.  
  30. function addr_obj(addr, e_msg, allow_zero, is_network){
  31.     this.addr = addr;
  32.     this.e_msg = e_msg;
  33.     this.allow_zero = allow_zero;      
  34.     this.is_network = is_network;
  35. }
  36.  
  37. function isp_obj(isp_name, dial_number, apn, username, password){
  38.     this.isp_name = isp_name;
  39.     this.dial_number = dial_number;    
  40.     this.apn = apn;
  41.     this.username = username;
  42.     this.password = password;
  43. }
  44.  
  45. function set_isp_option(obj_value, obj_array){
  46.     for (var i = 0; i < obj_array.length; i++){
  47.         var temp_isp = obj_array[i];
  48.         obj_value += "<option>" + temp_isp.isp_name + "</option>";
  49.     }
  50.     return obj_value;
  51. }
  52.  
  53.  
  54.  
  55. function varible_obj(var_value, e_msg, min, max, is_even){
  56.     this.var_value = var_value;
  57.     this.e_msg = e_msg;
  58.     this.min = min;
  59.     this.max = max;    
  60.     this.is_even = is_even;    
  61. }
  62.  
  63. function raidus_obj(ip, port, secret){
  64.     this.ip = ip;
  65.     this.port = port;
  66.     this.secret = secret;
  67. }
  68.  
  69. function ip4_obj(ip, min_range, max_range, e_msg1, e_msg2){
  70.     this.ip = ip;  
  71.     this.min_range = min_range;
  72.     this.max_range = max_range;    
  73.     this.e_msg1 = msg[e_msg1];
  74.     this.e_msg2 = msg[e_msg2]; 
  75. }
  76. function change_wan(){
  77.     var html_file;
  78.    
  79.     switch(get_by_id("wan_proto").selectedIndex){
  80.         case 0 :
  81.             html_file = "wan_static.asp";
  82.             break;     
  83.         case 1 :
  84.             html_file = "wan_dhcp.asp";
  85.             break;
  86.         case 2 :
  87.             html_file = "wan_poe.asp";
  88.             break;
  89.         case 3 :
  90.             html_file = "wan_pptp.asp";
  91.             break;
  92.         case 4 :
  93.             html_file = "wan_l2tp.asp";
  94.             break;
  95.         case 5 :
  96.             html_file = "wan_3G.asp";
  97.             break;
  98.        
  99.     }
  100.     location.href = html_file;
  101. }
  102.  
  103. function change_filter(which_filter){
  104.     var html_file;
  105.    
  106.     switch(which_filter){
  107.         case 0 :
  108.             html_file = "adv_filters.asp";
  109.             break;
  110.         case 1 :
  111.             html_file = "adv_filters_mac.asp";
  112.             break;         
  113.         case 2 :
  114.             html_file = "adv_filters_url.asp";
  115.             break;
  116.         case 3 :
  117.             html_file = "adv_filters_domain.asp";
  118.             break;
  119.     }
  120.    
  121.     location.href = html_file;
  122. }
  123.  
  124. function change_routing(which_routing){
  125.     var html_file;
  126.    
  127.     switch(which_routing){
  128.         case 0 :
  129.             html_file = "adv_routing.asp";
  130.             break;
  131.         case 1 :
  132.             html_file = "adv_routing_dynamic.asp";
  133.             break;
  134.         case 2 :
  135.             html_file = "adv_routing_table.asp";
  136.             break;
  137.     }
  138.    
  139.     location.href = html_file;
  140. }
  141.  
  142. function check_network_address(my_obj, mask_obj){
  143.     var count_zero = 0;
  144.     var ip = my_obj.addr;
  145.     var mask;
  146.     var allow_cast = false;
  147.  
  148.     if (my_obj.addr.length == 4){
  149.         // check the ip is not multicast IP (127.x.x.x && 224.x.x.x ~ 239.x.x.x)
  150.         if(my_obj.addr[0] == "127"){
  151.             alert(my_obj.e_msg[MULTICASE_IP_ERROR]);
  152.             return false;
  153.         }
  154.        
  155.         // check the ip is "0.0.0.0" or not
  156.         for(var i = 0; i < ip.length; i++){
  157.             if (ip[i] == "0"){
  158.                 count_zero++;          
  159.             }              
  160.         }
  161.  
  162.         if (!my_obj.allow_zero && count_zero == 4){ // if the ip is not allowed to be 0.0.0.0
  163.             alert(my_obj.e_msg[ZERO_IP]);           // but we check the ip is 0.0.0.0
  164.             return false;
  165.         }else if (count_zero != 4){     // when IP is not 0.0.0.0, checking range. Otherwise no need to check              
  166.                 mask = mask_obj.addr;
  167.                 for(var i = 0; i < mask.length; i++){
  168.                     if (mask[i] != "255"){
  169.                     if (ip[i] != (mask[i] & ip[i])){
  170.                         alert(my_obj.e_msg[FIRST_RANGE_ERROR + i] + (mask[i] & ip[i]));
  171.                         return false;
  172.                     }
  173.                 }
  174.             }
  175.         }
  176.     }else{  // if the length of ip is not correct, show invalid ip msg
  177.         alert(my_obj.e_msg[INVALID_IP]);
  178.         return false;
  179.     }
  180.  
  181.     return true;
  182. }
  183.  
  184. function check_domain(ip, mask, gateway){
  185.     var temp_ip = ip.addr;
  186.     var temp_mask = mask.addr;
  187.     var temp_gateway = gateway.addr;
  188.     var temp_str = "";
  189.    
  190.     for (var i = 0; i < 4; i++){
  191.         temp_str += temp_gateway[i];
  192.        
  193.         if (i < 3){
  194.             temp_str += ".";
  195.         }
  196.     }
  197.    
  198.     if (gateway.allow_zero && (temp_str == "0.0.0.0" || temp_str == "...")){
  199.         return true;
  200.     }
  201.  
  202.     for (var i = 0; i < temp_ip.length - 1; i++){
  203.         if ((temp_ip[i] & temp_mask[i]) != (temp_gateway[i] & temp_mask[i])){
  204.             return false;       // when not in the same subnet mask, return false
  205.         }
  206.     }
  207.  
  208.     return true;
  209. }
  210.  
  211. function check_ip_order(start_ip, end_ip){
  212.     var temp_start_ip = start_ip.addr;
  213.     var temp_end_ip = end_ip.addr;
  214.     var total1 = ip_num(temp_start_ip);
  215.     var total2 = ip_num(temp_end_ip);
  216.    
  217.     if(total1 > total2)
  218.         return false;
  219.     return true;
  220. }
  221.  
  222. function check_lanip_order(ip,start_ip, end_ip){
  223.     var temp_start_ip = start_ip.addr;
  224.     var temp_end_ip = end_ip.addr;
  225.     var temp_ip = ip.addr;
  226.     var total1 = ip_num(temp_start_ip);
  227.     var total2 = ip_num(temp_end_ip);
  228.     var total3 = ip_num(temp_ip);
  229.     if(total1 <= total3 && total3 <= total2)
  230.          return true;
  231.     return false;
  232. }
  233.  
  234. function check_resip_order(reserved_ip,start_ip, end_ip){
  235.     var temp_start_ip = start_ip.addr;
  236.     var temp_end_ip = end_ip.addr;
  237.     var temp_res_ip = reserved_ip.addr;
  238.     var total1 = ip_num(temp_start_ip);
  239.     var total2 = ip_num(temp_end_ip);
  240.     var total3 = ip_num(temp_res_ip);
  241.     if(total1 <= total3 && total3 <= total2)
  242.         return false;
  243.     return true;
  244. }
  245.  
  246. function check_ip4(ip4){
  247.     var temp_ip = (ip4.ip).split(" ");
  248.    
  249.     if (ip4.ip == ""){
  250.         alert(ip4.e_msg1);
  251.         return false;
  252.     }else if (isNaN(ip4.ip) || temp_ip.length > 1 || parseInt(ip4.ip) < ip4.min_range || parseInt(ip4.ip) > ip4.max_range){
  253.         alert(ip4.e_msg2);
  254.         return false;
  255.     }
  256.     return true;
  257. }
  258.  
  259. function check_key(){
  260.     var key;
  261.     var def_key = get_by_id("wep_def_key").value;
  262.     var wep_def_key = get_by_id("wep_def_key");
  263.     var wep_key_len = parseInt(get_by_id("wep_key_len").value);
  264.     var hex_len = wep_key_len * 2;
  265.  
  266.     for(var i = 1; i < 5; i++){
  267.             key = get_by_id("key" + i).value;
  268.             if (wep_def_key[i-1].selectedIndex){
  269.                 if (key == ''){
  270.                 alert(YM122);  
  271.                     return false;
  272.                 }
  273.           }else{
  274.                 if (key.length != wep_key_len && key.length != hex_len){
  275.                         alert(TEXT041_1+" " + i + " "+TEXT041_2+" " + wep_key_len + " "+TEXT041_3+" " + hex_len + " "+TEXT041_4);//TEXT041
  276.                         return false;
  277.                 }else if(key.length == hex_len){
  278.                     for (var j = 0; j < key.length; j++){
  279.                         if (!check_hex(key.substring(j, j+1))){
  280.                             alert(TEXT042_1+" " + i + " "+TEXT042_2);//TEXT042
  281.                             return false;
  282.                         }
  283.                     }
  284.                     if(i == def_key)
  285.                         get_by_id("wlan0_wep_display").value = "hex";
  286.                 }else{
  287.                         if(i == def_key)
  288.                             get_by_id("wlan0_wep_display").value = "ascii";
  289.                 }
  290.           }
  291.     }
  292.     return true;
  293. }
  294. function check_vap1_key(){
  295.     var key;
  296.     var def_key = get_by_id("wep_def_key").value;
  297.     var wep_def_key = get_by_id("wep_def_key");
  298.     var wep_key_len = parseInt(get_by_id("wep_key_len").value);
  299.     var hex_len = wep_key_len * 2;
  300.  
  301.     for(var i = 1; i < 5; i++){
  302.             key = get_by_id("key" + i).value;
  303.             if (wep_def_key[i-1].selectedIndex){
  304.                 if (key == ''){
  305.                 alert(msg[WEP_KEY_EMPTY]);
  306.                     return false;
  307.                 }
  308.           }else{
  309.                 if (key.length != wep_key_len && key.length != hex_len){
  310.                         alert(TEXT041_1+" " + i + " "+TEXT041_2+" " + wep_key_len + " "+TEXT041_3+" " + hex_len + " "+TEXT041_4);//TEXT041
  311.                         return false;
  312.                 }else if(key.length == hex_len){
  313.                     for (var j = 0; j < key.length; j++){
  314.                         if (!check_hex(key.substring(j, j+1))){
  315.                             alert(TEXT042_1+" " + i + " "+TEXT042_2);//TEXT042
  316.                             return false;
  317.                         }
  318.                     }
  319.                     if(i == def_key)
  320.                         get_by_id("wlan0_vap1_wep_display").value = "hex";
  321.                 }else{
  322.                         if(i == def_key)
  323.                             get_by_id("wlan0_vap1_wep_display").value = "ascii";
  324.                 }
  325.           }
  326.     }
  327.     return true;
  328. }
  329.  
  330. function check_key_1(){
  331.     var key;
  332.     var def_key = get_by_id("wep_def_key_1").value;
  333.     var wep_def_key = get_by_id("wep_def_key_1");
  334.     var wep_key_len = parseInt(get_by_id("wep_key_len_1").value);
  335.     var hex_len = wep_key_len * 2;
  336.  
  337.     for(var i = 1; i < 5; i++){
  338.             key = get_by_id("key" + (i+4)).value;
  339.             if (wep_def_key[i-1].selectedIndex){
  340.                 if (key == ''){
  341.                 alert(msg[WEP_KEY_EMPTY]);
  342.                     return false;
  343.                 }
  344.           }else{
  345.                 if (key.length != wep_key_len && key.length != hex_len){
  346.                         alert(TEXT041_1+" " + [i-5] + " "+TEXT041_2+" " + wep_key_len + " "+TEXT041_3+" " + hex_len + " "+TEXT041_4);//TEXT041
  347.                         return false;
  348.                 }else if(key.length == hex_len){
  349.                     for (var j = 0; j < key.length; j++){
  350.                         if (!check_hex(key.substring(j, j+1))){
  351.                             alert(TEXT042_1+" " + [i-5] + " "+TEXT042_2);//TEXT042
  352.                             return false;
  353.                         }
  354.                     }
  355.                     if(i == def_key)
  356.                         get_by_id("wlan1_wep_display").value = "hex";
  357.                 }else{
  358.                         if(i == def_key)
  359.                             get_by_id("wlan1_wep_display").value = "ascii";
  360.                 }
  361.           }
  362.     }
  363.     return true;
  364. }
  365. function check_vap1_key_1(){
  366.     var key;
  367.     var def_key = get_by_id("wep_def_key_1").value;
  368.     var wep_def_key = get_by_id("wep_def_key_1");
  369.     var wep_key_len = parseInt(get_by_id("wep_key_len_1").value);
  370.     var hex_len = wep_key_len * 2;
  371.  
  372.     for(var i = 1; i < 5; i++){
  373.             key = get_by_id("key" + (i+4)).value;
  374.             if (wep_def_key[i-1].selectedIndex){
  375.                 if (key == ''){
  376.                 alert(msg[WEP_KEY_EMPTY]);
  377.                     return false;
  378.                 }
  379.           }else{
  380.                 if (key.length != wep_key_len && key.length != hex_len){
  381.                         alert(TEXT041_1+" " + [i-5] + " "+TEXT041_2+" " + wep_key_len + " "+TEXT041_3+" " + hex_len + " "+TEXT041_4);//TEXT041
  382.                         return false;
  383.                 }else if(key.length == hex_len){
  384.                     for (var j = 0; j < key.length; j++){
  385.                         if (!check_hex(key.substring(j, j+1))){
  386.                             alert(TEXT042_1+" " + [i-5] + " "+TEXT042_2);//TEXT042
  387.                             return false;
  388.                         }
  389.                     }
  390.                     if(i == def_key)
  391.                         get_by_id("wlan1_vap1_wep_display").value = "hex";
  392.                 }else{
  393.                         if(i == def_key)
  394.                             get_by_id("wlan1_vap1_wep_display").value = "ascii";
  395.                 }
  396.           }
  397.     }
  398.     return true;
  399. }
  400.  
  401. function check_integer(which_value, min, max){ 
  402.     var temp_obj = (which_value).split(" ");
  403.    
  404.     if (temp_obj == "" || temp_obj.length > 1 || isNaN(which_value)){  
  405.         return false;
  406.     }else if (parseInt(which_value,10) < min || parseInt(which_value,10) > max){
  407.         return false;
  408.     }
  409.    
  410.     return true;
  411. }
  412.  
  413. function get_seq(index){
  414.     var seq;
  415.    
  416.     switch(index){
  417.         case 0:
  418.             seq = "1st";
  419.             break;
  420.         case 1:
  421.             seq = "2nd";
  422.             break;
  423.         case 2:
  424.             seq = "3rd";
  425.             break;
  426.         case 3:
  427.             seq = "4th";
  428.             break;
  429.     }
  430.     return seq;
  431. }
  432.  
  433. function check_ip_range(order, my_obj, mask){
  434.     var which_ip = (my_obj.addr[order]).split(" ");
  435.     var start, end;
  436.  
  437.     if (isNaN(which_ip) || which_ip == "" || which_ip.length > 1 || (which_ip[0].length > 1 && which_ip[0].substring(0,1) == "0")){ // if the address is invalid
  438.         alert(my_obj.e_msg[FIRST_IP_ERROR + order]);
  439.         return false;
  440.     }
  441.  
  442.     if (order == 0){                // the checking range of 1st address
  443.         start = 1;
  444.     }else{
  445.                 start = 0;
  446.             }
  447.        
  448.     if (mask[order] != 255){       
  449.         if (parseInt(which_ip) >= 0 && parseInt(which_ip) <= 255){ 
  450.             end = (~mask[order]+256);              
  451.             start = mask[order] & which_ip;
  452.             end += start;
  453.        
  454.             if (end > 255){
  455.                 end = 255;
  456.             }
  457.         }else{
  458.             end = 255;
  459.         }
  460.     }else{
  461.         end = 255;
  462.     }
  463.    
  464.    
  465.     if (order == 3){
  466.         if ((mask[0] == 255) && (mask[1] == 255) && (mask[2] == 255)){
  467.             start += 1;
  468.             end -= 1;
  469.         }else{
  470.             if (((mask[0] | (~my_obj.addr[0]+256)) == 255) && ((mask[1] | (~my_obj.addr[1]+256)) == 255) && ((mask[2] | (~my_obj.addr[2]+256)) == 255)){
  471.                 start += 1;
  472.             }
  473.            
  474.             if (((mask[0] | my_obj.addr[0]) == 255) && ((mask[1] | my_obj.addr[1]) == 255) && ((mask[2] | my_obj.addr[2]) == 255)){        
  475.                 end -= 1;
  476.             }              
  477.         }
  478.         }
  479.        
  480.     if (parseInt(which_ip) < start || parseInt(which_ip) > end){           
  481.         alert(my_obj.e_msg[FIRST_RANGE_ERROR + order] + " " + start + " ~ " + end + ".");      
  482.         return false;
  483.     }
  484.  
  485.     return true;
  486. }
  487.  
  488. function check_current_range(order, my_obj, checking_ip, mask){
  489.     var which_ip = (my_obj.addr[order]).split(" ");
  490.     var start, end;
  491.  
  492.     if (isNaN(which_ip) || which_ip == "" || which_ip.length > 1 || (which_ip[0].length > 1 && which_ip[0].substring(0,1) == "0")){ // if the address is invalid
  493.         alert(my_obj.e_msg[FIRST_IP_ERROR + order]);
  494.         return false;
  495.     }
  496.    
  497.     if (order == 0){                // the checking range of 1st address
  498.         start = 1; 
  499.     }else{
  500.         start = 0;             
  501.     }
  502.    
  503.     if (mask[order] != 255){               
  504.         if (parseInt(checking_ip[order]) >= 0 && parseInt(checking_ip[order]) <= 255){ 
  505.             end = (~mask[order]+256);              
  506.             start = mask[order] & checking_ip[order];  
  507.             end += start;
  508.        
  509.             if (end > 255){
  510.                 end = 255;
  511.             }
  512.         }else{
  513.             end = 255;
  514.         }
  515.     }else{
  516.         end = 255;
  517.     }
  518.    
  519.     if (order == 3){
  520.         if ((mask[0] == 255) && (mask[1] == 255) && (mask[2] == 255)){
  521.             start += 1;
  522.             end -= 1;
  523.         }else{     
  524.             if (((mask[0] | (~my_obj.addr[0]+256)) == 255) && ((mask[1] | (~my_obj.addr[1]+256)) == 255) && ((mask[2] | (~my_obj.addr[2]+256)) == 255)){
  525.                 start += 1;
  526.             }
  527.            
  528.             if (((mask[0] | my_obj.addr[0]) == 255) && ((mask[1] | my_obj.addr[1]) == 255) && ((mask[2] | my_obj.addr[2]) == 255)){        
  529.                 end -= 1;
  530.             }  
  531.         }  
  532.     }
  533.        
  534.     if (parseInt(which_ip) < start || parseInt(which_ip) > end){           
  535.         alert(my_obj.e_msg[FIRST_RANGE_ERROR + order] + " " + start + " ~ " + end + ".");      
  536.         return false;
  537.     }
  538.    
  539.     return true;
  540. }
  541.  
  542. function check_hex(data){
  543.     data = data.toUpperCase();
  544.  
  545.     if (!(data >= 'A' && data <= 'F') && !(data >= '0' && data <= '9')){
  546.         return false;
  547.     }
  548.     return true;
  549. }                                      
  550.                
  551. function check_lan_setting(ip, mask, gateway, obj_word){               
  552.    
  553.      if (!check_mask(mask)){
  554.         return false;   // when subnet mask is not in the subnet mask range
  555.     }else if (!check_address(ip, mask)){
  556.         return false;       // when ip is invalid
  557.     }else if (!check_address(gateway, mask, ip)){
  558.         return false;   // when gateway is invalid
  559.     }else if (!check_domain(ip, mask, gateway)){        // check if the ip and the gateway are in the same subnet mask or not
  560.         var gateway_ipaddr_1 = gateway.addr[0]+"."+gateway.addr[1]+"."+gateway.addr[2]+"."+gateway.addr[3];
  561.         alert(addstr(msg[NOT_SAME_DOMAIN], obj_word, gateway_ipaddr_1));
  562.         return false;
  563.     }
  564.     return true;
  565. }
  566. function check_mac(mac){
  567.     var temp_mac = mac.split(":");
  568.     var error = true;
  569.     if (temp_mac.length == 6){
  570.         if(temp_mac[0] != "00" && temp_mac[0] != "08"){
  571.             return false;
  572.         }
  573.         for (var i = 0; i < 6; i++){        
  574.             var temp_str = temp_mac[i];
  575.            
  576.             if (temp_str == ""){
  577.                 error = false;
  578.             }else{         
  579.                 if (!check_hex(temp_str.substring(0,1)) || !check_hex(temp_str.substring(1))){
  580.                     error = false;
  581.                 }
  582.             }
  583.            
  584.             if (!error){
  585.                 break;
  586.             }
  587.         }
  588.     }else{
  589.         error = false;
  590.     }
  591.     return error;
  592. }
  593. function check_mac_00(mac){
  594.     var error = true;
  595.     if((mac.indexOf(':') != -1)){
  596.         var temp_mac = mac.split(":");
  597.     }else if((mac.indexOf('-') != -1)){
  598.         var temp_mac = mac.split("-");
  599.     }
  600.    
  601.     if(mac.length != 17) {
  602.         return false;
  603.     }
  604.     if(mac.substring(0,2) != "00"){
  605.         return false;
  606.     }    
  607.    
  608.     if (temp_mac.length == 6){
  609.         var j=0;
  610.         for (var i = 0; i < 6; i++){        
  611.             var temp_str = temp_mac[i];
  612.            
  613.             if (temp_str == ""){
  614.                 error = false;
  615.             }
  616.             else if(temp_str == "00"){
  617.                 j++;
  618.             }  
  619.             else{          
  620.                 if (!check_hex(temp_str.substring(0,1)) || !check_hex(temp_str.substring(1))){
  621.                     error = false;
  622.                 }
  623.             }
  624.             if (!error){
  625.                 break;
  626.             }
  627.         }
  628.         if(j==6)
  629.             error = false;
  630.     }else{
  631.         error = false;
  632.     }
  633.     return error;
  634. }
  635.  
  636. function check_address(my_obj, mask_obj, ip_obj){
  637.     var count_zero = 0;
  638.     var count_bcast = 0;   
  639.     var ip = my_obj.addr;
  640.     var mask;
  641.    
  642.     if (my_obj.addr.length == 4){
  643.         // check the ip is not multicast IP (127.x.x.x && 224.x.x.x ~ 239.x.x.x)
  644.         if((my_obj.addr[0] == "127") || ((my_obj.addr[0] >= 224) && (my_obj.addr[0] <= 239))){
  645.             alert(my_obj.e_msg[MULTICASE_IP_ERROR]);
  646.             return false;
  647.         }
  648.         // check the ip is "0.0.0.0" or not
  649.         for(var i = 0; i < ip.length; i++){
  650.             if (ip[i] == "0"){
  651.                 count_zero++;          
  652.             }
  653.         }
  654.  
  655.         if (!my_obj.allow_zero && count_zero == 4){ // if the ip is not allowed to be 0.0.0.0
  656.             alert(my_obj.e_msg[ZERO_IP]);           // but we check the ip is 0.0.0.0
  657.             return false;
  658.         }else if (count_zero != 4){     // when IP is not 0.0.0.0, checking range. Otherwise no need to check      
  659.             count_zero = 0;
  660.                
  661.             if (check_address.arguments.length >= 2 && mask_obj != null){
  662.                 mask = mask_obj.addr;
  663.             }else{
  664.                 mask = new Array(255,255,255,0);
  665.             }
  666.                        
  667.             for(var i = 0; i < ip.length; i++){
  668.                
  669.                 if (check_address.arguments.length == 3 && ip_obj != null){
  670.                     if (!check_current_range(i, my_obj, ip_obj.addr, mask)){
  671.                         return false;
  672.                     }
  673.                 }else{                 
  674.                     if (!check_ip_range(i, my_obj, mask)){
  675.                         return false;
  676.                     }
  677.                 }
  678.             }      
  679.                            
  680.             for (var i = 0; i < 4; i++){    // check the IP address is a network address or a broadcast address                                                                                        
  681.                 if (((~mask[i] + 256) & ip[i]) == 0){   // (~mask[i] + 256) = reverse mask[i]
  682.                     count_zero++;                      
  683.                 }
  684.                                
  685.                 if ((mask[i] | ip[i]) == 255){
  686.                     count_bcast++;
  687.                 }
  688.             }
  689.        
  690.             if ((count_zero == 4 && !my_obj.is_network) || (count_bcast == 4)){
  691.                 alert(my_obj.e_msg[INVALID_IP]);           
  692.                 return false;
  693.             }                                                  
  694.         }
  695.     }else{  // if the length of ip is not correct, show invalid ip msg
  696.         alert(my_obj.e_msg[INVALID_IP]);
  697.         return false;
  698.     }
  699.  
  700.     return true;
  701. }
  702.  
  703. function check_route_mask(my_mask){
  704.     var temp_mask = my_mask.addr;
  705.  
  706.     if (temp_mask.length == 4){
  707.         for (var i = 0; i < temp_mask.length; i++){
  708.             var which_ip = temp_mask[i].split(" ");
  709.             var mask = parseInt(temp_mask[i]);
  710.             var in_range = false;
  711.             var j = 0;
  712.  
  713.             if (isNaN(which_ip) || which_ip == "" || which_ip.length > 1 || (which_ip[0].length > 1 && which_ip[0].substring(0,1) == "0")){ // if the address is invalid
  714.                 alert(my_mask.e_msg[FIRST_IP_ERROR + i]);
  715.                 return false;
  716.             }
  717.  
  718.             if (i == 0){    // when it's 1st address
  719.                 j = 1;      // the 1st address can't be 0
  720.             }
  721.  
  722.             for (; j < subnet_mask.length; j++){
  723.                 if (mask == subnet_mask[j]){
  724.                     in_range = true;
  725.                     break;
  726.                 }else{
  727.                     in_range = false;
  728.                 }
  729.             }
  730.  
  731.             if (!in_range){
  732.                 alert(my_mask.e_msg[FIRST_RANGE_ERROR + i]);
  733.                 return false;
  734.             }
  735.  
  736.             if (i != 0 && mask != 0){ // when not the 1st range and the value is not 0
  737.                 if (parseInt(temp_mask[i-1]) != 255){  // check the previous value is 255 or not
  738.                     alert(my_mask.e_msg[INVALID_IP]);
  739.                     return false;
  740.                 }
  741.             }
  742.  
  743.             //if (i == 3 && (parseInt(mask) == 254 || parseInt(mask) == 255)){  // route mask don't check 4th mask=255 or 254
  744.             //  alert(my_mask.e_msg[FOURTH_RANGE_ERROR]);
  745.             //  return false;
  746.             //}
  747.         }
  748.     }else{
  749.         alert(my_mask.e_msg[INVALID_IP]);
  750.         return false;
  751.     }
  752.  
  753.     return true;
  754. }
  755. function check_mask(my_mask){
  756.     var temp_mask = my_mask.addr;
  757.  
  758.     if (temp_mask.length == 4){
  759.         for (var i = 0; i < temp_mask.length; i++){
  760.             var which_ip = temp_mask[i].split(" ");
  761.             var mask = parseInt(temp_mask[i]);
  762.             var in_range = false;
  763.             var j = 0;
  764.  
  765.             if (isNaN(which_ip) || which_ip == "" || which_ip.length > 1 || (which_ip[0].length > 1 && which_ip[0].substring(0,1) == "0")){ // if the address is invalid
  766.                 alert(my_mask.e_msg[FIRST_IP_ERROR + i]);
  767.                 return false;
  768.             }
  769.  
  770.             if (i == 0){    // when it's 1st address
  771.                 j = 1;      // the 1st address can't be 0
  772.             }
  773.  
  774.             for (; j < subnet_mask.length; j++){
  775.                 if (mask == subnet_mask[j]){
  776.                     in_range = true;
  777.                     break;
  778.                 }else{
  779.                     in_range = false;
  780.                 }
  781.             }
  782.  
  783.             if (!in_range){
  784.                 alert(my_mask.e_msg[FIRST_RANGE_ERROR + i]);
  785.                 return false;
  786.             }
  787.  
  788.             if (i != 0 && mask != 0){ // when not the 1st range and the value is not 0
  789.                 if (parseInt(temp_mask[i-1]) != 255){  // check the previous value is 255 or not
  790.                     alert(my_mask.e_msg[INVALID_IP]);
  791.                     return false;
  792.                 }
  793.             }
  794.  
  795.             if (i == 3 && (parseInt(mask) == 254 || parseInt(mask) == 255)){    // when the last mask address is 255
  796.                 alert(my_mask.e_msg[FOURTH_RANGE_ERROR]);
  797.                 return false;
  798.             }
  799.         }
  800.     }else{
  801.         alert(my_mask.e_msg[INVALID_IP]);
  802.         return false;
  803.     }
  804.  
  805.     return true;
  806. }
  807.  
  808.  
  809. function check_pwd(pwd1, pwd2){
  810.     if (get_by_id(pwd1).value != get_by_id(pwd2).value){
  811.          //alert(msg[MATCH_PWD_ERROR]);
  812.          alert(YM102);
  813.         return false;
  814.     }
  815.     return true;
  816. }
  817.  
  818. function check_port(port){
  819.     var temp_port = port.split(" ");
  820.    
  821.     if (isNaN(port) || port == "" || temp_port.length > 1
  822.             || (parseInt(port) < 1 || parseInt(port) > 65535)){
  823.          return false;
  824.     }
  825.     return true;
  826. }
  827.  
  828. function check_radius(radius){
  829.     if (!check_address(radius.ip)){
  830.         return false;
  831.     }else if (!check_port(radius.port)){
  832.         alert(radius.ip.e_msg[RADIUS_SERVER_PORT_ERROR]);
  833.         return false;
  834.     }else if (radius.secret == ""){
  835.         alert(radius.ip.e_msg[RADIUS_SERVER_SECRET_ERROR]);
  836.         return false;              
  837.     }
  838.    
  839.     return true;
  840. }
  841.  
  842. function check_ssid(id){
  843.     if (get_by_id(id).value == ""){
  844.         alert(msg[SSID_EMPTY_ERROR]);
  845.         return false;
  846.     }
  847.     return true;        
  848. }
  849.  
  850. function check_varible(obj){
  851.     var temp_obj = obj.var_value.split(" ");
  852.    
  853.     if (temp_obj == "" || temp_obj.length > 1){
  854.         alert(obj.e_msg[EMPTY_VARIBLE_ERROR]);
  855.         return false;
  856.     }else if (isNaN(obj.var_value)){
  857.         alert(obj.e_msg[INVALID_VARIBLE_ERROR]);
  858.         return false;
  859.     }else if (parseInt(obj.var_value) < obj.min || parseInt(obj.var_value) > obj.max){
  860.         alert(obj.e_msg[VARIBLE_RANGE_ERROR]);
  861.         return false;
  862.     }else if (obj.is_even && (parseInt(obj.var_value) % 2 != 0)){
  863.         alert(obj.e_msg[EVEN_NUMBER_ERROR]);
  864.         return false;
  865.     }
  866.     return true;
  867. }
  868.  
  869. function check_pf_port(port){
  870.     var temp_port = port.split(" ");
  871.    
  872.     if (isNaN(port) || port == "" || temp_port.length > 1
  873.             || (parseInt(port) <= 0 || parseInt(port) > 65535)){
  874.         return false;
  875.     }
  876.     return true;
  877. }
  878.  
  879. function check_multi_port(remote_port, obj_port){
  880.     //multi-port: 25,80,110,443,50000-65535
  881.     var port_info = obj_port + ",";
  882.     var port = port_info.split(",");
  883.    
  884.     for(var i = 0; i < port.length; i++){
  885.         var port_range = port[i].split("-");
  886.         if(port_range.length > 1){
  887.             if(parseInt(port_range[0]) <= parseInt(remote_port) && parseInt(port_range[1]) >= parseInt(remote_port)){
  888.                 return false;
  889.             }
  890.         }else{
  891.             if(port[i] == remote_port){
  892.                 return false;
  893.             }
  894.         }
  895.     }
  896.     return true;
  897. }
  898.    
  899. function change_color(table_name, row){
  900.     var obj = get_by_id(table_name);
  901.     for (var i = 1; i < obj.rows.length; i++){
  902.         if (row == i){
  903.             obj.rows[i].style.backgroundColor = "#FFFF00";
  904.         }else{
  905.             obj.rows[i].style.backgroundColor = "#FFFFFF";
  906.         }
  907.     }      
  908. }
  909.  
  910. function exit_wizard(){
  911.     //if (confirm(msg[QUIT_WIZARD])){
  912.     if (confirm(_wizquit)){
  913.         window.close();
  914.     }
  915. }
  916.  
  917. function exit_access(){
  918.     //if (confirm(msg[QUIT_WIZARD])){
  919.     if (confirm(_wizquit)){
  920.         window.location.href = "adv_access_control.asp";
  921.     }
  922. }
  923.  
  924. function get_by_id(id){
  925.     with(document){
  926.         return getElementById(id);
  927.     }
  928. }
  929.  
  930. function get_by_name(name){
  931.     with(document){
  932.         return getElementsByName(name);
  933.     }
  934. }
  935.  
  936. function openwin(url,w,h) {
  937.     var winleft = (screen.width - w) / 2;
  938.     var wintop = (screen.height - h) / 2;
  939.     window.open(url,"popup",'width='+w+',height='+h+',top='+wintop+',left='+winleft+',scrollbars=yes,status=no,location=no,resizable=yes')
  940. }  
  941.  
  942. function send_submit(which_form){
  943.     get_by_id(which_form).submit();
  944. }
  945.  
  946. function set_server(is_enable){
  947.     var enable = get_by_id("enable");
  948.    
  949.     if (is_enable == "1"){
  950.         enable[0].checked = true;
  951.     }else{
  952.         enable[1].checked = true;
  953.     }
  954. }
  955.  
  956. function set_protocol(which_value, obj){
  957.     for (var i = 0; i < 3; i++){    
  958.         if (which_value == obj.options[i].value){
  959.             obj.selectedIndex = i;
  960.             break;
  961.         }
  962.     }
  963. }
  964.  
  965. function set_schedule(data, index){
  966.     var schd = get_by_name("schd");  
  967.    
  968.     if (data[index] == "0"){
  969.         schd[0].checked = true;      
  970.     }else{
  971.         schd[1].checked = true;        
  972.     }
  973.    
  974.     get_by_id("hour1").selectedIndex = data[index+1];
  975.     get_by_id("min1").selectedIndex = data[index+2];
  976.     get_by_id("am1").selectedIndex = data[index+3];
  977.     get_by_id("hour2").selectedIndex = data[index+4];
  978.     get_by_id("min2").selectedIndex = data[index+5];
  979.     get_by_id("am2").selectedIndex = data[index+6];
  980.     get_by_id("day1").selectedIndex = data[index+7];
  981.     get_by_id("day2").selectedIndex = data[index+8];
  982. }
  983.  
  984. function set_selectIndex(which_value, obj){
  985.     for (var pp=0; pp<obj.options.length; pp++){
  986.         if (which_value == obj.options[pp].value){
  987.             obj.selectedIndex = pp;
  988.             break;
  989.         }
  990.     }
  991. }
  992.    
  993. function set_checked(which_value, obj){
  994.     if(obj.length > 1){
  995.         obj[0].checked = true;
  996.         for(var pp=0;pp<obj.length;pp++){
  997.             if(obj[pp].value == which_value){
  998.                 obj[pp].checked = true;
  999.             }
  1000.         }
  1001.     }else{
  1002.         obj.checked = false;
  1003.         if(obj.value == which_value){
  1004.             obj.checked = true;
  1005.         }
  1006.     }
  1007. }
  1008.  
  1009. function get_checked_value(obj){
  1010.     if(obj.length > 1){
  1011.         for(pp=0;pp<obj.length;pp++){
  1012.             if(obj[pp].checked){
  1013.                 return obj[pp].value;
  1014.             }
  1015.         }
  1016.     }else{
  1017.         if(obj.checked){
  1018.             return obj.value;
  1019.         }else{
  1020.             return 0;
  1021.         }
  1022.     }  
  1023. }
  1024.  
  1025. function set_schedule_option(){
  1026.     for (var i = 0; i < 32; i++){
  1027.         var temp_sch = get_by_id("schedule_rule_" + i).value;
  1028.         var temp_data = temp_sch.split("/");
  1029.        
  1030.         if (temp_data.length > 1){
  1031.             document.write("<option value=" + temp_data[0] + ">" + temp_data[0] + "</option>");
  1032.         }
  1033.     }
  1034. }
  1035.  
  1036. function set_inbound_option(obj_value, idx){
  1037.     for (var i = 0; i < 24; i++){
  1038.         var k=i;
  1039.         if(parseInt(i,10)<10){
  1040.             k="0"+i;
  1041.         }
  1042.         var temp_inb = get_by_id("inbound_filter_name_" + k).value;
  1043.         var temp_data = temp_inb.split("/");
  1044.        
  1045.         if (temp_data.length > 1){
  1046.             obj_value += "<option value='" + temp_data[0] + "'>" + temp_data[0] + "</option>";
  1047.             load_inbound_used(k, temp_data, idx);
  1048.         }else{
  1049.             break;
  1050.         }
  1051.     }
  1052.     return obj_value;
  1053. }
  1054.  
  1055. function load_inbound_used(jj, obj_array, idx){
  1056.     if(obj_array[2].charAt(idx) == "1"){
  1057.         var is_used = "";
  1058.         if(idx == 0){
  1059.             is_used = "0"+ obj_array[2].substring(1,obj_array[2].length);
  1060.         }else if(idx == 1){
  1061.             is_used = obj_array[2].charAt(0) + "0"+ obj_array[2].substring(2,obj_array[2].length);
  1062.         }else if(idx == 2){
  1063.             is_used = obj_array[2].substring(0,2) + "0"+ obj_array[2].charAt(obj_array[2].length-1);
  1064.         }else if(idx == 3){
  1065.             is_used = obj_array[2].substr(0,obj_array[2].length-1) + "0";
  1066.         }
  1067.         get_by_id("inbound_filter_name_" + jj).value = obj_array[0] +"/"+ obj_array[1] +"/"+ is_used;
  1068.     }
  1069. }
  1070.  
  1071. function save_inbound_used(chk_value, idx){
  1072.     for (var i = 0; i < 24; i++){
  1073.         var k=i;
  1074.         if(parseInt(i,10)<10){
  1075.             k="0"+i;
  1076.         }
  1077.         var temp_inb = get_by_id("inbound_filter_name_" + k).value;
  1078.         var temp_data = temp_inb.split("/");
  1079.        
  1080.         if (temp_data.length > 1){
  1081.             var is_used = temp_data[2];
  1082.             if(temp_data[0] == chk_value){
  1083.                 if(idx == 0){
  1084.                     is_used = "1"+ temp_data[2].substring(1,temp_data[2].length);
  1085.                 }else if(idx == 1){
  1086.                     is_used = temp_data[2].charAt(0) + "1"+ temp_data[2].substring(2,temp_data[2].length);
  1087.                 }else if(idx == 2){
  1088.                     is_used = temp_data[2].substring(0,2) + "1"+ temp_data[2].charAt(temp_data[2].length-1);
  1089.                 }else if(idx == 3){
  1090.                     is_used = temp_data[2].substr(0,temp_data[2].length-1) + "1";
  1091.                 }
  1092.             }
  1093.             get_by_id("inbound_filter_name_" + k).value = temp_data[0] +"/"+ temp_data[1] +"/"+ is_used;
  1094.         }else{
  1095.             break;
  1096.         }
  1097.     }
  1098. }
  1099.  
  1100. function set_dhcp_list(){
  1101.     var temp_dhcp_list = get_by_id("dhcp_list").value.split(",");
  1102.    
  1103.     for (var i = 0; i < temp_dhcp_list.length; i++){   
  1104.         var temp_data = temp_dhcp_list[i].split("/");
  1105.         if(temp_data.length > 1){      
  1106.         document.write("<option value='" + temp_data[1] + "'>" + temp_data[0] + "</option>");  
  1107.         }
  1108.     }
  1109. }
  1110.  
  1111. function set_mac_list(parameter){
  1112.     var temp_dhcp_list = get_by_id("dhcp_list").value.split(",");
  1113.    
  1114.     for (var i = 0; i < temp_dhcp_list.length; i++){   
  1115.         var temp_data = temp_dhcp_list[i].split("/");
  1116.         if(temp_data.length > 1){      
  1117.             if(parameter == "mac"){
  1118.                 document.write("<option value='" + temp_data[2] + "'>" + temp_data[0] + " (" + temp_data[2] + " )" + "</option>");     
  1119.             }else if(parameter == "ip"){
  1120.                 document.write("<option value='" + temp_data[1] + "'>" + temp_data[0] + " (" + temp_data[1] + " )" + "</option>");     
  1121.             }else{
  1122.                 document.write("<option value='" + temp_data[2] + "'>" + temp_data[0] + "</option>");
  1123.             }
  1124.         }
  1125.     }
  1126. }
  1127.  
  1128. function set_mac(mac){
  1129.     var temp_mac = mac.split(":");
  1130.     for (var i = 0; i < 6; i++){
  1131.         var obj = get_by_id("mac" + (i+1));
  1132.         obj.value = temp_mac[i];
  1133.     }
  1134. }
  1135.  
  1136. function show_dns(type){
  1137.     if (type){
  1138.         get_by_id("dns1").value = "0.0.0.0";
  1139.         get_by_id("dns2").value = "0.0.0.0";
  1140.     }
  1141. }
  1142.  
  1143. function show_wizard(name){
  1144.     window.open(name,"Wizard","width=450,height=370");
  1145. }
  1146.  
  1147. function show_window(name){
  1148.     window.open(name,"Window","width=500,height=600,scrollbar=yes");
  1149. }
  1150.  
  1151. function show_schedule_detail(idx){
  1152.     var temp_rule, detail;
  1153.     temp_rule = get_by_id("schedule_rule_" + idx).value;
  1154.  
  1155.     var rule = temp_rule.split("/");                   
  1156.     var s = new Array();
  1157.    
  1158.     for(var j = 0; j < 8; j++){
  1159.         if(rule[1].charAt(j) == "1"){
  1160.             s[j] = "1";
  1161.         }else{
  1162.             s[j] = "0";
  1163.         }
  1164.     }
  1165.  
  1166.     var s_day = "", count = 0;
  1167.     for(var j = 0; j < 8; j++){        
  1168.         if(s[j] == "1"){
  1169.             s_day = s_day + " " + Week[j];
  1170.             count++;
  1171.         }
  1172.     }
  1173.  
  1174.     if(count == 7){
  1175.         s_day = "All week";
  1176.     }
  1177.            
  1178.     var temp_time_array = rule[2] + "~" + rule[3];
  1179.     if(rule[2] == "00:00" && rule[3] == "24:00"){
  1180.         temp_time_array = "All Day";
  1181.     }
  1182.    
  1183.     detail = s_day + " " + temp_time_array;
  1184.     return detail;
  1185. }
  1186.  
  1187. function get_row_data(obj, index){ 
  1188.        
  1189.     try {
  1190.         return obj.cells[index].childNodes[0].data;
  1191.     }catch(e) {
  1192.         return ("");
  1193.     }
  1194. }
  1195.  
  1196. function copy_virtual(index){
  1197.     var data;
  1198.    
  1199.     if (get_by_id("application" + index).selectedIndex > 0){
  1200.         data = default_virtual[get_by_id("application" + index).selectedIndex - 1];    
  1201.         get_by_id("name" + index).value = data.name;
  1202.         get_by_id("public_portS" + index).value = data.public_port;
  1203.         get_by_id("private_portS" + index).value = data.private_port;
  1204.         get_by_id("protocol" + index).value = data.prot;
  1205.         set_vs_protocol(index, data.prot, get_by_id("protocol_select" + index));   
  1206.     }else{
  1207.         //alert(msg[SELECT_APPLICATION_ERROR]);
  1208.         alert(GW_NAT_NAME_INVALID);
  1209.     }      
  1210. }
  1211.  
  1212. function copy_portforward(index){
  1213.     var data;
  1214.    
  1215.     if (get_by_id("application" + index).selectedIndex > 0){
  1216.         data = default_rule[get_by_id("application" + index).selectedIndex - 1];       
  1217.         get_by_id("name" + index).value = data.name;
  1218.         get_by_id("tcp_ports" + index).value = data.public_port;
  1219.         //get_by_id("public_portE" + index).value = data.public_port;
  1220.         get_by_id("udp_ports" + index).value = data.private_port;
  1221.         //get_by_id("private_portE" + index).value = data.private_port;
  1222.         //set_protocol(data.prot, get_by_id("protocol" + index));  
  1223.     }else{
  1224.         //alert(msg[SELECT_APPLICATION_ERROR]);
  1225.         alert(GW_NAT_NAME_INVALID);
  1226.     }      
  1227. }
  1228.  
  1229. function copy_special_appl(index){
  1230.     var name = get_by_id("name" + index);
  1231.     var trigger_port = get_by_id("trigger_port" + index);
  1232.     var trigger_type = get_by_id("trigger" + index);
  1233.     var public_port = get_by_id("public_port" + index);
  1234.     var public_type = get_by_id("public" + index);
  1235.     var application = get_by_id("application" + index);    
  1236.     var data;
  1237.    
  1238.     if (application.selectedIndex > 0){
  1239.         data = default_appl[application.selectedIndex - 1];
  1240.         name.value = data.name;    
  1241.         trigger_port.value = data.trigger_port;        
  1242.         public_port.value = data.public_port;              
  1243.         set_protocol(data.trigger_prot, trigger_type);  
  1244.         set_protocol(data.public_prot, public_type);           
  1245.     }else{
  1246.         //alert(msg[SELECT_APPLICATION_ERROR]);
  1247.         alert(GW_NAT_NAME_INVALID);
  1248.     }
  1249.    
  1250. }
  1251.  
  1252. function copy_ip(index){
  1253.  
  1254.     if (get_by_id("ip_list" + index).selectedIndex > 0){
  1255.         get_by_id("ip" + index).value = get_by_id("ip_list" + index).options[get_by_id("ip_list" + index).selectedIndex].value;
  1256.     }else{
  1257.         alert(msg[SELECT_COMPUTER_ERROR]);
  1258.     }
  1259. }
  1260.  
  1261. function get_random_char(){
  1262.     var number_list = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  1263.     var number = Math.round(Math.random()*62);
  1264.    
  1265.     return(number_list.substring(number, number + 1));
  1266. }
  1267.  
  1268. function generate_psk(key){
  1269.     var i = key.length;
  1270.    
  1271.     if (key.length < 8){
  1272.         for (; i < 8; i++){
  1273.             key += get_random_char();
  1274.         }
  1275.     }
  1276.  
  1277.     return key;
  1278. }
  1279.  
  1280. function create_wep_key128(passpharse, pharse_len){
  1281.     var pseed2 = "";
  1282.     var md5_str = "";
  1283.     var count;
  1284.    
  1285.    
  1286.     for(var i = 0; i < 64; i++){
  1287.         count = i % pharse_len;
  1288.         pseed2 += passpharse.substring(count, count+1);
  1289.     }
  1290.    
  1291.     md5_str = calcMD5(pseed2);  
  1292.    
  1293.     return md5_str.substring(0, 26).toUpperCase();
  1294. }
  1295. function check_ascii_key_fun(data){
  1296.  
  1297.     if (!(data >= 'A' && data <= 'Z') && !(data >= '0' && data <= '9') && !(data >= 'a' && data <= 'z')){  
  1298.         return false;
  1299.     }  
  1300.     return true;
  1301. }
  1302.  
  1303. function check_name_key_fun(data){
  1304.     if (!(data >= 'A' && data <= 'Z') && !(data >= '0' && data <= '9') && !(data >= 'a' && data <= 'z') && !(data == "-") && !(data == "_")){
  1305.         return false;
  1306.     }  
  1307.     return true;
  1308. }
  1309.  
  1310. function _isNumeric(str) {
  1311.         var i;
  1312.         for(i = 0; i<str.length; i++) {
  1313.             var c = str.substring(i, i+1);
  1314.             if("0" <= c && c <= "9") {
  1315.                 continue;
  1316.             }
  1317.             return false;
  1318.         }
  1319.         return true;
  1320.     }
  1321.  
  1322. function check_name_word_fun(obj,word){
  1323.     for(var k=0;k<obj.length;k++){
  1324.         if (!check_name_key_fun(obj.substring(k, k+1))){
  1325.             alert(word+" invalid. the legal characters are 0~9, A~Z, or a~z,-,_.");
  1326.             return false;
  1327.         }
  1328.     }
  1329.     return true;
  1330. }
  1331.  
  1332. function Find_word(strOrg,strFind){
  1333.     var index = 0;
  1334.     index = strOrg.indexOf(strFind,index);
  1335.     if (index > -1){
  1336.         return true;
  1337.     }
  1338.     return false;
  1339. }
  1340.  
  1341. function a_to_hex(inValue) {
  1342.     var outValue = "";
  1343.     if (inValue) {
  1344.         for (i = 0; i < inValue.length; i++) {
  1345.             if(inValue.charCodeAt(i).toString(16) < 10)
  1346.                 outValue += 0;
  1347.             if(inValue.charCodeAt(i).toString(16) > 'a' && inValue.charCodeAt(i).toString(16) <= 'f')
  1348.                 if(inValue.charCodeAt(i).toString(16).length == 1)
  1349.                     outValue += 0;
  1350.             outValue += inValue.charCodeAt(i).toString(16);
  1351.         }
  1352.     }
  1353.     return outValue;
  1354. }
  1355.  
  1356. function hex_to_a(inValue){
  1357.     outValue = "";
  1358.     var k = '';
  1359.     for (i = 0; i < inValue.length; i++) {
  1360.         l = i % 2;
  1361.         if (l == 0)
  1362.             k += "%";
  1363.         k += inValue.substr(i, 1);
  1364.     }
  1365.     outValue = unescape(k);
  1366.     return outValue;
  1367. }
  1368.  
  1369. function change_word(inValue,strFind,strAdd){
  1370.     var outValue = "";
  1371.     for(var i=0;i<inValue.length;i++){
  1372.         if(inValue.substr(i,1) == strFind)
  1373.             outValue = outValue + strAdd;
  1374.         outValue += inValue.substr(i,1);
  1375.     }
  1376.     return outValue;
  1377. }
  1378.  
  1379. function ReplaceAll(strOrg,strFind,strReplace){
  1380.     var index = 0;
  1381.     while(strOrg.indexOf(strFind,index) != -1){
  1382.             strOrg = strOrg.replace(strFind,strReplace);
  1383.             index = strOrg.indexOf(strFind,index);
  1384.     }
  1385.     return strOrg
  1386. }
  1387.  
  1388. function addstr(input_msg)
  1389. {
  1390.     var last_msg = "";
  1391.     var str_location;
  1392.     var temp_str_1 = "";
  1393.     var temp_str_2 = "";
  1394.     var str_num = 0;
  1395.     temp_str_1 = addstr.arguments[0];
  1396.     while(1)
  1397.     {
  1398.         str_location = temp_str_1.indexOf("%s");
  1399.         if(str_location >= 0)
  1400.         {
  1401.             str_num++;
  1402.             temp_str_2 = temp_str_1.substring(0,str_location);
  1403.             last_msg += temp_str_2 + addstr.arguments[str_num];
  1404.             temp_str_1 = temp_str_1.substring(str_location+2,temp_str_1.length);
  1405.             continue;
  1406.         }
  1407.         if(str_location < 0)
  1408.         {
  1409.             last_msg += temp_str_1;
  1410.             break;
  1411.         }
  1412.     }
  1413.     return last_msg;
  1414. }
  1415.  
  1416. function replace_msg(obj_S){
  1417.     obj_D = new Array();
  1418.     for (i=0;i<obj_S.length;i++){
  1419.         obj_D[i] = addstr(obj_S[i], replace_msg.arguments[1]);
  1420.         obj_D[i] = obj_D[i].replace("%1n", replace_msg.arguments[2]);
  1421.         obj_D[i] = obj_D[i].replace("%2n", replace_msg.arguments[3]);
  1422.     }
  1423.     return obj_D;
  1424. }
  1425. function ip_num(IP_array){
  1426.     var total1 = 0;
  1427.     if(IP_array.length > 1){
  1428.         total1 += parseInt(IP_array[3],10);
  1429.         total1 += parseInt(IP_array[2],10)*256;
  1430.         total1 += parseInt(IP_array[1],10)*256*256;
  1431.         total1 += parseInt(IP_array[0],10)*256*256*256;
  1432.     }
  1433.     return total1;
  1434. }
  1435.  
  1436. function check_LAN_ip(LAN_IP, CHK_IP, obj_name){
  1437.     if(ip_num(LAN_IP) == ip_num(CHK_IP)){
  1438.         //alert(addstr(msg[THE_SAME_LAN_IP], obj_name));
  1439.         alert(addstr(LW1, obj_name));
  1440.         return false;
  1441.     }
  1442.     return true;
  1443. }
  1444.  
  1445. function isHex(str) {
  1446.     var i;
  1447.     for(i = 0; i<str.length; i++) {
  1448.         var c = str.substring(i, i+1);
  1449.         if(("0" <= c && c <= "9") || ("a" <= c && c <= "f") || ("A" <= c && c <= "F")) {
  1450.             continue;
  1451.         }
  1452.         return false;
  1453.     }
  1454.     return true;
  1455. }
  1456.  
  1457. function open_more(rule_num, num, is_hidden, obj){
  1458.     var open_word = "none";
  1459.     get_by_id("show_more_word").style.display = "";
  1460.     get_by_id("show_less_word").style.display = "none";
  1461.     if(is_hidden){
  1462.         get_by_id("show_more_word").style.display = "none";
  1463.         get_by_id("show_less_word").style.display = "";
  1464.         open_word = "";
  1465.     }
  1466.     var start_num = parseInt(rule_num-1,10);
  1467.     for(j=start_num;j>=num;j--){
  1468.         get_by_id(obj+j).style.display = open_word;
  1469.     }
  1470. }
  1471.  
  1472. /*Date Used, copy by Netgear*/
  1473. function getDaysInMonth(mon,year)
  1474. {
  1475.     var days;
  1476.     if (mon==1 || mon==3 || mon==5 || mon==7 || mon==8 || mon==10 || mon==12) days=31;
  1477.     else if (mon==4 || mon==6 || mon==9 || mon==11) days=30;
  1478.     else if (mon==2)
  1479.     {
  1480.         if (isLeapYear(year)) { days=29; }
  1481.         else { days=28; }
  1482.     }
  1483.     return (days);
  1484. }
  1485.  
  1486. function isLeapYear (Year)
  1487. {
  1488.     if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
  1489.         return (true);
  1490.     } else { return (false); }
  1491. }
  1492.  
  1493. function key_word(newobj,obj){
  1494.     get_by_id(obj).value = newobj.value;
  1495. }
  1496.  
  1497. /*
  1498.  * is_form_modified
  1499.  *  Check if a form's current values differ from saved values in custom attribute.
  1500.  *  Function skips elements with attribute: 'modified'= 'ignore'.
  1501.  */
  1502. function is_form_modified(form_id)
  1503. {
  1504.     var df = document.forms[form_id];
  1505.     if (!df) {
  1506.         return false;
  1507.     }
  1508.     if (df.getAttribute('modified') == "true") {
  1509.         return true;
  1510.     }
  1511.     if (df.getAttribute('saved') != "true") {
  1512.         return false;
  1513.     }
  1514.     for (var i = 0, k = df.elements.length; i < k; i++) {
  1515.         var obj = df.elements[i];
  1516.         if (obj.getAttribute('modified') == 'ignore') {
  1517.             continue;
  1518.         }
  1519.         var name = obj.tagName.toLowerCase();
  1520.         if (name == 'input') {
  1521.             var type = obj.type.toLowerCase();
  1522.             if (((type == 'text') || (type == 'textarea') || (type == 'password') || (type == 'hidden')) &&
  1523.                     !are_values_equal(obj.getAttribute('default'), obj.value)) {
  1524.                 return true;
  1525.             } else if (((type == 'checkbox') || (type == 'radio')) && !are_values_equal(obj.getAttribute('default'), obj.checked)) {
  1526.                 return true;
  1527.             }
  1528.         } else if (name == 'select') {
  1529.             var opt = obj.options;
  1530.             for (var j = 0; j < opt.length; j++) {
  1531.                 if (!are_values_equal(opt[j].getAttribute('default'), opt[j].selected)) {
  1532.                     return true;
  1533.                 }
  1534.             }
  1535.         }
  1536.     }
  1537.     return false;
  1538. }
  1539.  
  1540. /*
  1541.  * set_form_default_values
  1542.  *  Save a form's current values to a custom attribute.
  1543.  */
  1544. function set_form_default_values(form_id)
  1545. {
  1546.     var df = document.forms[form_id];
  1547.     if (!df) {
  1548.         return;
  1549.     }
  1550.     for (var i = 0, k = df.elements.length; i < k; i++) {
  1551.         var obj = df.elements[i];
  1552.         if (obj.getAttribute('modified') == 'ignore') {
  1553.             continue;
  1554.         }
  1555.         var name = obj.tagName.toLowerCase();
  1556.         if (name == 'input') {
  1557.             var type = obj.type.toLowerCase();
  1558.             if ((type == 'text') || (type == 'textarea') || (type == 'password') || (type == 'hidden')) {
  1559.                 obj.setAttribute('default', obj.value);
  1560.                 /* Workaround for FF error when calling focus() from an input text element. */
  1561.                 if (type == 'text') {
  1562.                     obj.setAttribute('autocomplete', 'off');
  1563.                 }
  1564.             } else if ((type == 'checkbox') || (type == 'radio')) {
  1565.                 obj.setAttribute('default', obj.checked);
  1566.             }
  1567.         } else if (name == 'select') {
  1568.             var opt = obj.options;
  1569.             for (var j = 0; j < opt.length; j++) {
  1570.                 opt[j].setAttribute('default', opt[j].selected);
  1571.             }
  1572.         }
  1573.     }
  1574.     df.setAttribute('saved', "true");
  1575. }
  1576.  
  1577. /*
  1578.  * are_values_equal()
  1579.  *  Compare values of types boolean, string and number. The types may be different.
  1580.  *  Returns true if values are equal.
  1581.  */
  1582. function are_values_equal(val1, val2)
  1583. {
  1584.     /* Make sure we can handle these values. */
  1585.     switch (typeof(val1)) {
  1586.     case 'boolean':
  1587.     case 'string':
  1588.     case 'number':
  1589.         break;
  1590.     default:
  1591.         // alert("are_values_equal does not handle the type '" + typeof(val1) + "' of val1 '" + val1 + "'.");
  1592.         return false;
  1593.     }
  1594.  
  1595.     switch (typeof(val2)) {
  1596.     case 'boolean':
  1597.         switch (typeof(val1)) {
  1598.         case 'boolean':
  1599.             return (val1 == val2);
  1600.         case 'string':
  1601.             if (val2) {
  1602.                 return (val1 == "1" || val1.toLowerCase() == "true" || val1.toLowerCase() == "on");
  1603.             } else {
  1604.                 return (val1 == "0" || val1.toLowerCase() == "false" || val1.toLowerCase() == "off");
  1605.             }
  1606.             break;
  1607.         case 'number':
  1608.             return (val1 == val2 * 1);
  1609.         }
  1610.         break;
  1611.     case 'string':
  1612.         switch (typeof(val1)) {
  1613.         case 'boolean':
  1614.             if (val1) {
  1615.                 return (val2 == "1" || val2.toLowerCase() == "true" || val2.toLowerCase() == "on");
  1616.             } else {
  1617.                 return (val2 == "0" || val2.toLowerCase() == "false" || val2.toLowerCase() == "off");
  1618.             }
  1619.             break;
  1620.         case 'string':
  1621.             if (val2 == "1" || val2.toLowerCase() == "true" || val2.toLowerCase() == "on") {
  1622.                 return (val1 == "1" || val1.toLowerCase() == "true" || val1.toLowerCase() == "on");
  1623.             }
  1624.             if (val2 == "0" || val2.toLowerCase() == "false" || val2.toLowerCase() == "off") {
  1625.                 return (val1 == "0" || val1.toLowerCase() == "false" || val1.toLowerCase() == "off");
  1626.             }
  1627.             return (val2 == val1);
  1628.         case 'number':
  1629.             if (val2 == "1" || val2.toLowerCase() == "true" || val2.toLowerCase() == "on") {
  1630.                 return (val1 == 1);
  1631.             }
  1632.             if (val2 == "0" || val2.toLowerCase() == "false" || val2.toLowerCase() == "off") {
  1633.                 return (val1 === 0);
  1634.             }
  1635.             return (val2 == val1 + "");
  1636.         }
  1637.         break;
  1638.     case 'number':
  1639.         switch (typeof(val1)) {
  1640.         case 'boolean':
  1641.             return (val1 * 1 == val2);
  1642.         case 'string':
  1643.             if (val1 == "1" || val1.toLowerCase() == "true" || val1.toLowerCase() == "on") {
  1644.                 return (val2 == 1);
  1645.             }
  1646.             if (val1 == "0" || val1.toLowerCase() == "false" || val1.toLowerCase() == "off") {
  1647.                 return (val2 === 0);
  1648.             }
  1649.             return (val1 == val2 + "");
  1650.         case 'number':
  1651.             return (val2 == val1);
  1652.         }
  1653.         break;
  1654.     default:
  1655.         return false;
  1656.     }
  1657. }
  1658.  
  1659. function jump_if(){
  1660.     for (var i = 0; i < document.forms.length; i++) {
  1661.         if (is_form_modified(document.forms[i].id)) {
  1662.             if (!confirm(up_jt_1+"\n"+up_jt_2+"\n"+up_jt_3)){
  1663.                 return false;
  1664.             }
  1665.         }
  1666.     }
  1667.     return true;
  1668. }
  1669. function jump_3g_if(){
  1670.     get_by_id("asp_temp_72").value = get_by_id("usb_type").value
  1671.     send_submit('wwan_form');
  1672.     for (var i = 0; i < document.forms.length; i++) {
  1673.         if (is_form_modified(document.forms[i].id)) {
  1674.             if (!confirm(up_jt_1+"\n"+up_jt_2+"\n"+up_jt_3)){
  1675.                 return false;
  1676.             }
  1677.         }
  1678.     }
  1679.     return true;
  1680. }
  1681.  
  1682. /*
  1683.  * Cancel and reset changes to the page.
  1684.  */
  1685. function page_cancel_1(form_name, redirect_url){
  1686.     if (!is_form_modified(form_name) && confirm (up_fm_dc_1)) {
  1687.         window.location.href=redirect_url;
  1688.     }
  1689. }
  1690. function page_cancel(form_name, redirect_url){
  1691.     if (is_form_modified(form_name) && confirm (up_fm_dc_1)) {
  1692.         window.location.href=redirect_url;
  1693.     }
  1694. }
  1695.  
  1696. function page_reboot(){
  1697.     jump_if();
  1698.     window.location.href='reboot.asp'
  1699. }
  1700.  
  1701. /*
  1702.  * trim_string
  1703.  *  Remove leading and trailing blank spaces from a string.
  1704.  */
  1705. function trim_string(str)
  1706. {
  1707.     var trim = str + "";
  1708.     trim = trim.replace(/^\s*/, "");
  1709.     return trim.replace(/\s*$/, "");
  1710. }
  1711.  
  1712. /*
  1713.  * is_mac_valid()
  1714.  *  Check if a MAC address is in a valid form.
  1715.  *  Allow 00:00:00:00:00:00 and FF:FF:FF:FF:FF:FF if optional argument is_full_range is true.
  1716.  */
  1717. function is_mac_valid(mac, is_full_range)
  1718. {
  1719.     var macstr = mac + "";
  1720.     var got = macstr.match(/^[0-9a-fA-F]{2}[:-]?[0-9a-fA-F]{2}[:-]?[0-9a-fA-F]{2}[:-]?[0-9a-fA-F]{2}[:-]?[0-9a-fA-F]{2}[:-]?[0-9a-fA-F]{2}$/);
  1721.     if (!got) {
  1722.         return false;
  1723.     }
  1724.     macstr = macstr.replace (/[:-]/g, '');
  1725.     if (!is_full_range && (macstr.match(/^0{12}$/) || macstr.match(/^[fF]{12}$/))) {
  1726.         return false;
  1727.     }
  1728.  
  1729.     return true;
  1730. }
  1731.  
  1732. /*
  1733.  * is_ipv4_valid
  1734.  *  Check is an IP address dotted string is valid.
  1735.  */
  1736. function is_ipv4_valid(ipaddr)
  1737. {
  1738.     var ip = ipv4_to_bytearray(ipaddr);
  1739.     if (ip === 0) {
  1740.         return false;
  1741.     }
  1742.     return true;
  1743. }
  1744.  
  1745. /*
  1746.  * ipv4_to_bytearray
  1747.  *  Convert an IPv4 address dotted string to a byte array
  1748.  */
  1749. function ipv4_to_bytearray(ipaddr)
  1750. {
  1751.     var ip = ipaddr + "";
  1752.     var got = ip.match (/^\s*(\d{1,3})\s*[.]\s*(\d{1,3})\s*[.]\s*(\d{1,3})\s*[.]\s*(\d{1,3})\s*$/);
  1753.     if (!got) {
  1754.         return 0;
  1755.     }
  1756.     var a = [];
  1757.     var q = 0;
  1758.     for (var i = 1; i <= 4; i++) {
  1759.         q = parseInt(got[i],10);
  1760.         if (q < 0 || q > 255) {
  1761.             return 0;
  1762.         }
  1763.         a[i-1] = q;
  1764.     }
  1765.     return a;
  1766. }
  1767.  
  1768. function check_ipv4_symbol(strOrg,strFind){
  1769.     /* Search ipv4_address has "." symbol */   
  1770.     /*if false return 0, otherwises return 1 */
  1771.     var index = 0;
  1772.     index = strOrg.indexOf(strFind,index);
  1773.  
  1774.     if(index == -1)
  1775.             return 0;
  1776.     else
  1777.             return 1;              
  1778.             }
  1779.            
  1780.            
  1781.            
  1782. function transValue(data)
  1783. {
  1784.     var value =0;
  1785.     data = data.toUpperCase();
  1786.    
  1787.     if(data == "0")
  1788.         value =0;
  1789.     else if(data =="1")
  1790.         value = 1;
  1791.     else if(data =="2")
  1792.         value = 2;
  1793.     else if(data =="3")
  1794.         value = 3;
  1795.     else if(data =="4")
  1796.         value = 4; 
  1797.     else if(data =="5")
  1798.         value = 5;
  1799.     else if(data =="6")
  1800.         value = 6;
  1801.     else if(data =="7")
  1802.         value = 7;
  1803.     else if(data =="8")
  1804.         value = 8;
  1805.     else if(data =="9")
  1806.         value = 9;
  1807.     else if(data =="A")
  1808.         value = 10;
  1809.     else if(data =="B")
  1810.         value = 11;
  1811.     else if(data =="C")
  1812.         value = 12;
  1813.     else if(data =="D")
  1814.         value = 13;
  1815.     else if(data =="E")
  1816.         value = 14;
  1817.     else if(data =="F")
  1818.         value = 15;            
  1819.     else
  1820.         value = 0;
  1821.     return value ;             
  1822. }                                                                                                                                         ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  1823.  
  1824.  
  1825.  
  1826.  
  1827. function check_symbol(strOrg,strFind){
  1828.     var index = 0;
  1829.     index = strOrg.indexOf(strFind,index);
  1830.     return index;
  1831. }
  1832.  
  1833. function find_colon(strOrg,strFind)
  1834. {
  1835.         var index=0;
  1836.         var colon=0;
  1837.         index = strOrg.indexOf(strFind,index);
  1838.         while(index != -1)
  1839.         {
  1840.                 colon++;
  1841.                 index++;
  1842.                 index = strOrg.indexOf(strFind,index);
  1843.         }
  1844.         return colon;                
  1845. }
  1846.  
  1847. function count_colon_pos(strOrg,strFind,count)
  1848. {
  1849.         var index =0;
  1850.         var i=0;
  1851.        
  1852.         for(i=0;i<count;i++){
  1853.                 index = strOrg.indexOf(strFind,index);
  1854.                 index++;        
  1855.         }
  1856.         return index;                
  1857. }
  1858.  
  1859. function count_last_colon_pos(strOrg,strFind)
  1860. {
  1861.                 var index =0;
  1862.                 var pos=0;
  1863.        
  1864.         while(1){
  1865.                 index = strOrg.indexOf(strFind,index);
  1866.                 if(index == -1)
  1867.                         break;
  1868.                 pos = index;       
  1869.                 index++;               
  1870.         }
  1871.         return pos;        
  1872. }
  1873. function compare_suffix(start_suffix,end_suffix)
  1874. {
  1875.     var start_suffix_length = start_suffix.length;
  1876.     var end_suffix_length = end_suffix.length;
  1877.    
  1878.     var start_suffix_value =0;
  1879.     var end_suffix_value=0;
  1880.    
  1881.     //calculate the start_suffix
  1882.     if(start_suffix_length == 1){
  1883.         start_suffix_value = transValue(start_suffix.charAt(0)) * 1;
  1884.     }else if(start_suffix_length == 2){
  1885.         start_suffix_value = transValue(start_suffix.charAt(0)) * 16;
  1886.         start_suffix_value += transValue(start_suffix.charAt(1)) * 1;
  1887.     }else if(start_suffix_length == 3){
  1888.         start_suffix_value = transValue(start_suffix.charAt(0)) * 256;
  1889.         start_suffix_value += transValue(start_suffix.charAt(1)) * 16;
  1890.         start_suffix_value += transValue(start_suffix.charAt(2)) * 1;
  1891.     }else if(start_suffix_length == 4){
  1892.         start_suffix_value = transValue(start_suffix.charAt(0)) * 4096;
  1893.         start_suffix_value += transValue(start_suffix.charAt(1)) * 256;
  1894.         start_suffix_value += transValue(start_suffix.charAt(2)) * 16;
  1895.         start_suffix_value += transValue(start_suffix.charAt(3)) * 1;
  1896.     }
  1897.    
  1898.     //calculate the end_suffix
  1899.     if(end_suffix_length == 1){
  1900.         end_suffix_value = transValue(end_suffix.charAt(0)) * 1;
  1901.     }else if(end_suffix_length == 2){
  1902.         end_suffix_value = transValue(end_suffix.charAt(0)) * 16;
  1903.         end_suffix_value += transValue(end_suffix.charAt(1)) * 1;
  1904.     }else if(end_suffix_length == 3){
  1905.         end_suffix_value = transValue(end_suffix.charAt(0)) * 256;
  1906.         end_suffix_value += transValue(end_suffix.charAt(1)) * 16;
  1907.         end_suffix_value += transValue(end_suffix.charAt(2)) * 1;
  1908.     }else if(end_suffix_length == 4){
  1909.         end_suffix_value = transValue(end_suffix.charAt(0)) * 4096;
  1910.         end_suffix_value += transValue(end_suffix.charAt(1)) * 256;
  1911.         end_suffix_value += transValue(end_suffix.charAt(2)) * 16;
  1912.         end_suffix_value += transValue(end_suffix.charAt(3)) * 1;
  1913.     }
  1914.        
  1915.     if(start_suffix_value >= end_suffix_value){
  1916.         alert(MSG040);
  1917.         return false;  
  1918.     }
  1919.     return true;
  1920. }
  1921. function show_words(word){
  1922. with(document){
  1923.     return write(word);
  1924. }
  1925. }
  1926.  
  1927. function open_more(rule_num, num, is_hidden, obj){
  1928.     var open_word = "none";
  1929.     get_by_id("show_more_word").style.display = "";
  1930.     get_by_id("show_less_word").style.display = "none";
  1931.     if(is_hidden){
  1932.         get_by_id("show_more_word").style.display = "none";
  1933.         get_by_id("show_less_word").style.display = "";
  1934.         open_word = "";
  1935.     }
  1936.     var start_num = parseInt(rule_num-1,10);
  1937.     for(j=start_num;j>=num;j--){
  1938.         get_by_id(obj+j).style.display = open_word;
  1939.     }
  1940. }
  1941.  
  1942. /* GraceYang
  1943. Disable All Form Elements
  1944.  */
  1945. function DisableEnableForm(xForm,xHow){
  1946.   objElems = xForm.elements;
  1947.   for(i=0;i<objElems.length;i++){
  1948.     objElems[i].disabled = xHow;
  1949.   }
  1950. }
  1951. //Set Language & Response URL - GraceYang 20090217
  1952. function set_lang(){
  1953.         //var url = document.URL.split("/");
  1954.         get_by_id("language").value = get_by_id("site").value;
  1955.         //get_by_id("html_response_lang").value = url[3];
  1956.         send_submit('lang_form');
  1957.    }
  1958.    
  1959. function get_lang(){
  1960.          set_selectIndex(get_by_id("language").value, get_by_id("site"));
  1961.    }
  1962.    
  1963. //Get schedule value - Tina Tsao 20090410
  1964. function get_schedule_value(idx){
  1965.     var tmp_schedule_index = get_by_id("schedule" + idx).selectedIndex;
  1966.     var schedule;
  1967.     if (tmp_schedule_index > 1){
  1968.         schedule = get_by_id("schedule_rule_" + (tmp_schedule_index-2)).value;
  1969.     }else if (tmp_schedule_index == 0){
  1970.         schedule = "Always";
  1971.     }else if (tmp_schedule_index == 1){
  1972.         schedule = "Never";
  1973.     }
  1974.     return schedule;
  1975. }
  1976.              
  1977.              
  1978. //Get schedule index - Tina Tsao 20090410
  1979. function get_schedule_index(which_value){
  1980.     var idx;
  1981.     for (var j = 0; j < 32; j++){
  1982.         var temp_sch = get_by_id("schedule_rule_" + j).value;
  1983.         var temp = temp_sch.split("/");
  1984.         if(which_value == temp[0]){
  1985.             idx = j;
  1986.         }
  1987.     }  
  1988.     return idx;
  1989. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement