1/*general*/
2var nav;
3var change;
4var keyPressed;
5var wItem;
6var ip = "";
7var ip_addr = '<!--#echo var="REMOTE_ADDR"-->';
8var chanList = 0;
9var wep1, wep2, wep3, wep4;
10var varload=0;
11var final_flag = 0;
12if (navigator.appName == 'Netscape')
13{nav = true;
14}
15else
16{nav = false;
17document.onkeydown = MicrosoftEventHandler_KeyDown;
18}
19function NetscapeEventHandler_KeyDown(e)
20{keyPressed = e.which;
21if (keyPressed<48 && keyPressed!=16)
22{keyPressed = 0;
23}
24return true;
25}
26function IEKey()
27{window.top.pageChanged = 1;
28return (event.keyCode);
29}
30function NSKey()
31{window.top.pageChanged = 1;
32return(0);
33}
34function changeDate()
35{window.top.pageChanged = 1;
36return true;
37}
38function MicrosoftEventHandler_KeyDown()
39{/* if (keyPressed == 13  && event.srcElement.type != 'button' && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
40return false;
41return true;*/
42return true;
43}
44function inputCtrl(o, flag)
45{if (flag == 0)
46{o.disabled = 1;
47o.style.backgroundColor = "gray";
48}
49else
50{o.disabled = 0;
51o.style.backgroundColor = "white";
52}
53}
54function str2val(v)
55{for(i=0; i<v.length; i++)
56{if (v.charAt(i) !='0') break;
57}
58return v.substring(i);
59}
60function inputRCtrl1(o, flag)
61{if (flag == 0)
62{o[0].disabled = 1;
63o[1].disabled = 1;
64}
65else
66{o[0].disabled = 0;
67o[1].disabled = 0;
68}
69}
70function inputRCtrl2(o, flag)
71{if (flag == 0)
72{o[0].checked = true;
73o[1].checked = false;
74}
75else
76{o[0].checked = false;
77o[1].checked = true;
78}
79}
80function buttonOver(o)
81{o.style.backgroundColor = "#FFFFCC";
82o.style.cursor="hand";
83}
84function buttonOut(o) {
85o.style.backgroundColor = "#C0C0C0";
86}
87function checkPass(o, o1, o2)
88{if (o1.value==o2.value)
89{document.form.action_mode.value = "  Save  ";
90return true;
91}
92alert('<#JS_checkpass#>');
93return false;
94}
95function markGroup(o, s, c, b) {
96var bFlag, cFlag;
97document.form.group_id.value = s;
98bFlag = 0;
99cFlag = 0;
100if (b == " Add ")
101{if (s=='RBRList')
102{if (document.form.wl_wdsnum_x_0.value >= c) cFlag=1;
103else if (!validate_hwaddr(document.form.wl_wdslist_x_0)) return false;
104else if (document.form.wl_wdslist_x_0.value=="") bFlag=1;
105else if (!validate_duplicate(document.form.RBRList_s, document.form.wl_wdslist_x_0.value, 12, 0)) return false;
106}
107else if (s == 'MFList')
108{if (document.form.macfilter_num_x_0.value >= c) cFlag=1;
109else if (!validate_hwaddr(document.form.macfilter_list_x_0)) return false;
110else if (document.form.macfilter_list_x_0.value=="") bFlag=1;
111else if (!validate_duplicate(document.form.MFList_s, document.form.macfilter_list_x_0.value, 12, 0)) return false;
112}
113else if (s == 'ACLList')
114{if (document.form.wl_macnum_x_0.value >= c) cFlag=1;
115else if (!validate_hwaddr(document.form.wl_maclist_x_0)) return false;
116else if (document.form.wl_maclist_x_0.value=="") bFlag=1;
117else if (!validate_duplicate(document.form.ACLList_s, document.form.wl_maclist_x_0.value, 12, 0)) return false;
118}
119else if (s=='ManualDHCPList')
120{if (!validate_ipaddr_final(document.form.dhcp_start, 'dhcp_start') ||
121!validate_ipaddr_final(document.form.dhcp_end, 'dhcp_end') ||
122!validate_ipaddr_final(document.form.dhcp_gateway_x, 'dhcp_gateway_x') ||
123!validate_ipaddr_final(document.form.dhcp_dns1_x, 'dhcp_dns1_x') ||
124!validate_ipaddr_final(document.form.dhcp_wins_x, 'dhcp_wins_x') ) return false;
125if (intoa(document.form.dhcp_start.value)>intoa(document.form.dhcp_end.value))
126{tmp = document.form.dhcp_start.value;
127document.form.dhcp_start.value = document.form.dhcp_end.value;
128document.form.dhcp_end.value = tmp;
129}
130if (document.form.dhcp_staticnum_x_0.value >= c) cFlag=1;
131else if (!validate_hwaddr(document.form.dhcp_staticmac_x_0) ||
132!validate_ipaddr_final(document.form.dhcp_staticip_x_0, "staticip")) return false;
133else if (document.form.dhcp_staticmac_x_0.value=="" ||
134document.form.dhcp_staticip_x_0.value=="") bFlag=1;
135else if (!validate_duplicate(document.form.ManualDHCPList_s, document.form.dhcp_staticmac_x_0.value, 12, 0)) return false;
136else if (!validate_duplicate(document.form.ManualDHCPList_s, document.form.dhcp_staticip_x_0.value, 15, 14)) return false;
137}
138else if (s=='PPPoERouteList')
139{if (document.form.PPPConnection_PPPoERouteCount_0.value > c) cFlag=1;
140else if (!validate_ipaddr(document.form.PPPConnection_x_PPPoEIP_0, "") ||
141!validate_range(document.form.PPPConnection_x_PPPoEMask_0, 0, 32)) return false;
142else if (document.form.PPPConnection_x_PPPoEIP_0.value=="" ||
143document.form.PPPConnection_x_PPPoEMask_0.value=="") bFlag=1;
144}
145else if (s=='GWStatic')
146{if (document.form.sr_num_x_0.value > c) cFlag=1;
147else if (!validate_ipaddr(document.form.sr_ipaddr_x_0, "") ||
148!validate_ipaddr(document.form.sr_netmask_x_0, "") ||
149!validate_ipaddr(document.form.sr_gateway_x_0, "")) return false;
150else if (document.form.sr_ipaddr_x_0.value=="" ||
151document.form.sr_netmask_x_0.value=="" ||
152document.form.sr_gateway_x_0.value=="") bFlag=1;
153else if (!validate_duplicate_noalert(document.form.GWStatic_s, document.form.sr_ipaddr_x_0.value, 16, 0) &&
154!validate_duplicate_noalert(document.form.GWStatic_s, document.form.sr_netmask_x_0.value, 16, 17) &&
155!validate_duplicate_noalert(document.form.GWStatic_s, document.form.sr_gateway_x_0.value, 16, 34) &&
156!validate_duplicate(document.form.GWStatic_s, document.form.sr_if_x_0.value, 2, 56)
157) return false;
158}
159else if (s=='VSList')
160{if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
161{if (document.form.vts_num_x_0.value >= c) cFlag=1;
162else if (document.form.vts_ipaddr_x_0.value=="") bFlag=1;
163else if (document.form.vts_proto_x_0.value == "OTHER")
164{if (!validate_ipaddr(document.form.vts_ipaddr_x_0, "") ||
165!validate_portrange(document.form.vts_port_x_0, "") ||
166!validate_range(document.form.vts_protono_x_0, 0, 255)) return false;
167else if (document.form.vts_protono_x_0.value=="") bFlag=1;
168document.form.vts_port_x_0.value = "";
169}
170else
171{if (!validate_ipaddr(document.form.vts_ipaddr_x_0, "") ||
172!validate_portrange(document.form.vts_port_x_0, "") ||
173!validate_range_sp(document.form.vts_lport_x_0, 1, 65535)) return false;
174else if (document.form.vts_port_x_0.value=="") bFlag=1;
175else
176{for(i=0; i< document.form.VSList_s.options.length; i++)
177{if(entry_cmp(document.form.VSList_s.options[i].text.substring(35).toLowerCase(), document.form.vts_proto_x_0.value.toLowerCase(), 5)==0)
178{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
179portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
180)
181)
182{alert('<#JS_duplicate#>');
183return false;
184}
185if(entry_cmp(document.form.VSList_s.options[i].text.substring(12).toLowerCase(), document.form.vts_ipaddr_x_0.value.toLowerCase(), 15)==0
186)
187{if(document.form.vts_lport_x_0.value.length!=0)
188{if(entry_cmp(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), "", 5)==0)
189{if(!(portrange_min(document.form.vts_lport_x_0.value, 5) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
190portrange_max(document.form.vts_lport_x_0.value, 5) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
191)
192)
193{alert('<#JS_duplicate#>');
194return false;
195}
196}
197else
198{if(portrange_min(document.form.vts_lport_x_0.value,5) == portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5))
199{alert('<#JS_duplicate#>');
200return false;
201}
202}
203}
204else
205{if(entry_cmp(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), "", 5)==0)
206{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
207portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
208)
209)
210{alert('<#JS_duplicate#>');
211return false;
212}
213}
214else
215{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5) ||
216portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5)
217)
218)
219{alert('<#JS_duplicate#>');
220return false;
221}
222}
223}
224}
225}
226}
227}
228document.form.vts_protono_x_0.value = "";
229}
230}
231else
232{if (document.form.vts_num_x_0.value >= c) cFlag=1;
233else if (document.form.vts_ipaddr_x_0.value=="") bFlag=1;
234else
235{if (!validate_ipaddr(document.form.vts_ipaddr_x_0, "") ||
236!validate_portrange(document.form.vts_port_x_0, "")) return false;
237else if (document.form.vts_port_x_0.value=="") bFlag=1;
238else
239{for(i=0; i< document.form.VSList_s.options.length; i++)
240{if(entry_cmp(document.form.VSList_s.options[i].text.substring(35).toLowerCase(), document.form.vts_proto_x_0.value.toLowerCase(), 5)==0)
241{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
242portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
243)
244)
245{alert('<#JS_duplicate#>');
246return false;
247}
248if(entry_cmp(document.form.VSList_s.options[i].text.substring(12).toLowerCase(), document.form.vts_ipaddr_x_0.value.toLowerCase(), 15)==0
249)
250{if(document.form.vts_lport_x_0.value.length!=0)
251{if(entry_cmp(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), "", 5)==0)
252{if(!(portrange_min(document.form.vts_lport_x_0.value, 5) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
253portrange_max(document.form.vts_lport_x_0.value, 5) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
254)
255)
256{alert('<#JS_duplicate#>');
257return false;
258}
259}
260else
261{if(portrange_min(document.form.vts_lport_x_0.value,5) == portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5))
262{alert('<#JS_duplicate#>');
263return false;
264}
265}
266}
267else
268{if(entry_cmp(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), "", 5)==0)
269{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_max(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11) ||
270portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(0).toLowerCase(), 11)
271)
272)
273{alert('<#JS_duplicate#>');
274return false;
275}
276}
277else
278{if(!(portrange_min(document.form.vts_port_x_0.value, 11) > portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5) ||
279portrange_max(document.form.vts_port_x_0.value, 11) < portrange_min(document.form.VSList_s.options[i].text.substring(28).toLowerCase(), 5)
280)
281)
282{alert('<#JS_duplicate#>');
283return false;
284}
285}
286}
287}
288}
289}
290}
291}
292}
293}
294else if (s=='TriggerList')
295{if (document.form.autofw_num_x_0.value >= c) cFlag=1;
296else if (!validate_portrange(document.form.autofw_inport_x_0, "") ||
297!validate_portrange(document.form.autofw_outport_x_0, "")) return false;
298else if (document.form.autofw_inport_x_0.value=="" ||
299document.form.autofw_outport_x_0.value=="") bFlag=1;
300else if (!validate_duplicate_noalert(document.form.TriggerList_s, document.form.autofw_outport_x_0.value, 5, 0)&&
301!validate_duplicate(document.form.TriggerList_s, document.form.autofw_outproto_x_0.value, 3, 12)
302) return false;
303}
304else if (s=='WLFilterList')
305{if (document.form.filter_wl_num_x_0.value >= c) cFlag=1;
306else if (!validate_iprange(document.form.filter_wl_srcip_x_0, "") ||
307!validate_portrange(document.form.filter_wl_srcport_x_0, "") ||
308!validate_iprange(document.form.filter_wl_dstip_x_0, "") ||
309!validate_portrange(document.form.filter_wl_dstport_x_0, "")) return false;
310else if (document.form.filter_wl_srcip_x_0.value=="" &&
311document.form.filter_wl_srcport_x_0.value=="" &&
312document.form.filter_wl_dstip_x_0.value=="" &&
313document.form.filter_wl_dstport_x_0.value=="") bFlag=1;
314}
315else if (s=='LWFilterList')
316{if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
317{if (document.form.filter_lw_num_x_0.value >= c) cFlag=1;
318else if (!validate_iprange(document.form.filter_lw_srcip_x_0, "") ||
319!validate_portrange(document.form.filter_lw_srcport_x_0, "") ||
320!validate_iprange(document.form.filter_lw_dstip_x_0, "") ||
321!validate_portrange(document.form.filter_lw_dstport_x_0, "")) return false;
322else if (document.form.filter_lw_srcip_x_0.value=="" &&
323document.form.filter_lw_srcport_x_0.value=="" &&
324document.form.filter_lw_dstip_x_0.value=="" &&
325document.form.filter_lw_dstport_x_0.value=="") bFlag=1;
326}
327else
328{if (document.form.filter_lw_num_x_0.value >= c) cFlag=1;
329else if (!validate_iprange(document.form.filter_lw_srcip_x_0, "") ||
330!validate_portrange(document.form.filter_lw_dstport_x_0, "")) return false;
331else if (document.form.filter_lw_srcip_x_0.value=="" &&
332document.form.filter_lw_dstport_x_0.value=="") bFlag=1;
333}
334}
335else if (s=='UrlList')
336{if (document.form.url_num_x_0.value >= c) cFlag=1;
337else if (document.form.url_keyword_x_0.value=="") bFlag=1;
338else if (!validate_duplicate(document.form.UrlList_s, document.form.url_keyword_x_0.value, 32, 0)) return false;
339}
340else if (s=='x_FUserList')
341{if (document.form.usb_ftpnum_x_0.value >= c) cFlag=1;
342else if (!validate_string(document.form.usb_ftpusername_x_0) ||
343!validate_string(document.form.usb_ftppasswd_x_0) ||
344!validate_range(document.form.usb_ftpmaxuser_x_0, 1, 12)) return false;
345else if (document.form.usb_ftpusername_x_0.value=="" ||
346document.form.usb_ftppasswd_x_0.value=="" ||
347document.form.usb_ftpmaxuser_x_0.value=="") bFlag=1;
348else if (!validate_duplicate(document.form.x_FUserList_s, document.form.usb_ftpusername_x_0.value, 16, 0)) return false;
349}
350else if (s=='x_FBanIPList')
351{if (document.form.usb_bannum_x_0.value >= c) cFlag=1;
352else if (!validate_iprange(document.form.usb_ftpbanip_x_0, "")) return false;
353else if (document.form.usb_ftpbanip_x_0.value=="") bFlag=1;
354else if (!validate_duplicate(document.form.x_FBanIPList_s, document.form.usb_ftpbanip_x_0.value, 15, 0)) return false;
355}
356else if (s=='x_QRuleList')
357{if (document.form.qos_rulenum_x_0.value >= c) cFlag=1;
358else if (!validate_iprange(document.form.qos_ipaddr_x_0) ||
359!validate_range_sp(document.form.qos_port_x_0, 1, 65535) ||
360!validate_range_sp(document.form.qos_maxbw_x_0, 0, 1000000) ||
361!validate_range_sp(document.form.qos_minbw_x_0, 0, 1000000)) return false;
362else if (document.form.qos_maxbw_x_0.value=="" &&
363document.form.qos_minbw_x_0.value=="") bFlag=1;
364else if (document.form.qos_maxbw_x_0.value!="" &&
365document.form.qos_minbw_x_0.value!="" &&
366eval(document.form.qos_minbw_x_0.value) > eval(document.form.qos_maxbw_x_0.value))
367{alert('<#JS_validrange#> 0 to ' + document.form.qos_maxbw_x_0.value + '.');
368document.form.qos_minbw_x_0.focus();
369return false;
370}
371}
372else if (s=='x_UQRuleList')
373{if (document.form.qos_urulenum_x_0.value >= c) cFlag=1;
374else if (!validate_range_sp(document.form.qos_uport_x_0, 1, 65535) ||
375!validate_range_sp(document.form.qos_umaxbw_x_0, 0, 1000000) ||
376!validate_range_sp(document.form.qos_uminbw_x_0, 0, 1000000)) return false;
377else if (document.form.qos_umaxbw_x_0.value=="" &&
378document.form.qos_uminbw_x_0.value=="") bFlag=1;
379else if (document.form.qos_umaxbw_x_0.value!="" &&
380document.form.qos_uminbw_x_0.value!="" &&
381eval(document.form.qos_uminbw_x_0.value) > eval(document.form.qos_umaxbw_x_0.value))
382{alert('<#JS_validrange#> 0 to ' + document.form.qos_umaxbw_x_0.value + '.');
383document.form.qos_uminbw_x_0.focus();
384return false;
385}
386}
387else if (s=='x_USRRuleList')
388{if (document.form.qos_rulenum_x_0.value >= c) cFlag=1;
389else if ( !validate_string(document.form.qos_service_name_x_0) ||
390!validate_iprange(document.form.qos_ip_x_0) ||
391!validate_portrange(document.form.qos_port_x_0, "")) return false;
392else if (document.form.qos_port_x_0.value=="" ||
393document.form.qos_service_name_x_0.value=="" ||
394document.form.qos_ip_x_0.value=="") bFlag=1;
395else if ( !validate_duplicate(document.form.x_USRRuleList_s, document.form.qos_prio_x_0.value, 1, 44) ||
396!validate_duplicate(document.form.x_USRRuleList_s, document.form.qos_service_name_x_0.value, 16, 0) )  return false;
397}
398else if (s=='Storage_SharedList')
399{if (document.form.sh_num_0.value >= c) cFlag=1;
400/* 2005.12.16 Jiahao
401else if (!validate_path(document.form.sh_path_0)) return false;
402*/
403else if (document.form.sh_path_0.value=="") bFlag=1;
404else if (document.form.sh_name_0.value=="") bFlag=1;
405else if (!validate_duplicate(document.form.Storage_SharedList_s, document.form.sh_path_0.value, 32, 0))  return false;
406else if (!validate_duplicate(document.form.Storage_SharedList_s, document.form.sh_name_0.value, 16, 34)) return false;
407top.Edit_Flag = "on";
408}
409else if (s=='Storage_UserList')
410{if (document.form.acc_num_0.value >= c) cFlag=1;
411else if (!validate_string(document.form.acc_username_0)) return false;
412else if (!validate_string(document.form.acc_password_0)) return false;
413else if (document.form.acc_username_0.value=="") bFlag=1;
414else if (document.form.acc_username_0.value.toLowerCase()=="guest")
415{alert("<#JS_validusername#>");
416return false;
417}
418else if (document.form.acc_username_0.value.toLowerCase()=="anonymous")
419{alert("<#JS_validusernamea#>");
420return false;
421}
422else if (document.form.acc_username_0.value.toLowerCase()=="ftp")
423{alert("<#JS_validusernameb#>");
424return false;
425}
426else if (document.form.acc_password_0.value=="") bFlag=1;
427else if (!validate_duplicate(document.form.Storage_UserList_s, document.form.acc_username_0.value, 28, 0)) return false;
428else if (!validate_duplicate(document.form.Storage_UserList_s, document.form.acc_password_0.value, 24, 29)) return false;
429}
430else if (s=='Storage_UserRight_List')
431{if (document.form.sh_acc_onlist_num_x_0.value >= c) cFlag = 1;
432else if (!validate_string(document.form.sh_acc_user_0.value)) return false;
433else if (document.form.sh_acc_user_0.value == "") bFlag = 1;
434}
435}
436if (bFlag==1)
437alert("<#JS_fieldblank#>");
438else if(cFlag==1)
439alert("<#JS_itemlimit1#> " + c + " <#JS_itemlimit2#>");
440else
441{if (s=='WLFilterList')
442{updateDateTime("Advanced_Firewall_Content.asp");
443}
444else if (s=='LWFilterList')
445{updateDateTime("Advanced_Firewall_Content.asp");
446}
447else if (s=='UrlList')
448{updateDateTime("Advanced_URLFilter_Content.asp");
449}
450else if (s=='LocalCertDB')
451{}
452window.top.pageChanged = 0;
453window.top.pageChangedCount = 0;
454o.value = b;
455document.form.action_mode.value = b;
456return true;
457}
458return false;
459}
460function portrange_min(o, v)
461{var num = 0;
462var common_index = o.substring(0, v).indexOf(':');
463if(common_index == -1)
464num = parseInt(o.substring(0, v));
465else
466num = parseInt(o.substring(0, common_index));
467return num;
468}
469function portrange_max(o, v)
470{var num = 0;
471var common_index = o.substring(0, v).indexOf(':');
472if(common_index == -1)
473num = parseInt(o.substring(0, v));
474else
475num = parseInt(o.substring(common_index+1, v+1));
476return num;
477}
478function isBlank(s) {
479for(i=0; i<s.length; i++) {
480c=s.charAt(i);
481if((c!=' ')&&(c!='\n')&&(c!='\t'))return false;}
482return true;
483}
484function numbersonly()
485{if (keyPressed>47 && keyPressed<58)
486return true;
487else
488return false;
489}
490function check_ptl()
491{if(keyPressed==38)
492return false;
493else
494return true;
495}
496function linkOver(o)
497{o.style.cursor="hand";
498}
499function linkOut(o) {
500}
501function linkTo(s)
502{window.top.location=s;
503}
504function refreshList()
505{parent.location.href = 'index.asp';
506}
507function onApply(o)
508{parent.upperframe.location.href="Restarting.html";
509parent.upperframe.location.href="Restarting.html";
510}
511function entry_cmp(entry, match, len)
512{var j;
513if(entry.length<match.length) return (1);
514for(j=0; j<entry.length && j<len; j++)
515{c1 = entry.charCodeAt(j);
516if (j>=match.length) c2=160;
517else c2 = match.charCodeAt(j);
518if (c1==160) c1 = 32;
519if (c2==160) c2 = 32;
520if (c1>c2) return (1);
521else if (c1<c2) return(-1);
522}
523return 0;
524}
525function validate_duplicate_noalert(o, v, l, off)
526{var i;
527for (i=0; i<o.options.length; i++)
528{if (entry_cmp(o.options[i].text.substring(off).toLowerCase(), v.toLowerCase(), l)==0)
529{return false;
530}
531}
532return true;
533}
534function validate_duplicate(o, v, l, off)
535{var i;
536for (i=0; i<o.options.length; i++)
537{if (entry_cmp(o.options[i].text.substring(off).toLowerCase(), v.toLowerCase(), l)==0)
538{alert('<#JS_duplicate#>');
539return false;
540}
541}
542return true;
543}
544function validate_duplicate2(o, v, l, off)
545{var i;
546for (i=0; i<o.options.length; i++)
547{if (entry_cmp(o.options[i].text.substring(off).toLowerCase(), v.toLowerCase(), l)==0)
548{return false;
549}
550}
551return true;
552}
553function is_hwaddr()
554{if (!nav) keyPressed = IEKey();
555else keyPressed=NSKey();
556if ((keyPressed>47 && keyPressed<58)||(keyPressed>64 && keyPressed<71)||(keyPressed>96 && keyPressed<103))
557return true;
558else if (keyPressed==0)
559return true;
560else
561return false;
562}
563function validate_hwaddr(o)
564{if (o.value.length == 0) return true;
565if(o.value != "")
566{if(o.value.length == 12)
567{for(i=0; i<o.value.length; i++)
568{c=o.value.charAt(i);
569if (!(c>='0'&&c<='9') && !(c>='a'&&c<='f') && !(c>='A'&&c<='F'))
570{alert('<#JS_validmac#>');
571o.value = "";
572o.focus();
573return false;
574}
575}
576return true;
577}
578}
579alert('<#JS_validmac#>');
580o.value = "";
581o.focus();
582return false;
583}
584function is_string(o) {
585if (!nav)
586keyPressed = IEKey();
587else
588keyPressed = NSKey();
589if (keyPressed==0)
590return true;
591else if (keyPressed>=0&&keyPressed<=126)
592return true;
593alert('<#JS_validchar#>');
594return false;
595}
596function is_string2(o) {
597if (!nav)
598keyPressed = IEKey();
599else
600keyPressed = NSKey();
601if (keyPressed==0)
602return true;
603else if ((keyPressed>=48&&keyPressed<=57) ||
604(keyPressed>=97&&keyPressed<=122) ||
605(keyPressed>=65&&keyPressed<=90) ||
606(keyPressed==45)
607)
608return true;
609alert('<#JS_validchar#>');
610return false;
611}
612function validate_string(o) {
613if (o.value.charAt(0)=='"') {
614alert("<#JS_validstr1#> '\"'");
615o.value="";
616o.focus();
617return false;
618}
619else {
620inv="";
621for(i=0; i<o.value.length; i++) {
622if (o.value.charAt(i)<' '||o.value.charAt(i)>'~' || o.value.charAt(i)=='"') {
623inv = inv + o.value.charAt(i);
624}
625}
626if (inv!="") {
627alert("<#JS_validstr2#> " + inv +"!");
628o.value="";
629o.focus();
630return false;
631}
632}
633return true;
634}
635function validate_string_ssid(o) {
636for(i=0;i<o.value.length;i++)
637{c = o.value.charCodeAt(i);
638if (!validate_ssidchar(c))
639{alert("<#JS_validstr2#> " + o.value.charAt(i) +"!");
640o.value="";
641o.focus();
642return false;
643}
644}
645if (document.form.current_page.value == "Advanced_Wireless_Content.asp" && document.form.wl_ssid.value == "") {
646o.value = "default";
647}
648else if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp" && document.form.wl_guest_ssid_1.value == "") {
649o.value = "guest";
650}
651else if (document.form.current_page.value == "Basic_GOperation_Content.asp" && document.form.wl_ssid.value == "") {
652o.value = "default";
653}
654else if (document.form.current_page.value == "Basic_AOperation_Content.asp" && document.form.wl_ssid.value == "") {
655o.value = "default";
656}
657return true;
658}
659function validate_share(o)
660{s=o.value;
661if (!validate_string(o))
662{return false;
663}
664for(i=0;i<s.length;i++)
665{c = s.charCodeAt(i);
666if (!validate_sharechar(c))
667{alert("Share name can not contain '" + s.charAt(i) +"' !");
668return(false);
669}
670}
671return(true);
672}
673function validate_sharechar(ch)
674{if (ch>=48&&ch<=57) return true;
675if (ch>=97&&ch<=122) return true;
676if (ch>=65&&ch<=90) return true;
677if (ch==45) return true;
678if (ch==95) return true;
679if (ch==32) return true;
680return false;
681}
682function validate_ssidchar(ch)
683{if (ch>=32&&ch<=126) return true;
684return false;
685}
686function is_number(o)
687{if (!nav) keyPressed = IEKey();
688else keyPressed = NSKey();
689if (keyPressed==0) return true;
690if (keyPressed>47 && keyPressed<58)
691{if (keyPressed==48 && o.length == 0) return false;
692return true;
693}
694else
695{return false;
696}
697}
698function validate_range(o, min, max) {
699for(i=0; i<o.value.length; i++)
700{if (o.value.charAt(i)<'0' || o.value.charAt(i)>'9')
701{alert('<#JS_validrange#> ' + min + ' to ' + max + '.');
702o.value = min;
703o.focus();
704return false;
705}
706}
707if(o.value<min || o.value>max) {
708alert('<#JS_validrange#> ' + min + ' to ' + max + '.');
709o.value = min;
710o.focus();
711return false;
712}
713else {
714o.value = str2val(o.value);
715if(o.value=="")
716o.value="0";
717return true;
718}
719}
720function validate_range_sp(o, min, max) {
721if (o.value.length==0) return true;
722if(o.value<min || o.value>max) {
723alert('<#JS_validrange#> ' + min + ' to ' + max + '.');
724o.value = min;
725o.focus();
726return false;
727}
728else {
729o.value = str2val(o.value);
730if(o.value=="") o.value="0"
731return true;
732}
733}
734function change_ipaddr(o)
735{}
736function is_ipaddr(o)
737{if (!nav) keyPressed = IEKey();
738else keyPressed=NSKey();
739if (keyPressed==0)
740{return true;
741}
742if (o.value.length>=16) return false;
743if ((keyPressed>47 && keyPressed<58))
744{j = 0;
745for(i=0; i<o.value.length; i++)
746{if (o.value.charAt(i)=='.')
747{j++;
748}
749}
750if (j<3 && i>=3)
751{if (o.value.charAt(i-3)!='.' && o.value.charAt(i-2)!='.' && o.value.charAt(i-1)!='.')
752{o.value = o.value + '.';
753}
754}
755return true;
756}
757else if (keyPressed == 46)
758{j = 0;
759for(i=0; i<o.value.length; i++)
760{if (o.value.charAt(i)=='.')
761{j++;
762}
763}
764if (o.value.charAt(i-1)=='.' || j==3)
765{return false;
766}
767return true;
768}
769else
770{return false;
771}
772return false;
773}
774function intoa(ip)
775{n=0;
776vip=0;
777for(i=0;i<ip.length;i++)
778{c = ip.charAt(i);
779if (c == '.')
780{vip = vip * 256 + n;
781n = 0;
782}
783else if(c>='0' && c<='9')
784{n = n*10 + (c-'0');
785}
786}
787vip = vip*256 + n;
788return(vip);
789}
790function requireWANIP(v)
791{if (v=='wan_ipaddr' || v=='wan_netmask' || v=='lan_ipaddr' ||
792v=='lan_netmask' || v=='lan1_ipaddr' || v=='lan1_netmask')
793{if(document.form.wan_proto.value=="static" || document.form.wan_proto.value=="pptp") return 1;
794else return 0;
795}
796else return 0;
797}
798function matchSubnet2(ip1, sb1, ip2, sb2)
799{nsb1 = intoa(sb1.value);
800nsb2 = intoa(sb2.value);
801if(nsb1<nsb2) nsb=nsb1;
802else nsb=nsb2;
803if ((intoa(ip1)&nsb)==(intoa(ip2)&nsb)) return 1;
804else return 0;
805}
806function validate_ipaddr(o, v)
807{if(final_flag) return true;
808num = -1;
809pos = 0;
810if (o.value.length==0)
811{if (v=='dhcp_start' || v=='dhcp_end' || v=='wan_ipaddr' || v=='dhcp1_start' || v=='dhcp1_end' ||
812v=='lan_ipaddr' || v=='lan_netmask' || v=='lan1_ipaddr' || v=='lan1_netmask')
813{alert("<#JS_fieldblank#>");
814if (v=='wan_ipaddr')
815{document.form.wan_ipaddr.value = "10.1.1.1";
816document.form.wan_netmask.value = "255.0.0.0";
817}
818else if (v=='lan_ipaddr')
819{document.form.lan_ipaddr.value = "192.168.1.1";
820document.form.lan_netmask.value = "255.255.255.0";
821}
822else if (v=='lan1_ipaddr')
823{document.form.lan1_ipaddr.value = "192.168.2.1";
824document.form.lan1_netmask.value = "255.255.255.0";
825}
826else if (v=='lan_netmask') document.form.lan_netmask.value = "255.255.255.0";
827else if (v=='lan1_netmask') document.form.lan1_netmask.value = "255.255.255.0";
828else if (v=='dhcp_start') document.form.dhcp_start.value = document.form.dhcp_end.value;
829else if (v=='dhcp_end') document.form.dhcp_end.value = document.form.dhcp_start.value;
830else if (v=='dhcp1_start') document.form.dhcp1_start.value = document.form.dhcp1_end.value;
831else if (v=='dhcp1_end') document.form.dhcp1_end.value = document.form.dhcp1_start.value;
832o.focus();
833return false;
834}
835else return true;
836}
837if(v=='wan_ipaddr' && document.form.wan_netmask.value=="")
838document.form.wan_netmask.value="255.255.255.0";
839for(i=0; i<o.value.length; i++) {
840c=o.value.charAt(i);
841if(c>='0' && c<='9')
842{if ( num==-1 )
843{num = (c-'0');
844}
845else
846{num = num*10 + (c-'0');
847}
848}
849else
850{if ( num<0 || num>255 || c!='.')
851{alert(o.value + ' <#JS_validip#>');
852o.value = "";
853o.focus();
854return false;
855}
856if (pos==0) v1=num;
857else if (pos==1) v2=num;
858else if (pos==2) v3=num;
859num = -1;
860pos++;
861}
862}
863if (pos!=3 || num<0 || num>255)
864{alert(o.value + ' <#JS_validip#>');
865o.value = "";
866o.focus();
867return false;
868}
869else v4=num;
870if (v=='dhcp_start' || v=='dhcp_end' || v=='wan_ipaddr' || v=='dhcp1_start' || v=='dhcp1_end' || v=='lan_ipaddr' || v=='lan1_ipaddr' || v=='staticip')
871{if(v1==255||v2==255||v3==255||v4==255||v1==0||v4==0||v1==127||v1==224)
872{alert(o.value + ' <#JS_validip#>');
873o.value = "";
874o.focus();
875return false;
876}
877if (requireWANIP(v) && (
878(v=='wan_ipaddr' &&  matchSubnet2(o.value, document.form.wan_netmask, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
879(v=='lan_ipaddr' &&  matchSubnet2(o.value, document.form.lan_netmask, document.form.wan_ipaddr.value, document.form.wan_netmask)) ||
880(window.top.isModel3() == 'WL550gE' && v=='wan_ipaddr' && matchSubnet2(o.value, document.form.wan_netmask, document.form.lan1_ipaddr.value, document.form.lan1_netmask)) ||
881(window.top.isModel3() == 'WL550gE' && v=='lan1_ipaddr' && matchSubnet2(o.value, document.form.lan1_netmask, document.form.wan_ipaddr.value, document.form.wan_netmask))
882))
883{alert(o.value + ' <#JS_validip#>');
884if (v=='wan_ipaddr')
885{document.form.wan_ipaddr.value = "10.1.1.1";
886document.form.wan_netmask.value = "255.0.0.0";
887}
888else if(v=='lan_ipaddr')
889{document.form.lan_ipaddr.value = "192.168.1.1";
890document.form.lan_netmask.value = "255.255.255.0";
891}
892else if(v=='lan1_ipaddr')
893{document.form.lan1_ipaddr.value = "192.168.2.1";
894document.form.lan1_netmask.value = "255.255.255.0";
895}
896o.focus();
897return false;
898}
899}
900else if(v=='lan_netmask' || v=='lan1_netmask')
901{if(v1==255&&v2==255&&v3==255&&v4==255)
902{alert(o.value + ' <#JS_validip#>');
903o.value = "";
904o.focus();
905return false;
906}
907}
908if (requireWANIP(v) && (
909(v=='wan_netmask' &&  matchSubnet2(document.form.wan_ipaddr.value, o, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
910(v=='lan_netmask' &&  matchSubnet2(document.form.lan_ipaddr.value, o, document.form.wan_ipaddr.value, document.form.wan_netmask)) ||
911(window.top.isModel3() == 'WL550gE' && v=='wan_netmask' &&  matchSubnet2(document.form.wan_ipaddr.value, o, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
912(window.top.isModel3() == 'WL550gE' && v=='lan1_netmask' &&  matchSubnet2(document.form.lan1_ipaddr.value, o, document.form.wan_ipaddr.value, document.form.wan_netmask))
913))
914{alert(o.value + ' <#JS_validip#>');
915if (v=='wan_netmask')
916{document.form.wan_ipaddr.value = "10.1.1.1";
917document.form.wan_netmask.value = "255.0.0.0";
918}
919else if(v=='lan_netmask')
920{document.form.lan_ipaddr.value = "192.168.1.1";
921document.form.lan_netmask.value = "255.255.255.0";
922}
923else if(v=='lan1_netmask')
924{document.form.lan1_ipaddr.value = "192.168.2.1";
925document.form.lan1_netmask.value = "255.255.255.0";
926}
927o.focus();
928return false;
929}
930if(v=='lan1_ipaddr')
931{if(window.top.isModel3() == 'WL550gE' && matchSubnet(document.form.lan_ipaddr.value, document.form.lan1_ipaddr.value, 3))
932{alert(o.value + ' <#JS_validip#>');
933o.value = "";
934o.focus();
935return false;
936}
937}
938else if(v=='lan_ipaddr' && window.top.isBand() != 'b')
939{if(window.top.isModel3() == 'WL550gE' && matchSubnet(document.form.lan_ipaddr.value, document.form.lan1_ipaddr.value, 3))
940{alert(o.value + ' <#JS_validip#>');
941o.value = "";
942o.focus();
943return false;
944}
945}
946o.value = v1 + "." + v2 + "." + v3 + "." + v4;
947if ((v1 > 0) && (v1 < 127)) mask = "255.0.0.0";
948else if ((v1 > 127) && (v1 < 192)) mask = "255.255.0.0";
949else if ((v1 > 191) && (v1 < 224)) mask = "255.255.255.0";
950else mask = "0.0.0.0";
951if (v=='wan_ipaddr' && document.form.wan_netmask.value=="")
952{document.form.wan_netmask.value = mask;
953}
954else if (v=='lan_ipaddr' && document.form.lan_netmask.value=="" )
955{document.form.lan_netmask.value = mask;
956}
957else if (v=='dhcp_start')
958{if (!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_start.value, 3))
959{alert(o.value + ' <#JS_validip#>');
960o.focus();
961return false;
962}
963if (intoa(o.value)>intoa(document.form.dhcp_end.value))
964{tmp = document.form.dhcp_start.value;
965document.form.dhcp_start.value = document.form.dhcp_end.value;
966document.form.dhcp_end.value = tmp;
967}
968}
969else if (v=='dhcp_end')
970{if (!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_end.value, 3))
971{alert(o.value + ' <#JS_validip#>');
972o.focus();
973return false;
974}
975if (intoa(document.form.dhcp_start.value)>intoa(o.value))
976{tmp = document.form.dhcp_start.value;
977document.form.dhcp_start.value = document.form.dhcp_end.value;
978document.form.dhcp_end.value = tmp;
979}
980}
981else if (v=='lan1_ipaddr')
982{if(document.form.lan1_netmask.value=="" )
983document.form.lan1_netmask.value = mask;
984}
985else if (v=='dhcp1_start')
986{if (!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_start.value, 3))
987{alert(o.value + ' <#JS_validip#>');
988o.focus();
989return false;
990}
991if (intoa(o.value)>intoa(document.form.dhcp1_end.value))
992{tmp = document.form.dhcp1_start.value;
993document.form.dhcp1_start.value = document.form.dhcp1_end.value;
994document.form.dhcp1_end.value = tmp;
995}
996}
997else if (v=='dhcp1_end')
998{if (!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_end.value, 3))
999{alert(o.value + ' <#JS_validip#>');
1000o.focus();
1001return false;
1002}
1003if (intoa(document.form.dhcp1_start.value)>intoa(o.value))
1004{tmp = document.form.dhcp1_start.value;
1005document.form.dhcp1_start.value = document.form.dhcp1_end.value;
1006document.form.dhcp1_end.value = tmp;
1007}
1008}
1009return true;
1010}
1011function validate_ipaddr_final(o, v)
1012{num = -1;
1013pos = 0;
1014if (o.value.length==0)
1015{if (v=='dhcp_start' || v=='dhcp_end' || v=='wan_ipaddr' || v=='dhcp1_start' || v=='dhcp1_end' ||
1016v=='lan_ipaddr' || v=='lan_netmask' || v=='lan1_ipaddr' || v=='lan1_netmask' || v=='wl_radius_ipaddr')
1017{alert("<#JS_fieldblank#>");
1018if (v=='wan_ipaddr')
1019{document.form.wan_ipaddr.value = "10.1.1.1";
1020document.form.wan_netmask.value = "255.0.0.0";
1021}
1022else if (v=='lan_ipaddr')
1023{document.form.lan_ipaddr.value = "192.168.1.1";
1024document.form.lan_netmask.value = "255.255.255.0";
1025}
1026else if (v=='lan1_ipaddr')
1027{document.form.lan1_ipaddr.value = "192.168.2.1";
1028document.form.lan1_netmask.value = "255.255.255.0";
1029}
1030else if (v=='lan_netmask') document.form.lan_netmask.value = "255.255.255.0";
1031else if (v=='lan1_netmask') document.form.lan1_netmask.value = "255.255.255.0";
1032o.focus();
1033return false;
1034}
1035else return true;
1036}
1037if(v=='wan_ipaddr' && document.form.wan_netmask.value=="")
1038document.form.wan_netmask.value="255.255.255.0";
1039for(i=0; i<o.value.length; i++) {
1040c=o.value.charAt(i);
1041if(c>='0' && c<='9')
1042{if ( num==-1 )
1043{num = (c-'0');
1044}
1045else
1046{num = num*10 + (c-'0');
1047}
1048}
1049else
1050{if ( num<0 || num>255 || c!='.')
1051{alert(o.value + ' <#JS_validip#>');
1052o.value = "";
1053o.focus();
1054return false;
1055}
1056if (pos==0) v1=num;
1057else if (pos==1) v2=num;
1058else if (pos==2) v3=num;
1059num = -1;
1060pos++;
1061}
1062}
1063if (pos!=3 || num<0 || num>255)
1064{alert(o.value + ' <#JS_validip#>');
1065o.value = "";
1066o.focus();
1067return false;
1068}
1069else v4=num;
1070if (v=='dhcp_start' || v=='dhcp_end' || v=='wan_ipaddr' || v=='dhcp1_start' || v=='dhcp1_end' || v=='lan_ipaddr' || v=='lan1_ipaddr' || v=='staticip' || v=='wl_radius_ipaddr' || v=='dhcp_dns1_x' || v=='dhcp_gateway_x' || v=='dhcp_wins_x')
1071{if((v!='wan_ipaddr')&& (v1==255||v2==255||v3==255||v4==255||v1==0||v4==0||v1==127||v1==224))
1072{alert(o.value + ' <#JS_validip#>');
1073o.value = "";
1074o.focus();
1075return false;
1076}
1077if (requireWANIP(v) && (
1078(v=='wan_ipaddr' &&  matchSubnet2(o.value, document.form.wan_netmask, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
1079(v=='lan_ipaddr' &&  matchSubnet2(o.value, document.form.lan_netmask, document.form.wan_ipaddr.value, document.form.wan_netmask)) ||
1080(window.top.isModel3() == 'WL550gE' && v=='wan_ipaddr' && matchSubnet2(o.value, document.form.wan_netmask, document.form.lan1_ipaddr.value, document.form.lan1_netmask)) ||
1081(window.top.isModel3() == 'WL550gE' && v=='lan1_ipaddr' && matchSubnet2(o.value, document.form.lan1_netmask, document.form.wan_ipaddr.value, document.form.wan_netmask))
1082))
1083{alert(o.value + ' <#JS_validip#>');
1084if (v=='wan_ipaddr')
1085{document.form.wan_ipaddr.value = "10.1.1.1";
1086document.form.wan_netmask.value = "255.0.0.0";
1087}
1088else if(v=='lan_ipaddr')
1089{document.form.lan_ipaddr.value = "192.168.1.1";
1090document.form.lan_netmask.value = "255.255.255.0";
1091}
1092else if(v=='lan1_ipaddr')
1093{document.form.lan1_ipaddr.value = "192.168.2.1";
1094document.form.lan1_netmask.value = "255.255.255.0";
1095}
1096o.focus();
1097return false;
1098}
1099}
1100else if(v=='lan_netmask' || v=='lan1_netmask')
1101{if(v1==255&&v2==255&&v3==255&&v4==255)
1102{alert(o.value + ' <#JS_validip#>');
1103o.value = "";
1104o.focus();
1105return false;
1106}
1107}
1108if (requireWANIP(v) && (
1109(v=='wan_netmask' &&  matchSubnet2(document.form.wan_ipaddr.value, o, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
1110(v=='lan_netmask' &&  matchSubnet2(document.form.lan_ipaddr.value, o, document.form.wan_ipaddr.value, document.form.wan_netmask)) ||
1111(window.top.isModel3() == 'WL550gE' && v=='wan_netmask' &&  matchSubnet2(document.form.wan_ipaddr.value, o, document.form.lan_ipaddr.value, document.form.lan_netmask)) ||
1112(window.top.isModel3() == 'WL550gE' && v=='lan1_netmask' &&  matchSubnet2(document.form.lan1_ipaddr.value, o, document.form.wan_ipaddr.value, document.form.wan_netmask))
1113))
1114{alert(o.value + ' <#JS_validip#>');
1115if (v=='wan_netmask')
1116{document.form.wan_ipaddr.value = "10.1.1.1";
1117document.form.wan_netmask.value = "255.0.0.0";
1118}
1119else if(v=='lan_netmask')
1120{document.form.lan_ipaddr.value = "192.168.1.1";
1121document.form.lan_netmask.value = "255.255.255.0";
1122}
1123else if(v=='lan1_netmask')
1124{document.form.lan1_ipaddr.value = "192.168.2.1";
1125document.form.lan1_netmask.value = "255.255.255.0";
1126}
1127o.focus();
1128return false;
1129}
1130if(v=='lan1_ipaddr')
1131{if(window.top.isModel3() == 'WL550gE' && matchSubnet(document.form.lan_ipaddr.value, document.form.lan1_ipaddr.value, 3))
1132{alert(o.value + ' <#JS_validip#>');
1133o.value = "";
1134o.focus();
1135return false;
1136}
1137}
1138else if(v=='lan_ipaddr' && window.top.isBand() != 'b')
1139{if(window.top.isModel3() == 'WL550gE' && matchSubnet(document.form.lan_ipaddr.value, document.form.lan1_ipaddr.value, 3))
1140{alert(o.value + ' <#JS_validip#>');
1141o.value = "";
1142o.focus();
1143return false;
1144}
1145}
1146o.value = v1 + "." + v2 + "." + v3 + "." + v4;
1147if ((v1 > 0) && (v1 < 127)) mask = "255.0.0.0";
1148else if ((v1 > 127) && (v1 < 192)) mask = "255.255.0.0";
1149else if ((v1 > 191) && (v1 < 224)) mask = "255.255.255.0";
1150else mask = "0.0.0.0";
1151if (v=='wan_ipaddr' && document.form.wan_netmask.value=="")
1152{document.form.wan_netmask.value = mask;
1153}
1154else if (v=='lan_ipaddr' && document.form.lan_netmask.value=="" )
1155{document.form.lan_netmask.value = mask;
1156}
1157else if (v=='dhcp_start')
1158{if (!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_start.value, 3))
1159{alert(o.value + ' <#JS_validip#>');
1160o.focus();
1161return false;
1162}
1163}
1164else if (v=='dhcp_end')
1165{if (!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_end.value, 3))
1166{alert(o.value + ' <#JS_validip#>');
1167o.focus();
1168return false;
1169}
1170}
1171else if (v=='lan1_ipaddr')
1172{if(document.form.lan1_netmask.value=="") document.form.lan1_netmask.value = mask;
1173}
1174else if (v=='dhcp1_start')
1175{if (!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_start.value, 3))
1176{alert(o.value + ' <#JS_validip#>');
1177o.focus();
1178return false;
1179}
1180}
1181else if (v=='dhcp1_end')
1182{if (!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_end.value, 3))
1183{alert(o.value + ' <#JS_validip#>');
1184o.focus();
1185return false;
1186}
1187}
1188return true;
1189}
1190function change_ipaddrport(o)
1191{}
1192function is_ipaddrport(o)
1193{if (!nav) keyPressed = IEKey();
1194else keyPressed=NSKey();
1195if (keyPressed==0)
1196{return true;
1197}
1198if ((keyPressed>47 && keyPressed<58) || keyPressed == 46 || keyPressed == 58)
1199{return true;
1200}
1201return false;
1202}
1203function validate_ipaddrport(o, v)
1204{num = -1;
1205pos = 0;
1206if (o.value.length==0)
1207return true;
1208str = o.value;
1209portidx = str.indexOf(":");
1210if (portidx!=-1)
1211{port = str.substring(portidx+1);
1212len = portidx;
1213if (port>65535)
1214{alert(port + ' <#JS_validport#>');
1215o.value = "";
1216o.focus();
1217return false;
1218}
1219}
1220else
1221{len = o.value.length;
1222}
1223for(i=0; i<len; i++) {
1224c=o.value.charAt(i);
1225if(c>='0' && c<='9')
1226{if ( num==-1 )
1227{num = (c-'0');
1228}
1229else
1230{num = num*10 + (c-'0');
1231}
1232}
1233else
1234{if ( num<0 || num>255 || c!='.')
1235{alert(o.value + ' <#JS_validip#>');
1236o.value = "";
1237o.focus();
1238return false;
1239}
1240num = -1;
1241pos++;
1242}
1243}
1244if (pos!=3 || num<0 || num>255)
1245{alert(o.value + ' <#JS_validip#>');
1246o.value = "";
1247o.focus();
1248return false;
1249}
1250if (v=='ExternalIPAddress' && document.form.wan_netmask.value == '')
1251{document.form.wan_netmask.value = "255.255.255.0";
1252}
1253else if (v=='IPRouters' && document.form.lan_netmask.value == '')
1254{document.form.lan_netmask.value = "255.255.255.0";
1255}
1256return true;
1257}
1258function change_iprange(o)
1259{}
1260function is_iprange(o)
1261{if (!nav) keyPressed = IEKey();
1262else keyPressed=NSKey();
1263if (keyPressed==0)
1264{return true;
1265}
1266if (o.value.length>=15) return false;
1267if ((keyPressed>47 && keyPressed<58))
1268{j = 0;
1269for(i=0; i<o.value.length; i++)
1270{if (o.value.charAt(i)=='.')
1271{j++;
1272}
1273}
1274if (j<3 && i>=3)
1275{if (o.value.charAt(i-3)!='.' && o.value.charAt(i-2)!='.' && o.value.charAt(i-1)!='.')
1276o.value = o.value + '.';
1277}
1278return true;
1279}
1280else if (keyPressed == 46)
1281{j = 0;
1282for(i=0; i<o.value.length; i++)
1283{if (o.value.charAt(i)=='.')
1284{j++;
1285}
1286}
1287if (o.value.charAt(i-1)=='.' || j==3)
1288{return false;
1289}
1290return true;
1291}
1292else if (keyPressed == 42) /* '*' */
1293{return true;
1294}
1295else
1296{return false;
1297}
1298return false;
1299}
1300function validate_iprange(o, v)
1301{num = -1;
1302pos = 0;
1303if (o.value.length==0)
1304return true;
1305for(i=0; i<o.value.length; i++)
1306{c=o.value.charAt(i);
1307if(c>='0'&&c<='9')
1308{if ( num==-1 )
1309{num = (c-'0');
1310}
1311else
1312{num = num*10 + (c-'0');
1313}
1314}
1315else if (c=='*'&&num==-1)
1316{num = 0;
1317}
1318else
1319{if ( num<0 || num>255 || (c!='.'))
1320{alert(o.value + ' <#JS_validip#>');
1321o.value = "";
1322o.focus();
1323return false;
1324}
1325num = -1;
1326pos++;
1327}
1328}
1329if (pos!=3 || num<0 || num>255)
1330{alert(o.value + ' <#JS_validip#>');
1331o.value = "";
1332o.focus();
1333return false;
1334}
1335if (v=='ExternalIPAddress' && document.form.wan_netmask.value == '')
1336{document.form.wan_netmask.value = "255.255.255.0";
1337}
1338else if (v=='IPRouters' && document.form.lan_netmask.value == '')
1339{document.form.lan_netmask.value = "255.255.255.0";
1340}
1341return true;
1342}
1343function is_portrange(o)
1344{if (!nav) keyPressed = IEKey();
1345else keyPressed=NSKey();
1346if (keyPressed==0) return true;
1347if (o.value.length>11) return false;
1348if ((keyPressed>47 && keyPressed<58))
1349{return true;
1350}
1351else if (keyPressed == 58 && o.value.length>0)
1352{for(i=0; i<o.value.length; i++)
1353{c=o.value.charAt(i);
1354if (c==':' || c=='>' || c=='<' || c=='=')
1355return false;
1356}
1357return true;
1358}
1359else if (keyPressed==60 || keyPressed==62)
1360{if (o.value.length==0)
1361{return true;
1362}
1363else
1364return false;
1365}
1366else
1367{return false;
1368}
1369}
1370function validate_portrange(o, v)
1371{if (o.value.length==0)
1372return true;
1373prev = -1;
1374num = -1;
1375for(i=0; i<o.value.length; i++)
1376{c=o.value.charAt(i);
1377if (c>='0'&&c<='9')
1378{if(num==-1) num=0;
1379num = num*10 + (c-'0');
1380}
1381else
1382{if (num>65535 || num==0 || (c!=':' && c!='>' && c!='<'))
1383{alert(num + ' <#JS_validport#>');
1384o.value = "";
1385o.focus();
1386return false;
1387}
1388if (c=='>') prev = -2;
1389else if (c=='<') prev = -3;
1390else
1391{prev = num;
1392num = 0;
1393}
1394}
1395}
1396if ((num>65535 && prev!=-3) || (num<1&&prev!=-2) || (prev>num) || (num>=65535&&prev==-2) || (num<=1&&prev==-3))
1397{if (num>65535)
1398alert(num + ' <#JS_validport#>');
1399else
1400alert(o.value + ' <#JS_validportrange#>');
1401o.value = "";
1402o.focus();
1403return false;
1404}
1405else
1406{if (prev==-2)
1407{if (num==65535) o.value = num;
1408else o.value = (num+1) + ":65535";
1409}
1410else if (prev==-3)
1411{if (num==1) o.value = num;
1412else o.value = "1:" + (num-1);
1413}
1414else if (prev!=-1) o.value = prev + ":" + num;
1415else o.value = num;
1416}
1417return true;
1418}
1419function is_portlist(o)
1420{if (!nav) keyPressed = IEKey();
1421else keyPressed = NSKey();
1422if (keyPressed == 0 ) return true;
1423if (o.value.length>36) return false;
1424if ((keyPressed>47 && keyPressed<58) || keyPressed == 32)
1425{return true;
1426}
1427else
1428{return false;
1429}
1430}
1431function validate_portlist(o, v)
1432{if (o.value.length==0)
1433return true;
1434num = 0;
1435for(i=0; i<o.value.length; i++)
1436{c=o.value.charAt(i);
1437if (c>='0'&&c<='9')
1438{num = num*10 + (c-'0');
1439}
1440else
1441{if (num>255)
1442{alert(num + ' <#JS_validport#>');
1443o.value = "";
1444o.focus();
1445return false;
1446}
1447num = 0;
1448}
1449}
1450if (num>255)
1451{alert(num + ' <#JS_validport#>');
1452o.value = "";
1453o.focus();
1454return false;
1455}
1456return true;
1457}
1458function add_option(o, s, f)
1459{tail = o.options.length;
1460o.options[tail] = new Option(s);
1461o.options[tail].value = s;
1462if (f==1)
1463{o.options[tail].selected = f;
1464}
1465}
1466function add_option_match(o, s, f)
1467{tail = o.options.length;
1468o.options[tail] = new Option(s);
1469o.options[tail].value = s;
1470if (f==s)
1471{o.options[tail].selected = 1;
1472return(1);
1473}
1474else return(0);
1475}
1476function add_option_match_x(o, s, f)
1477{tail = o.options.length;
1478o.options[tail] = new Option(s);
1479o.options[tail].value = tail;
1480if (tail==f)
1481{o.options[tail].selected = 1;
1482return(1);
1483}
1484else return(0);
1485}
1486function add_option_x(o, i, s, f)
1487{tail = o.options.length;
1488o.options[tail] = new Option(s);
1489o.options[tail].value = i;
1490if (f==1)
1491{o.options[tail].selected = f;
1492}
1493}
1494function free_options(o)
1495{if (o==null) return;
1496count = o.options.length;
1497for (i=0; i<count; i++)
1498{o.options[0].value = null;
1499o.options[0] = null;
1500}
1501}
1502function find_option(o)
1503{count = o.options.length;
1504for (i=0; i<count; i++)
1505{if (o.options[i].selected)
1506return(o.options[i].value);
1507}
1508return(null);
1509}
1510function add_options(o, arr, orig)
1511{for (i = 0; i < arr.length; i++)
1512{if (orig == arr[i])
1513add_option(o, arr[i], 1);
1514else
1515add_option(o, arr[i], 0);
1516}
1517}
1518function add_options_x(o, arr, orig)
1519{for (i = 0; i < arr.length; i++)
1520{if (orig == i)
1521add_option_x(o, i, arr[i], 1);
1522else
1523add_option_x(o, i, arr[i], 0);
1524}
1525}
1526function add_options_x2(o, varr, arr, orig)
1527{for (i = 0; i < arr.length; i++)
1528{if (orig == varr[i])
1529add_option_x(o, varr[i], arr[i], 1);
1530else
1531add_option_x(o, varr[i], arr[i], 0);
1532}
1533}
1534function rcheck(o)
1535{if (o[0].checked == true)
1536return("1");
1537else
1538return("0");
1539}
1540function SaveChannelList(o)
1541{count = o.options.length;
1542chanList = new Array;
1543for (i=0; i<count; i++)
1544{chanList[chanList.length] = o.options[i].value;
1545}
1546}
1547function RestoreChannelList(d, isOut, isTurbo)
1548{for (i=0; i< chanList.length; i++)
1549{if (isOut=="0"&&chanList[i]>=100) return;
1550if (chanList[i] == 999) return;
1551d[d.length] = chanList[i];
1552}
1553}
1554function RefreshChannelList(isOut, isTurbo)
1555{orig = document.form.WLANConfig11a_Channel.value;
1556free_options(document.form.WLANConfig11a_Channel);
1557if (isTurbo=="1")
1558{if (isOut == "1")
1559{items = new Array("42","50","58","152","160");
1560}
1561else
1562{items = new Array("42","50","58");
1563}
1564}
1565else
1566{items = new Array;
1567RestoreChannelList(items, isOut, isTurbo);
1568}
1569add_options(document.form.WLANConfig11a_Channel, items, orig);
1570}
1571function RefreshRateList(isTurbo)
1572{orig = document.form.WLANConfig11a_DataRate.value;
1573free_options(document.form.WLANConfig11a_DataRate);
1574if (isTurbo=="1")
1575{items = new Array("Best","12","18","24","36","48","72","96","108");
1576}
1577else
1578{items = new Array("Best","6","9","12","18","24","36","48","54");
1579}
1580add_options_x(document.form.WLANConfig11a_DataRate, items, orig);
1581}
1582function RefreshRateSetList(gmode, chg)
1583{orig = document.form.WLANConfig11b_DataRate.value;
1584free_options(document.form.WLANConfig11b_DataRate);
1585if (gmode != "3")
1586{if (gmode == "1")
1587{items = new Array("1 & 2 Mbps", "Default", "All");
1588}
1589else
1590{items = new Array("1 & 2 Mbps", "Default", "All");
1591}
1592if (chg) orig = 1;
1593}
1594else
1595{items = new Array("1 & 2 Mbps", "Default");
1596if (chg) orig = 1;
1597}
1598add_options_x(document.form.WLANConfig11b_DataRate, items, orig);
1599}
1600function getDateCheck(str, pos)
1601{if (str.charAt(pos) == '1')
1602return true;
1603else
1604return false;
1605}
1606function getTimeRange(str, pos)
1607{if (pos == 0)
1608return str.substring(0,2);
1609else if (pos == 1)
1610return str.substring(2,4);
1611else if (pos == 2)
1612return str.substring(4,6);
1613else if (pos == 3)
1614return str.substring(6,8);
1615}
1616function setDateCheck(d1, d2, d3, d4, d5, d6, d7)
1617{str = "";
1618if (d7.checked == true ) str = "1" + str;
1619else str = "0" + str;
1620if (d6.checked == true ) str = "1" + str;
1621else str = "0" + str;
1622if (d5.checked == true ) str = "1" + str;
1623else str = "0" + str;
1624if (d4.checked == true ) str = "1" + str;
1625else str = "0" + str;
1626if (d3.checked == true ) str = "1" + str;
1627else str = "0" + str;
1628if (d2.checked == true ) str = "1" + str;
1629else str = "0" + str;
1630if (d1.checked == true ) str = "1" + str;
1631else str = "0" + str;
1632return str;
1633}
1634function setTimeRange(sh, sm, eh, em)
1635{return(sh.value+sm.value+eh.value+em.value);
1636}
1637function to_quick()
1638{location.href = "Basic_GOperation_Content.asp";
1639}
1640function load_wizard()
1641{if (document.form.first_time.value != "1")
1642{rst = confirm("<#JS_FirstTime#>");
1643if (rst)
1644{setTimeout("to_quick()", 1000)
1645}
1646}
1647}
1648function load_body() {
1649document.form.next_host.value = location.host;
1650if (document.form.current_page.value == "Advanced_Wireless_Content.asp") {
1651document.form.wl_ssid.value = decodeURIComponent(document.form.wl_ssid2.value);
1652if (window.top.isBand() == 'b') {
1653inputCtrl(document.form.wl_gmode, 0);
1654inputCtrl(document.form.wl_gmode_check, 0);
1655}
1656if (window.top.isModel()=="SnapAP" || window.top.isCard()=='ralink') {
1657wl_auth_mode_reconf();
1658}
1659wl_auth_mode_change(1);
1660change = 0;
1661window.top.pageChanged = 0;
1662if (document.form.wl_gmode_protection_x.value == "1") {
1663document.form.wl_gmode_check.checked = true;
1664} else {
1665document.form.wl_gmode_check.checked = false;
1666}
1667/* For G-protect mode */
1668if (window.top.isBand() == 'b' || document.form.wl_gmode.value=="0")
1669inputCtrl(document.form.wl_gmode_check, 0);
1670}
1671else if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp")
1672{final_flag = 1;
1673masq_wepkey_guest();
1674wl_auth_mode_reconf_guest();
1675wl_auth_mode_change_guest(1);
1676}
1677else if (document.form.current_page.value == "Advanced_WMode_Content.asp")
1678{if (window.top.isCard()=='ralink')
1679{document.form.wl_mode_x.options[1].value = null;
1680document.form.wl_mode_x.options[1] = null;
1681change_wireless_bridge2(document.form.wl_mode_x.value,
1682rcheck(document.form.wl_wdsapply_x),
16831, 0);
1684}
1685else if (window.top.isModel2()=='WL530')
1686{change_wireless_bridge2(document.form.wl_mode_x.value,
1687rcheck(document.form.wl_wdsapply_x),
16881, 0);
1689}
1690else
1691{change_wireless_bridge(document.form.wl_mode_x.value,
1692rcheck(document.form.wl_wdsapply_x),
1693/*rcheck(document.form.wl_lazywds), */
16940, 0);
1695}
1696}
1697else if (document.form.current_page.value == "Advanced_WAdvanced_Content.asp")
1698{if (window.top.isCard()!='ralink')
1699wl_rate_change();
1700if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP" && window.top.isModel()!="WL300" && window.top.isModel()!="WL331" && window.top.isCard()!='ralink')
1701{if (window.top.isBand() == 'b') inputCtrl(document.form.wl_frameburst, 0);
1702document.form.wl_radio_date_x_Sun.checked = getDateCheck(document.form.wl_radio_date_x.value, 0);
1703document.form.wl_radio_date_x_Mon.checked = getDateCheck(document.form.wl_radio_date_x.value, 1);
1704document.form.wl_radio_date_x_Tue.checked = getDateCheck(document.form.wl_radio_date_x.value, 2);
1705document.form.wl_radio_date_x_Wed.checked = getDateCheck(document.form.wl_radio_date_x.value, 3);
1706document.form.wl_radio_date_x_Thu.checked = getDateCheck(document.form.wl_radio_date_x.value, 4);
1707document.form.wl_radio_date_x_Fri.checked = getDateCheck(document.form.wl_radio_date_x.value, 5);
1708document.form.wl_radio_date_x_Sat.checked = getDateCheck(document.form.wl_radio_date_x.value, 6);
1709document.form.wl_radio_time_x_starthour.value = getTimeRange(document.form.wl_radio_time_x.value, 0);
1710document.form.wl_radio_time_x_startmin.value = getTimeRange(document.form.wl_radio_time_x.value, 1);
1711document.form.wl_radio_time_x_endhour.value = getTimeRange(document.form.wl_radio_time_x.value, 2);
1712document.form.wl_radio_time_x_endmin.value = getTimeRange(document.form.wl_radio_time_x.value, 3);
1713}
1714}
1715else if (document.form.current_page.value == "Advanced_LANWAN_Content.asp")
1716{final_flag = 1;
1717if (document.form.wan_dnsenable_x[0].checked == true)
1718{inputCtrl(document.form.wan_dns1_x, 0);
1719inputCtrl(document.form.wan_dns2_x, 0);
1720}
1721else
1722{inputCtrl(document.form.wan_dns1_x, 1);
1723inputCtrl(document.form.wan_dns2_x, 1);
1724}
1725if (window.top.isModel()!="SnapAP")
1726{change_wan_type(document.form.wan_proto.value);
1727if (document.form.wan_pppoe_txonly_x.value == "1")
1728{document.form.wan_pppoe_idletime_check.checked = true;
1729}
1730/*
1731if (window.top.isModel2()=='WL520' && window.top.isModel3()!='WL550gE')
1732{document.form.wan_mode_x.options[2].value = null;
1733document.form.wan_mode_x.options[2] = null;
1734}
1735*/
1736}
1737if (window.top.isModel()!="WL500" || window.top.supportCDMA()!="1")
1738{document.form.wan_proto.options[5].value = null;
1739document.form.wan_proto.options[5] = null;
1740}
1741}
1742else if (document.form.current_page.value == "Advanced_MultiPPPoE_Content.asp")
1743{if (document.form.PPPConnection_x_MultiPPPoEEnable1[0].checked == true)
1744{flag=1;
1745}
1746else
1747{flag=0;
1748}
1749inputCtrl(document.form.PPPConnection_x_UserName1, flag);
1750inputCtrl(document.form.PPPConnection_x_Password1, flag);
1751inputCtrl(document.form.PPPConnection_x_IdleTime1, flag);
1752inputCtrl(document.form.PPPConnection_x_IdleTime1_check, flag);
1753inputCtrl(document.form.PPPConnection_x_PPPoEMTU1, flag);
1754inputCtrl(document.form.PPPConnection_x_PPPoEMRU1, flag);
1755inputCtrl(document.form.PPPConnection_x_ServiceName1, flag);
1756inputCtrl(document.form.PPPConnection_x_AccessConcentrator1, flag);
1757if (document.form.PPPConnection_x_MultiPPPoEEnable2[0].checked == true)
1758{flag=1;
1759}
1760else
1761{flag=0;
1762}
1763inputCtrl(document.form.PPPConnection_x_UserName2, flag);
1764inputCtrl(document.form.PPPConnection_x_Password2, flag);
1765inputCtrl(document.form.PPPConnection_x_IdleTime2, flag);
1766inputCtrl(document.form.PPPConnection_x_IdleTime2_check, flag);
1767inputCtrl(document.form.PPPConnection_x_PPPoEMTU2, flag);
1768inputCtrl(document.form.PPPConnection_x_PPPoEMRU2, flag);
1769inputCtrl(document.form.PPPConnection_x_ServiceName2, flag);
1770inputCtrl(document.form.PPPConnection_x_AccessConcentrator2, flag);
1771if (document.form.PPPConnection_x_IdleTxOnly1.value == "1")
1772{document.form.PPPConnection_x_IdleTime1_check.checked = true;
1773}
1774if (document.form.PPPConnection_x_IdleTxOnly2.value == "1")
1775{document.form.PPPConnection_x_IdleTime2_check.checked = true;
1776}
1777}
1778else if (document.form.current_page.value == "Advanced_RLANWAN_Content.asp")
1779{}
1780else if (document.form.current_page.value == "Advanced_PortTrigger_Content.asp")
1781{wItem = new Array(
1782new Array("Quicktime 4 Client", "554", "TCP", "6970:32000", "UDP"),
1783new Array("Real Audio", "7070", "TCP", "6970:7170", "UDP"));
1784free_options(document.form.TriggerKnownApps);
1785add_option(document.form.TriggerKnownApps, "User Defined", 1);
1786for (i = 0; i < wItem.length; i++)
1787{add_option(document.form.TriggerKnownApps, wItem[i][0], 0);
1788}
1789}
1790else if (document.form.current_page.value == "Advanced_VirtualServer_Content.asp")
1791{wItem = new Array(
1792new Array("FTP", "20:21", "TCP"),
1793new Array("TELNET", "23", "TCP"),
1794new Array("SMTP", "25", "TCP"),
1795new Array("DNS", "53", "UDP"),
1796new Array("FINGER", "79", "TCP"),
1797new Array("HTTP", "80", "TCP"),
1798new Array("POP3", "110", "TCP"),
1799new Array("SNMP", "161", "UDP"),
1800new Array("SNMP TRAP", "162", "UDP"));
1801free_options(document.form.KnownApps);
1802add_option(document.form.KnownApps, "User Defined", 1);
1803for (i = 0; i < wItem.length; i++)
1804{add_option(document.form.KnownApps, wItem[i][0], 0);
1805}
1806}
1807else if (document.form.current_page.value == "Advanced_BasicFirewall_Content.asp")
1808{change_firewall(rcheck(document.form.fw_enable_x));
1809}
1810else if (document.form.current_page.value == "Advanced_Firewall_Content.asp")
1811{wItem = new Array(
1812new Array("WWW", "80", "TCP"),
1813new Array("TELNET", "23", "TCP"),
1814new Array("FTP", "20:21", "TCP")
1815);
1816free_options(document.form.LWKnownApps);
1817add_option(document.form.LWKnownApps, "User Defined", 1);
1818for (i = 0; i < wItem.length; i++)
1819{add_option(document.form.LWKnownApps, wItem[i][0], 0);
1820}
1821document.form.filter_lw_date_x_Sun.checked = getDateCheck(document.form.filter_lw_date_x.value, 0);
1822document.form.filter_lw_date_x_Mon.checked = getDateCheck(document.form.filter_lw_date_x.value, 1);
1823document.form.filter_lw_date_x_Tue.checked = getDateCheck(document.form.filter_lw_date_x.value, 2);
1824document.form.filter_lw_date_x_Wed.checked = getDateCheck(document.form.filter_lw_date_x.value, 3);
1825document.form.filter_lw_date_x_Thu.checked = getDateCheck(document.form.filter_lw_date_x.value, 4);
1826document.form.filter_lw_date_x_Fri.checked = getDateCheck(document.form.filter_lw_date_x.value, 5);
1827document.form.filter_lw_date_x_Sat.checked = getDateCheck(document.form.filter_lw_date_x.value, 6);
1828document.form.filter_lw_time_x_starthour.value = getTimeRange(document.form.filter_lw_time_x.value, 0);
1829document.form.filter_lw_time_x_startmin.value = getTimeRange(document.form.filter_lw_time_x.value, 1);
1830document.form.filter_lw_time_x_endhour.value = getTimeRange(document.form.filter_lw_time_x.value, 2);
1831document.form.filter_lw_time_x_endmin.value = getTimeRange(document.form.filter_lw_time_x.value, 3);
1832}
1833else if (document.form.current_page.value == "Advanced_LFirewall_Content.asp")
1834{document.form.FirewallConfig_WanLocalActiveDate_Sun.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 0);
1835document.form.FirewallConfig_WanLocalActiveDate_Mon.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 1);
1836document.form.FirewallConfig_WanLocalActiveDate_Tue.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 2);
1837document.form.FirewallConfig_WanLocalActiveDate_Wed.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 3);
1838document.form.FirewallConfig_WanLocalActiveDate_Thu.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 4);
1839document.form.FirewallConfig_WanLocalActiveDate_Fri.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 5);
1840document.form.FirewallConfig_WanLocalActiveDate_Sat.checked = getDateCheck(document.form.FirewallConfig_WanLocalActiveDate.value, 6);
1841document.form.FirewallConfig_WanLocalActiveTime_starthour.value = getTimeRange(document.form.FirewallConfig_WanLocalActiveTime.value, 0);
1842document.form.FirewallConfig_WanLocalActiveTime_startmin.value = getTimeRange(document.form.FirewallConfig_WanLocalActiveTime.value, 1);
1843document.form.FirewallConfig_WanLocalActiveTime_endhour.value = getTimeRange(document.form.FirewallConfig_WanLocalActiveTime.value, 2);
1844document.form.FirewallConfig_WanLocalActiveTime_endmin.value = getTimeRange(document.form.FirewallConfig_WanLocalActiveTime.value, 3);
1845}
1846else if (document.form.current_page.value == "Advanced_URLFilter_Content.asp")
1847{document.form.url_date_x_Sun.checked = getDateCheck(document.form.url_date_x.value, 0);
1848document.form.url_date_x_Mon.checked = getDateCheck(document.form.url_date_x.value, 1);
1849document.form.url_date_x_Tue.checked = getDateCheck(document.form.url_date_x.value, 2);
1850document.form.url_date_x_Wed.checked = getDateCheck(document.form.url_date_x.value, 3);
1851document.form.url_date_x_Thu.checked = getDateCheck(document.form.url_date_x.value, 4);
1852document.form.url_date_x_Fri.checked = getDateCheck(document.form.url_date_x.value, 5);
1853document.form.url_date_x_Sat.checked = getDateCheck(document.form.url_date_x.value, 6);
1854document.form.url_time_x_starthour.value = getTimeRange(document.form.url_time_x.value, 0);
1855document.form.url_time_x_startmin.value = getTimeRange(document.form.url_time_x.value, 1);
1856document.form.url_time_x_endhour.value = getTimeRange(document.form.url_time_x.value, 2);
1857document.form.url_time_x_endmin.value = getTimeRange(document.form.url_time_x.value, 3);
1858}
1859else if (document.form.current_page.value == "Advanced_DHCP_Content.asp" ||
1860document.form.current_page.value == "Advanced_RDHCP_Content.asp")
1861{final_flag = 1;
1862}
1863else if (document.form.current_page.value == "Advanced_DMZDHCP_Content.asp")
1864{}
1865else if (document.form.current_page.value == "Advanced_DDNS_Content.asp")
1866{}
1867else if (document.form.current_page.value == "Advanced_APLAN_Content.asp")
1868{if (document.form.lan_proto_x[0].checked == true)
1869{inputCtrl(document.form.lan_ipaddr, 0);
1870inputCtrl(document.form.lan_netmask, 0);
1871inputCtrl(document.form.lan_gateway, 0);
1872}
1873else
1874{inputCtrl(document.form.lan_ipaddr, 1);
1875inputCtrl(document.form.lan_netmask, 1);
1876inputCtrl(document.form.lan_gateway, 1);
1877}
1878}
1879else if (document.form.current_page.value == "Advanced_WebCam_Content.asp")
1880{if (window.top.isMode() == "AP")
1881{if (document.form.usb_webenable_x.value==2)
1882document.form.usb_webenable_x.value=1;
1883document.form.usb_webenable_x.options[2].value = null;
1884document.form.usb_webenable_x.options[2] = null;
1885}
1886if (document.form.usb_webdriver_x.value == 0)
1887{if (document.form.usb_webimage_x.value==0)
1888document.form.usb_webimage_x.value=1;
1889document.form.usb_webimage_x.options[0].value = null;
1890document.form.usb_webimage_x.options[0] = null;
1891}
1892document.form.usb_websecurity_date_x_Sun.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 0);
1893document.form.usb_websecurity_date_x_Mon.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 1);
1894document.form.usb_websecurity_date_x_Tue.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 2);
1895document.form.usb_websecurity_date_x_Wed.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 3);
1896document.form.usb_websecurity_date_x_Thu.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 4);
1897document.form.usb_websecurity_date_x_Fri.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 5);
1898document.form.usb_websecurity_date_x_Sat.checked = getDateCheck(document.form.usb_websecurity_date_x.value, 6);
1899document.form.usb_websecurity_time_x_starthour.value = getTimeRange(document.form.usb_websecurity_time_x.value, 0);
1900document.form.usb_websecurity_time_x_startmin.value = getTimeRange(document.form.usb_websecurity_time_x.value, 1);
1901document.form.usb_websecurity_time_x_endhour.value = getTimeRange(document.form.usb_websecurity_time_x.value, 2);
1902document.form.usb_websecurity_time_x_endmin.value = getTimeRange(document.form.usb_websecurity_time_x.value, 3);
1903if (document.form.usb_webhttpcheck_x.value == "1")
1904{document.form.usb_webhttpport_x_check.checked = true;
1905}
1906else
1907{document.form.usb_webhttpport_x_check.checked = false;
1908}
1909}
1910else if (document.form.current_page.value == "Advanced_DMZIP11g_Content.asp" ||
1911document.form.current_page.value == "Advanced_DMZIP_Content.asp")
1912{change_wireless_firewall();
1913}
1914else if (document.form.current_page.value == "Advanced_DMZIP_Content.asp")
1915{if (document.form.LANHostConfig_lan_proto_x[0].checked == true)
1916{inputCtrl(document.form.lan_ipaddr, 0);
1917inputCtrl(document.form.lan_netmask, 0);
1918inputCtrl(document.form.lan_gateway, 0);
1919}
1920else
1921{inputCtrl(document.form.lan_ipaddr, 1);
1922inputCtrl(document.form.lan_netmask, 1);
1923inputCtrl(document.form.lan_gateway, 1);
1924}
1925}
1926else if (document.form.current_page.value == "Main_GStatus_Content.asp")
1927{}/*
1928else if (document.form.current_page.value == "Advanced_QOSUserSpec_Content.asp")
1929{if (document.form.qos_dfragment_enable[0].checked == true)
1930{inputCtrl(document.form.qos_dfragment_size, 1);
1931}
1932else
1933{inputCtrl(document.form.qos_dfragment_size, 0);
1934}
1935}*/
1936else if (document.form.current_page.value == "Advanced_StorageRight_Content.asp")
1937{if ( (document.form.Storage_SharedList_s.options[0].value != -1) && (top.Edit_Flag == "on") )
1938{if (!validate_duplicate2(document.form.Storage_SharedList_s, top.Share_Path, 32, 0)) {
1939document.form.Storage_SharedList_s.selectedIndex = document.form.Storage_SharedList_s.length-1;
1940top.Edit_Flag = "";
1941document.form.Storage_SharedList2.click();
1942}
1943}
1944}
1945change = 0;
1946}
1947function unload_body()
1948{return true;
1949}
1950function change_wireless_firewall()
1951{if (window.top.isModel() == "WL600")
1952{if (document.form.FirewallConfig_DmzEnable[0].checked == true )
1953{if (document.form.FirewallConfig_DmzDevices.value == "Both")
1954document.form.WirelessFirewall_img.src = "graph/wf_both.gif";
1955else if (document.form.FirewallConfig_DmzDevices.value == "802.11a only")
1956document.form.WirelessFirewall_img.src = "graph/wf_a.gif";
1957else if (document.form.FirewallConfig_DmzDevices.value == "802.11g only")
1958document.form.WirelessFirewall_img.src = "graph/wf_g.gif";
1959}
1960else  document.form.WirelessFirewall_img.src = "graph/wf_none.gif";
1961}
1962else
1963{if (document.form.FirewallConfig_DmzEnable[0].checked == true)
1964{document.form.WirelessFirewall_img.src = "graph/wf_g.gif";
1965}
1966else document.form.WirelessFirewall_img.src = "graph/wf_none.gif";
1967}
1968}
1969function change_firewall(r)
1970{if (r == "0")
1971{inputRCtrl1(document.form.misc_http_x, 0);
1972inputRCtrl2(document.form.misc_http_x, 1);
1973inputCtrl(document.form.misc_httpport_x, 0);
1974if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
1975{if (window.top.isFlash() != '2MB' && window.top.isModel()!= "WL331" )
1976{inputRCtrl1(document.form.misc_lpr_x, 0);
1977inputRCtrl2(document.form.misc_lpr_x, 1);
1978}
1979inputRCtrl1(document.form.misc_ping_x, 0);
1980inputRCtrl2(document.form.misc_ping_x, 1);
1981}
1982}
1983else
1984{inputRCtrl1(document.form.misc_http_x, 1);
1985inputCtrl(document.form.misc_httpport_x, 1);
1986if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
1987{if (window.top.isFlash() != '2MB' && window.top.isModel()!="WL331")
1988{inputRCtrl1(document.form.misc_lpr_x, 1);
1989}
1990inputRCtrl1(document.form.misc_ping_x, 1);
1991}
1992}
1993}
1994function change_wireless_bridge(m, a, r, mflag)
1995{if (a=="0" && r == "0" && mflag != 1)
1996{document.form.wl_mode_x.value = "0";
1997m = "0";
1998}
1999if (m == "0")
2000{inputRCtrl2(document.form.wl_wdsapply_x, 1);
2001inputRCtrl1(document.form.wl_wdsapply_x, 0);
2002}
2003else
2004{if (a=="0" && r == "0")
2005{inputRCtrl2(document.form.wl_wdsapply_x, 0);
2006}
2007inputRCtrl1(document.form.wl_wdsapply_x, 1);
2008if (m != 0) {
2009if (document.form.wl_channel.value == "0")
2010{alert("<#JS_fixchannel#>");
2011document.form.wl_channel.options[0].selected = 0;
2012document.form.wl_channel.options[1].selected = 1;
2013}
2014}
2015}
2016return;
2017if (a=="0" && r == "0" && mflag != 1)
2018{document.form.wl_mode_x.value = "0";
2019m = "0";
2020}
2021if (m == "0")
2022{wdsimage = "wds_ap";
2023inputRCtrl2(document.form.wl_wdsapply_x, 1);
2024inputRCtrl1(document.form.wl_wdsapply_x, 0);
2025}
2026else
2027{if (a=="0" && r == "0")
2028{inputRCtrl2(document.form.wl_wdsapply_x, 0);
2029}
2030inputRCtrl1(document.form.wl_wdsapply_x, 1);
2031if (m == "1")
2032wdsimage = "wds_wds";
2033else
2034wdsimage = "wds_mixed";
2035if (a == "0")
2036{if (r == "0")
2037wdsimage += "_connect";
2038else
2039wdsimage += "_anony";
2040}
2041else
2042{if (r == "0")
2043wdsimage += "_connect";
2044else
2045wdsimage += "_both";
2046}
2047if (document.form.wl_channel.value == "0")
2048{alert("<#JS_fixchannel#>");
2049document.form.wl_channel.options[0].selected = 0;
2050document.form.wl_channel.options[1].selected = 1;
2051}
2052}
2053wdsimage = "graph/" + wdsimage + ".gif";
2054if (window.top.isFlash() != '2MB')
2055document.form.WirelessBridge_img.src = wdsimage;
2056}
2057function change_wireless_bridge2(m, a, r, mflag)
2058{return;
2059if (a=="0" && r == "0" && mflag != 1)
2060{document.form.wl_mode_x.value = "0";
2061m = "0";
2062}
2063if (m == "0")
2064{wdsimage = "wds_ap";
2065inputRCtrl2(document.form.wl_wdsapply_x, 1);
2066inputRCtrl1(document.form.wl_wdsapply_x, 0);
2067}
2068else
2069{if (a=="0" && r == "0")
2070{inputRCtrl2(document.form.wl_wdsapply_x, 0);
2071}
2072inputRCtrl1(document.form.wl_wdsapply_x, 1);
2073if (m == "1")
2074wdsimage = "wds_wds";
2075else
2076wdsimage = "wds_mixed";
2077if (a == "0")
2078{if (r == "0")
2079wdsimage += "_connect";
2080else
2081wdsimage += "_anony";
2082}
2083else
2084{if (r == "0")
2085wdsimage += "_connect";
2086else
2087wdsimage += "_both";
2088}
2089if (document.form.wl_channel.value == "0")
2090{alert("<#JS_fixchannel#>");
2091document.form.wl_channel.options[0].selected = 0;
2092document.form.wl_channel.options[1].selected = 1;
2093}
2094}
2095wdsimage = "graph/" + wdsimage + ".gif";
2096if (window.top.isFlash() != '2MB' && window.top.isModel2()!='WL530')
2097document.form.WirelessBridge_img.src = wdsimage;
2098}
2099function onSubmit() {
2100change = 0;
2101window.top.pageChanged = 0;
2102window.top.pageChangedCount = 0;
2103if (document.form.current_page.value == "Advanced_ACL_Content.asp") {
2104if (window.top.isMode() == "AP")
2105document.form.next_page.value = "Advanced_APLAN_Content.asp";
2106else if (window.top.isMode() == "Router")
2107document.form.next_page.value = "Advanced_RLANWAN_Content.asp";
2108} else if (document.form.current_page.value == "Advanced_LANWAN_Content.asp") {
2109if (document.form.wan_proto.value=="static" || document.form.wan_proto.value=="pptp") {
2110if(!wan_netmask_check(document.form.wan_netmask))
2111return false;
2112if(!validate_ipaddr_final(document.form.wan_ipaddr, 'wan_ipaddr') ||
2113!validate_ipaddr_final(document.form.wan_netmask, 'wan_netmask') ||
2114!validate_ipaddr_final(document.form.wan_gateway, 'wan_gateway')
2115)
2116return false;
2117}
2118if (document.form.wan_dnsenable_x[0].checked != true) {
2119if(!validate_ipaddr_final(document.form.wan_dns1_x, 'wan_dns1_x') ||
2120!validate_ipaddr_final(document.form.wan_dns2_x, 'wan_dns2_x')
2121)
2122return false;
2123}
2124if(!validate_ipaddr_final(document.form.lan_ipaddr, 'lan_ipaddr') ||
2125!validate_ipaddr_final(document.form.lan_netmask, 'lan_netmask')
2126)
2127return false;
2128checkSubnet();
2129}
2130else if (document.form.current_page.value == "Advanced_RLANWAN_Content.asp")
2131{checkSubnet();
2132}
2133else if (document.form.current_page.value == "Advanced_DMZIP_Content.asp")
2134{checkDmzSubnet();
2135}
2136else if (document.form.current_page.value == "Advanced_Firewall_Content.asp")
2137{updateDateTime(document.form.current_page.value);
2138}
2139else if (document.form.current_page.value == "Advanced_BasicFirewall_Content.asp")
2140{inputRCtrl1(document.form.misc_http_x, 1);
2141if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
2142{if ( window.top.isFlash() != '2MB' && window.top.isModel()!="WL331")
2143{inputRCtrl1(document.form.misc_lpr_x, 1);
2144}
2145inputRCtrl1(document.form.misc_ping_x, 1);
2146}
2147}
2148else if (document.form.current_page.value == "Advanced_LFirewall_Content.asp")
2149{updateDateTime(document.form.current_page.value);
2150}
2151else if (document.form.current_page.value == "Advanced_URLFilter_Content.asp")
2152{updateDateTime(document.form.current_page.value);
2153}
2154else if (document.form.current_page.value == "Advanced_WebCam_Content.asp")
2155{updateDateTime(document.form.current_page.value);
2156}
2157else if (document.form.current_page.value == "Advanced_WAdvanced_Content.asp")
2158{updateDateTime(document.form.current_page.value);
2159}
2160else if (document.form.current_page.value == "Advanced_WMode_Content.asp")
2161{if (document.form.wl_mode_x.value == "0")
2162{inputRCtrl1(document.form.wl_wdsapply_x, 1);
2163inputRCtrl2(document.form.wl_wdsapply_x, 1);
2164}
2165}
2166else if (document.form.current_page.value == "Advanced_Wireless_Content.asp")
2167{if(!validate_wlphrase('WLANConfig11b', 'wl_wpa_psk', document.form.wl_wpa_psk))
2168return false;
2169document.form.wl_ssid2.value = encodeURIComponent(document.form.wl_ssid.value);
2170inputCtrl(document.form.wl_phrase_x, 1);
2171inputCtrl(document.form.wl_wep_x, 1);
2172inputCtrl(document.form.wl_key1, 1);
2173inputCtrl(document.form.wl_key2, 1);
2174inputCtrl(document.form.wl_key3, 1);
2175inputCtrl(document.form.wl_key4, 1);
2176inputCtrl(document.form.wl_key, 1);
2177}
2178else if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp")
2179{if (!validate_ipaddr_final(document.form.lan1_ipaddr, 'lan1_ipaddr') ||
2180!validate_ipaddr_final(document.form.lan1_netmask, 'lan1_netmask') ||
2181!validate_ipaddr_final(document.form.dhcp1_start, 'dhcp1_start') ||
2182!validate_ipaddr_final(document.form.dhcp1_end, 'dhcp1_end')) return false;
2183if (intoa(document.form.dhcp1_start.value)>intoa(document.form.dhcp1_end.value))
2184{tmp = document.form.dhcp1_start.value;
2185document.form.dhcp1_start.value = document.form.dhcp1_end.value;
2186document.form.dhcp1_end.value = tmp;
2187}
2188inputCtrl(document.form.wl_guest_phrase_x_1, 1);
2189inputCtrl(document.form.wl_guest_wep_x_1, 1);
2190inputCtrl(document.form.wl_guest_key1_1, 1);
2191inputCtrl(document.form.wl_guest_key2_1, 1);
2192inputCtrl(document.form.wl_guest_key3_1, 1);
2193inputCtrl(document.form.wl_guest_key4_1, 1);
2194inputCtrl(document.form.wl_guest_key_1, 1);
2195unmasq_wepkey_guest();
2196}
2197else if (document.form.current_page.value == "Advanced_DHCP_Content.asp")
2198{if (!validate_ipaddr_final(document.form.dhcp_start, 'dhcp_start') ||
2199!validate_ipaddr_final(document.form.dhcp_end, 'dhcp_end') ||
2200!validate_ipaddr_final(document.form.dhcp_gateway_x, 'dhcp_gateway_x') ||
2201!validate_ipaddr_final(document.form.dhcp_dns1_x, 'dhcp_dns1_x') ||
2202!validate_ipaddr_final(document.form.dhcp_wins_x, 'dhcp_wins_x') ) return false;
2203if (intoa(document.form.dhcp_start.value)>intoa(document.form.dhcp_end.value))
2204{tmp = document.form.dhcp_start.value;
2205document.form.dhcp_start.value = document.form.dhcp_end.value;
2206document.form.dhcp_end.value = tmp;
2207}
2208}
2209return true;
2210}
2211function onSubmitCtrl(o, s) {
2212document.form.action_mode.value = s;
2213return (onSubmit());
2214}
2215function load_upload()
2216{varload=0;
2217}
2218function onSubmitCtrlOnly(o, s)
2219{if (s!='Upload' && s!='Upload1') document.form.action_mode.value = s;
2220if (s=='Upload1')
2221{if (varload)
2222{alert("<#JS_FirmUpgrade#>");
2223return false;
2224}
2225else document.form.submit();
2226varload++;
2227}
2228return true;
2229}
2230function validate_ddns_hostname(o)
2231{dot=0;
2232s=o.value;
2233if(!s.match(".asuscomm.com"))
2234{alert("<#LANHostConfig_x_DDNS_alarm_7#>");
2235return false;
2236}
2237if (!validate_string(o))
2238{return false;
2239}
2240for(i=0;i<s.length;i++)
2241{c = s.charCodeAt(i);
2242if (c==46)
2243{dot++;
2244if(dot>2)
2245{alert("<#LANHostConfig_x_DDNS_alarm_7#>");
2246return false;
2247}
2248}
2249if (!validate_hostnamechar(c))
2250{alert("<#LANHostConfig_x_DDNS_alarm_13#> '" + s.charAt(i) +"' !");
2251return(false);
2252}
2253}
2254return(true);
2255}
2256function validate_hostnamechar(ch)
2257{if (ch>=48&&ch<=57) return true;
2258if (ch>=97&&ch<=122) return true;
2259if (ch>=65&&ch<=90) return true;
2260if (ch==45) return true;
2261if (ch==46) return true;
2262return false;
2263}
2264function onSubmitApply(s)
2265{window.top.pageChanged = 0;
2266window.top.pageChangedCount = 0;
2267if (document.form.current_page.value == "Advanced_PortMapping_Content.asp")
2268{if (s == "0")
2269{action = document.form.IPConnection_MappedAction_0;
2270local = document.form.IPConnection_MappedIP_0;
2271port = document.form.IPConnection_MappedInPort_0;
2272desc = document.form.IPConnection_MappedDescript_0;
2273}
2274else if (s == "1")
2275{action = document.form.IPConnection_MappedAction_1;
2276local = document.form.IPConnection_MappedIP_1;
2277port = document.form.IPConnection_MappedInPort_1;
2278desc = document.form.IPConnection_MappedDescript_1;
2279}
2280else if (s == "2")
2281{action = document.form.IPConnection_MappedAction_2;
2282local = document.form.IPConnection_MappedIP_2;
2283port = document.form.IPConnection_MappedInPort_2;
2284desc = document.form.IPConnection_MappedDescript_2;
2285}
2286else if (s == "3")
2287{action = document.form.IPConnection_MappedAction_3;
2288local = document.form.IPConnection_MappedIP_3;
2289port = document.form.IPConnection_MappedInPort_3;
2290desc = document.form.IPConnection_MappedDescript_3;
2291}
2292else if (s == "4")
2293{action = document.form.IPConnection_MappedAction_4;
2294local = document.form.IPConnection_MappedIP_4;
2295port = document.form.IPConnection_MappedInPort_4;
2296desc = document.form.IPConnection_MappedDescript_4;
2297}
2298else if (s == "5")
2299{action = document.form.IPConnection_MappedAction_5;
2300local = document.form.IPConnection_MappedIP_5;
2301port = document.form.IPConnection_MappedInPort_5;
2302desc = document.form.IPConnection_MappedDescript_5;
2303}
2304if (action.value == "Set")
2305{if (!validate_ipaddr(local, "") ||
2306!validate_portrange(port, ""))
2307{return false;
2308}
2309else if (local.value=="" || port.value == "")
2310{alert("<#JS_ipblank1#>");
2311return false;
2312}
2313}
2314document.form.action_mode.value = action.value;
2315document.form.action_script.value = "portmapping.sh" + " " + action.value + " " + local.value + " " + port.value;
2316}
2317else if (document.form.current_page.value == "Advanced_ASUSDDNS_Content.asp")
2318{if(s=="hostname_check")
2319{if (!validate_ddns_hostname(document.form.ddns_hostname_x)) return false;
2320}
2321document.form.action_mode.value = "Update";
2322document.form.action_script.value = s;
2323}
2324else
2325{document.form.action_mode.value = "Update";
2326document.form.action_script.value = s;
2327}
2328return true;
2329}
2330function setup_script(s)
2331{if (document.form.current_page.value == "Advanced_ACL_Content.asp")
2332{document.form.action_script.value = s;
2333}
2334}
2335function change_common(o, s, v)
2336{change = 1;
2337window.top.pageChanged = 1;
2338if (v == "wl_auth_mode") /* Handle AuthenticationMethod Change */
2339{wl_auth_mode_change(0);
2340if (o.value == "psk" || o.value == "wpa")
2341{opts=document.form.wl_auth_mode.options;
2342if (opts[opts.selectedIndex].text == "WPA-Personal")
2343document.form.wl_wpa_mode.value="1";
2344else if (opts[opts.selectedIndex].text == "WPA2-Personal")
2345document.form.wl_wpa_mode.value="2";
2346else if (opts[opts.selectedIndex].text == "WPA-Auto-Personal")
2347document.form.wl_wpa_mode.value="0";
2348else if (opts[opts.selectedIndex].text == "WPA-Enterprise")
2349document.form.wl_wpa_mode.value="3";
2350else if (opts[opts.selectedIndex].text == "WPA-Auto-Enterprise")
2351document.form.wl_wpa_mode.value="4";
2352document.form.wl_wpa_psk.focus();
2353}
2354else if (o.value == "shared" || o.value == "radius")
2355document.form.wl_phrase_x.focus();
2356}
2357else if(s=="WLANConfig11b" && v == "wl_gmode")
2358{if(window.top.isBand() == 'b' || o.value=='0')
2359inputCtrl(document.form.wl_gmode_check, 0);
2360else inputCtrl(document.form.wl_gmode_check, 1);
2361}
2362else if (v == "wl_wep_x") /* Handle AuthenticationMethod Change */
2363{change_wlweptype(o, "WLANConfig11b");
2364}
2365else if (v == "wl_mode_x")
2366{change_wireless_bridge(o.value, rcheck(document.form.wl_wdsapply_x), 0, 1);
2367}
2368else if (v == "wl_crypto")
2369{wl_auth_mode_change(0);
2370}
2371else if (v == "wl_guest_auth_mode_1") /* Handle AuthenticationMethod Change */
2372{wl_auth_mode_change_guest(0);
2373if (o.value == "psk")
2374document.form.wl_guest_wpa_psk_1.focus();
2375else if (o.value == "shared" || o.value == "radius")
2376document.form.wl_guest_phrase_x_1.focus();
2377}
2378else if (v == "wl_guest_wep_x_1") /* Handle AuthenticationMethod Change */
2379{change_wlweptype_guest(o, "WLANConfig11b");
2380}
2381else if (v == "wl_guest_crypto_1")
2382{wl_auth_mode_change_guest(0);
2383}
2384else if (v=="wan_proto")
2385{change_wan_type(o.value);
2386}
2387else if (s == "FirewallConfig" && v=="DmzDevices")
2388{change_wireless_firewall();
2389}
2390else if (s == "FirewallConfig" && v=="WanLanDefaultAct")
2391{if (o.value == "DROP")
2392alert("<#JS_WanLanAlert#>");
2393}
2394else if (s == "FirewallConfig" && v=="LanWanDefaultAct")
2395{if (o.value == "DROP")
2396alert("<#JS_LanWanAlert#>");
2397}
2398else if (s=="WLANConfig11b" && v=="x_Mode11g")
2399{RefreshRateSetList(document.form.WLANConfig11b_x_Mode11g.value, true);
2400}
2401else if (s=="WLANConfig11b" && v=="Channel" && document.form.current_page.value=="Advanced_WMode_Content.asp")
2402{if (document.form.WLANConfig11b_x_APMode.value != "0" && document.form.WLANConfig11b_Channel.value == "0")
2403{alert("<#JS_fixchannel#>");
2404document.form.WLANConfig11b_Channel.options[0].selected = 0;
2405document.form.WLANConfig11b_Channel.options[1].selected = 1;
2406}
2407}
2408else if (v=="ddns_server_x")
2409{change_ddns_setting(o.value);
2410}
2411return true;
2412}
2413function change_common_radio(o, s, v, r)
2414{change = 1;
2415window.top.pageChanged = 1;
2416if (v=='wl_wdsapply_x')
2417{if (window.top.isCard()=='ralink'  || window.top.isModel2()=='WL530' )
2418{change_wireless_bridge2(document.form.wl_mode_x.value,
2419rcheck(document.form.wl_wdsapply_x),
24201, 0);
2421}
2422else{}
2423}
2424else if (v=='wl_lazywds')
2425{}
2426else if (v=="qos_dfragment_enable")
2427{if (r == '1')
2428{inputCtrl(document.form.qos_dfragment_size, 1);
2429}
2430else
2431{inputCtrl(document.form.qos_dfragment_size, 0);
2432}
2433}
2434else if (v=="wan_dnsenable_x")
2435{if (r == '1')
2436{inputCtrl(document.form.wan_dns1_x, 0);
2437inputCtrl(document.form.wan_dns2_x, 0);
2438}
2439else
2440{inputCtrl(document.form.wan_dns1_x, 1);
2441inputCtrl(document.form.wan_dns2_x, 1);
2442}
2443}
2444else if (v=="fw_enable_x")
2445{change_firewall(r);
2446}
2447else if (v=="x_AESEnable")
2448{if (r == '1')
2449{if (document.form.WLANConfig11a_AuthenticationMethod.value!="Open System")
2450{rst = confirm("<#JS_AES2#>");
2451if (rst)
2452document.form.WLANConfig11a_AuthenticationMethod.value = "Open System";
2453else
2454{inputRCtrl2(document.form.WLANConfig11a_x_AESEnable, 1);
2455return false;
2456}
2457}
2458else
2459{if (document.form.WLANConfig11a_WEPType.value == "None")
2460{rst = confirm("<#JS_AES3#>");
2461if (rst)
2462{document.form.WLANConfig11a_WEPType.value = "64bits";
2463change_wlweptype(document.form.WLANConfig11a_WEPType, "WLANConfig11a");
2464}
2465else
2466{inputRCtrl2(document.form.WLANConfig11a_x_AESEnable, 1);
2467return false;
2468}
2469}
2470}
2471}
2472}
2473else if (s=="WLANConfig11b" && v=="wl_gmode")
2474{if (document.form.wl_gmode_check.checked == true)
2475{document.form.wl_gmode_protection_x.value = "1";
2476}
2477else
2478{document.form.wl_gmode_protection_x.value = "0";
2479}
2480}
2481else if (s=="PrinterStatus" && v=="usb_webhttpport_x")
2482{if (document.form.usb_webhttpport_x_check.checked)
2483{document.form.usb_webhttpcheck_x.value = "1";
2484}
2485else
2486{document.form.usb_webhttpcheck_x.value = "0";
2487}
2488}
2489else if (v=="lan_proto_x")
2490{if (r == '1')
2491{inputCtrl(document.form.lan_ipaddr, 0);
2492inputCtrl(document.form.lan_netmask, 0);
2493inputCtrl(document.form.lan_gateway, 0);
2494}
2495else
2496{inputCtrl(document.form.lan_ipaddr, 1);
2497inputCtrl(document.form.lan_netmask, 1);
2498inputCtrl(document.form.lan_gateway, 1);
2499}
2500}
2501else if (s=='FirewallConfig' && v=='DmzEnable')
2502{change_wireless_firewall();
2503}
2504else if (s=="PPPConnection" && v=="wan_pppoe_idletime")
2505{if (document.form.wan_pppoe_idletime_check.checked)
2506{document.form.wan_pppoe_txonly_x.value = "1";
2507}
2508else
2509{document.form.wan_pppoe_txonly_x.value = "0";
2510}
2511}
2512else if (s=="PPPConnection" && v=="x_IdleTime1")
2513{if (document.form.PPPConnection_x_IdleTime1_check.checked)
2514{document.form.PPPConnection_x_IdleTxOnly1.value = "1";
2515}
2516else
2517{document.form.PPPConnection_x_IdleTxOnly1.value = "0";
2518}
2519}
2520else if (s=="PPPConnection" && v=="x_MultiPPPoEEnable1")
2521{if (document.form.PPPConnection_x_MultiPPPoEEnable1[0].checked == true)
2522{flag=1;
2523}
2524else
2525{flag=0;
2526}
2527inputCtrl(document.form.PPPConnection_x_UserName1, flag);
2528inputCtrl(document.form.PPPConnection_x_Password1, flag);
2529inputCtrl(document.form.PPPConnection_x_IdleTime1, flag);
2530inputCtrl(document.form.PPPConnection_x_IdleTime1_check, flag);
2531inputCtrl(document.form.PPPConnection_x_PPPoEMTU1, flag);
2532inputCtrl(document.form.PPPConnection_x_PPPoEMRU1, flag);
2533inputCtrl(document.form.PPPConnection_x_ServiceName1, flag);
2534inputCtrl(document.form.PPPConnection_x_AccessConcentrator1, flag);
2535}
2536else if (s=="PPPConnection" && v=="x_IdleTime2")
2537{if (document.form.PPPConnection_x_IdleTime2_check.checked)
2538{document.form.PPPConnection_x_IdleTxOnly2.value = "1";
2539}
2540else
2541{document.form.PPPConnection_x_IdleTxOnly2.value = "0";
2542}
2543}
2544else if (s=="PPPConnection" && v=="x_MultiPPPoEEnable2")
2545{if (document.form.PPPConnection_x_MultiPPPoEEnable2[0].checked == true)
2546{flag=1;
2547}
2548else
2549{flag=0;
2550}
2551inputCtrl(document.form.PPPConnection_x_UserName2, flag);
2552inputCtrl(document.form.PPPConnection_x_Password2, flag);
2553inputCtrl(document.form.PPPConnection_x_IdleTime2, flag);
2554inputCtrl(document.form.PPPConnection_x_IdleTime2_check, flag);
2555inputCtrl(document.form.PPPConnection_x_PPPoEMTU2, flag);
2556inputCtrl(document.form.PPPConnection_x_PPPoEMRU2, flag);
2557inputCtrl(document.form.PPPConnection_x_ServiceName2, flag);
2558inputCtrl(document.form.PPPConnection_x_AccessConcentrator2, flag);
2559}
2560return true;
2561}
2562function valid_WPAPSK(o)
2563{if (o.value.length>=64)
2564{o.value = o.value.substring(0, 63);
2565alert("<#JS_wpapass#>");
2566return false;
2567}
2568return true;
2569}
2570function encryptionType(authType, wepType)
2571{pflag = "1";
2572if (authType.value == "1")
2573{if (wepType.value == "0") wepLen = "64";
2574else wepLen = "128";
2575}
2576else if (authType.value == "2")
2577{wepLen = "0";
2578}
2579else if (authType.value == "3")
2580{wepLen = "0";
2581pflag = "0";
2582}
2583else if (authType.value == "4")
2584{if (wepType.value == "0") wepLen = "64";
2585else wepLen = "128";
2586}
2587else
2588{if (wepType.value == "0")
2589{wepLen = "0";
2590pflag = "0";
2591}
2592else if (wepType.value == "1") wepLen = "64";
2593else wepLen = "128";
2594}
2595return(pflag + wepLen);
2596}
2597function change_wlweptype(o, s)
2598{if (document.form.wl_auth_mode.value!="psk") {
2599change = 1;
2600window.top.pageChanged = 1;
2601}
2602document.form.wl_phrase_x.value = "";
2603if (o.value=="0")
2604{wflag = 0;
2605wep = "";
2606document.form.wl_key1.value = wep;
2607document.form.wl_key2.value = wep;
2608document.form.wl_key3.value = wep;
2609document.form.wl_key4.value = wep;
2610}
2611else
2612{wflag = 1;
2613if (o.value=="1")
2614{wep = "0000000000";
2615}
2616else  if (o.value=="2")
2617{wep = "00000000000000000000000000";
2618}
2619else
2620{wep = "00000000000000000000000000000000";
2621}
2622is_wlphrase("WLANConfig11b", "wl_phrase_x", document.form.wl_phrase_x);
2623}
2624inputCtrl(document.form.wl_phrase_x,  wflag);
2625inputCtrl(document.form.wl_key1,  wflag);
2626inputCtrl(document.form.wl_key2,  wflag);
2627inputCtrl(document.form.wl_key3,  wflag);
2628inputCtrl(document.form.wl_key4,  wflag);
2629inputCtrl(document.form.wl_key,  wflag);
2630wl_wep_change();
2631if (wflag=="1")
2632{document.form.wl_phrase_x.focus();
2633}
2634return true;
2635}
2636function change_widzard(o, id)
2637{if (document.form.current_page.value == "Advanced_PortTrigger_Content.asp")
2638{for (i = 0; i < wItem.length; i++)
2639{if (wItem[i][0]!=null)
2640{if (o.value == wItem[i][0])
2641{optIdx = i;
2642document.form.autofw_outport_x_0.value = wItem[optIdx][1];
2643document.form.autofw_outproto_x_0.value = wItem[optIdx][2];
2644document.form.autofw_inport_x_0.value = wItem[optIdx][3];
2645document.form.autofw_inproto_x_0.value = wItem[optIdx][4];
2646document.form.autofw_desc_x_0.value = wItem[optIdx][0];
2647}
2648}
2649}
2650}
2651else if (document.form.current_page.value == "Advanced_VirtualServer_Content.asp")
2652{for (i = 0; i < wItem.length; i++)
2653{if (wItem[i][0]!=null)
2654{if (o.value == wItem[i][0])
2655{optIdx = i;
2656if (wItem[optIdx][2]=="TCP")
2657document.form.vts_proto_x_0.options[0].selected = 1;
2658else if (wItem[optIdx][2]=="UDP")
2659document.form.vts_proto_x_0.options[1].selected = 1;
2660else
2661document.form.vts_proto_x_0.options[2].selected = 1;
2662document.form.vts_ipaddr_x_0.value = ip;
2663document.form.vts_port_x_0.value = wItem[optIdx][1];
2664document.form.vts_desc_x_0.value = wItem[optIdx][0] + " Server (" + wItem[optIdx][1] + ")";
2665}
2666}
2667}
2668}
2669else if (document.form.current_page.value == "Advanced_Firewall_Content.asp")
2670{for (i = 0; i < wItem.length; i++)
2671{if (wItem[i][0]!=null)
2672{if (o.value == wItem[i][0])
2673{optIdx = i;
2674if ( id == "WLKnownApps")
2675{if (wItem[optIdx][2]=="TCP")
2676document.form.filter_wl_proto_x_0.options[0].selected = 1;
2677else if (wItem[optIdx][2]=="UDP")
2678document.form.filter_wl_proto_x_0.options[8].selected = 1;
2679document.form.filter_wl_srcport_x_0.value = wItem[optIdx][1];
2680}
2681else
2682{if (wItem[optIdx][2]=="TCP")
2683document.form.filter_lw_proto_x_0.options[0].selected = 1;
2684else if (wItem[optIdx][2]=="UDP")
2685document.form.filter_lw_proto_x_0.options[8].selected = 1;
2686document.form.filter_lw_dstport_x_0.value = wItem[optIdx][1];
2687}
2688}
2689}
2690}
2691}
2692}
2693function is_wlkey(o, s)
2694{if (!nav) keyPressed = IEKey();
2695else keyPressed = NSKey();
2696if (keyPressed == 0) return true;
2697window.top.pageChanged = 1;
2698if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp")
2699wep = document.form.wl_guest_wep_x_1.value;
2700else wep = document.form.wl_wep_x.value;
2701if ((keyPressed>47 && keyPressed<58)||(keyPressed>64 && keyPressed<71)||(keyPressed>96 && keyPressed<103))
2702{if (wep == "1")
2703{if(o.value != "" && o.value.length > 10) return false;
2704}
2705else if (wep == "2")
2706{if(o.value != "" && o.value.length > 26) return false;
2707}
2708else return false;
2709}
2710else return false;
2711return true;
2712}
2713function change_wlkey(o, s)
2714{if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp")
2715wep = document.form.wl_guest_wep_x_1.value;
2716else wep = document.form.wl_wep_x.value;
2717if (wep == "1")
2718{if(o.value.length > 10) o.value = o.value.substring(0, 10);
2719}
2720else if (wep == "2")
2721{if(o.value.length > 26) o.value = o.value.substring(0, 26);
2722}
2723else return false;
2724}
2725function validate_timerange(o, p)
2726{if (o.value.length==0) o.value = "00";
2727else if (o.value.length==1) o.value = "0" + o.value;
2728if (o.value.charAt(0)<'0' || o.value.charAt(0)>'9') o.value = "00";
2729else if (o.value.charAt(1)<'0' || o.value.charAt(1)>'9') o.value = "00";
2730else if (p==0 || p==2)
2731{if(o.value>23) o.value = "00";
2732}
2733else
2734{if(o.value>59) o.value = "00";
2735}
2736return true;
2737}
2738function validate_wlkey(o, s)
2739{if (document.form.current_page.value == "Advanced_WirelessGuest_Content.asp")
2740wep = document.form.wl_guest_wep_x_1.value;
2741else wep = document.form.wl_wep_x.value;
2742if (wep == "1")
2743{if(o.value.length == 10) return;
2744o.value = "0000000000";
2745}
2746else if (wep == "2")
2747{if(o.value.length == 26) return;
2748o.value = "00000000000000000000000000";
2749}
2750else return;
2751alert('<#JS_wepkey#>');
2752return false;
2753}
2754/* Factory Reset Warning */
2755function confirmRestore(){
2756if(confirm('<#JS_RESET#>')) {
2757/* top.location.href="apply.cgi";*/
2758return true;
2759}
2760else
2761{top.location.href = "Advanced_Content.html";
2762return false;
2763}
2764}
2765function validate_wlphrase(s, v, o)
2766{if (v == "wl_wpa_psk")
2767{if (document.form.wl_auth_mode.value == "psk")
2768{if (o.value.length < 8)
2769{alert("<#JS_passzero#>");
2770document.form.wl_wpa_psk.value = "00000000";
2771return false;
2772}
2773}
2774}
2775else
2776{if (!validate_string(o))
2777{is_wlphrase(s, v, o);
2778return(false);
2779}
2780}
2781return true;
2782}
2783function add_portmapping()
2784{widzard = window.open("Advanced_PortForwarding_Widzard.asp", "PortForwarding_Widzard",
2785"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
2786if (!widzard.opener) widzard.opener = self;
2787}
2788function add_vsmapping()
2789{widzard = window.open("Advanced_VirtualServer_Widzard.asp", "VirtualServer_Widzard",
2790"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
2791if (!widzard.opener) widzard.opener = self;
2792}
2793function openHelp(o, name)
2794{urlstr = "Advanced_" + name + "_Widzard.asp"
2795widzard = window.open(urlstr, "Help_Widzard",
2796"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=500");
2797if (!widzard.opener) widzard.opener = self;
2798}
2799function matchSubnet(ip1, ip2, count)
2800{var c = 0;
2801var v1 = 0;
2802var v2 = 0;
2803for(i=0;i<ip1.length;i++)
2804{if (ip1.charAt(i) == '.')
2805{if (ip2.charAt(i) != '.')
2806return false;
2807c++;
2808if (v1!=v2) return false;
2809v1 = 0;
2810v2 = 0;
2811}
2812else
2813{if (ip2.charAt(i)=='.') return false;
2814v1 = v1*10 + (ip1.charAt(i) - '0');
2815v2 = v2*10 + (ip2.charAt(i) - '0');
2816}
2817if (c==count) return true;
2818}
2819return false;
2820}
2821function subnetPrefix(ip, orig, count)
2822{r='';
2823c=0;
2824for(i=0;i<ip.length;i++)
2825{if (ip.charAt(i) == '.')
2826c++;
2827if (c==count) break;
2828r = r + ip.charAt(i);
2829}
2830c=0;
2831for(i=0;i<orig.length;i++)
2832{if (orig.charAt(i) == '.')
2833{c++;
2834}
2835if (c>=count)
2836r = r + orig.charAt(i);
2837}
2838return (r);
2839}
2840function checkSubnet()
2841{/* Rule : If addresses in pool are match to subnet, don't change */
2842/* Rule : If addresses in pool are not match to subnet, change to subnet.2~subnet.254 */
2843if (!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_start.value, 3) ||
2844!matchSubnet(document.form.lan_ipaddr.value, document.form.dhcp_end.value, 3))
2845{if (confirm("<#JS_DHCP1#>"))
2846{document.form.dhcp_start.value = subnetPrefix(document.form.lan_ipaddr.value, document.form.dhcp_start.value, 3);
2847document.form.dhcp_end.value = subnetPrefix(document.form.lan_ipaddr.value, document.form.dhcp_end.value, 3);
2848}
2849}
2850}
2851function checkDmzSubnet()
2852{/* Rule : If addresses in pool are match to subnet, don't change */
2853/* Rule : If addresses in pool are not match to subnet, change to subnet.2~subnet.254 */
2854if (!matchSubnet(document.form.FirewallConfig_DmzIP.value, document.form.LANHostConfig_DmzMinAddress.value, 3) ||
2855!matchSubnet(document.form.FirewallConfig_DmzIP.value, document.form.LANHostConfig_DmzMaxAddress.value, 3))
2856{if (confirm("<#JS_DHCP2#>"))
2857{document.form.LANHostConfig_DmzMinAddress.value = subnetPrefix(document.form.FirewallConfig_DmzIP.value, document.form.LANHostConfig_DmzMinAddress.value, 3);
2858document.form.LANHostConfig_DmzMaxAddress.value = subnetPrefix(document.form.FirewallConfig_DmzIP.value, document.form.LANHostConfig_DmzMaxAddress.value, 3);
2859}
2860}
2861}
2862function checkSubnetGuest()
2863{/* Rule : If addresses in pool are match to subnet, don't change */
2864/* Rule : If addresses in pool are not match to subnet, change to subnet.2~subnet.254 */
2865if (!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_start.value, 3) ||
2866!matchSubnet(document.form.lan1_ipaddr.value, document.form.dhcp1_end.value, 3))
2867{if (confirm("<#JS_DHCP1#>"))
2868{document.form.dhcp1_start.value = subnetPrefix(document.form.lan1_ipaddr.value, document.form.dhcp1_start.value, 3);
2869document.form.dhcp1_end.value = subnetPrefix(document.form.lan1_ipaddr.value, document.form.dhcp1_end.value, 3);
2870}
2871}
2872}
2873function wan_netmask_check(o) {
2874ip =intoa(document.form.wan_ipaddr.value);
2875gw =intoa(document.form.wan_gateway.value);
2876nm =intoa(document.form.wan_netmask.value);
2877lip=intoa(document.form.lan_ipaddr.value);
2878lnm=intoa(document.form.lan_netmask.value);
2879rem=1;
2880if (ip==0x0 || (ip&lnm)==(lip&lnm))
2881{alert(o.value + ' <#JS_validip#>');
2882document.form.wan_ipaddr.value="1.1.1.1";
2883document.form.wan_netmask.value="255.0.0.0";
2884o.focus();
2885return false;
2886}
2887if (gw==0 || gw==0xffffffff || (ip&nm)==(gw&nm))
2888{return true;
2889}
2890else
2891{alert(o.value + ' <#JS_validip#>');
2892o.focus();
2893return false;
2894}
2895}
2896function updateDateTime(s)
2897{if (s == "Advanced_Firewall_Content.asp")
2898{/*if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
2899{document.form.filter_wl_date_x.value = setDateCheck(
2900document.form.filter_wl_date_x_Sun,
2901document.form.filter_wl_date_x_Mon,
2902document.form.filter_wl_date_x_Tue,
2903document.form.filter_wl_date_x_Wed,
2904document.form.filter_wl_date_x_Thu,
2905document.form.filter_wl_date_x_Fri,
2906document.form.filter_wl_date_x_Sat);
2907document.form.filter_wl_time_x.value = setTimeRange(
2908document.form.filter_wl_time_x_starthour,
2909document.form.filter_wl_time_x_startmin,
2910document.form.filter_wl_time_x_endhour,
2911document.form.filter_wl_time_x_endmin);
2912}
2913*/
2914document.form.filter_lw_date_x.value = setDateCheck(
2915document.form.filter_lw_date_x_Sun,
2916document.form.filter_lw_date_x_Mon,
2917document.form.filter_lw_date_x_Tue,
2918document.form.filter_lw_date_x_Wed,
2919document.form.filter_lw_date_x_Thu,
2920document.form.filter_lw_date_x_Fri,
2921document.form.filter_lw_date_x_Sat);
2922document.form.filter_lw_time_x.value = setTimeRange(
2923document.form.filter_lw_time_x_starthour,
2924document.form.filter_lw_time_x_startmin,
2925document.form.filter_lw_time_x_endhour,
2926document.form.filter_lw_time_x_endmin);
2927}
2928else if (s == "Advanced_LFirewall_Content.asp")
2929{document.form.FirewallConfig_WanLocalActiveDate.value = setDateCheck(
2930document.form.FirewallConfig_WanLocalActiveDate_Sun,
2931document.form.FirewallConfig_WanLocalActiveDate_Mon,
2932document.form.FirewallConfig_WanLocalActiveDate_Tue,
2933document.form.FirewallConfig_WanLocalActiveDate_Wed,
2934document.form.FirewallConfig_WanLocalActiveDate_Thu,
2935document.form.FirewallConfig_WanLocalActiveDate_Fri,
2936document.form.FirewallConfig_WanLocalActiveDate_Sat);
2937document.form.FirewallConfig_WanLocalActiveTime.value = setTimeRange(
2938document.form.FirewallConfig_WanLocalActiveTime_starthour,
2939document.form.FirewallConfig_WanLocalActiveTime_startmin,
2940document.form.FirewallConfig_WanLocalActiveTime_endhour,
2941document.form.FirewallConfig_WanLocalActiveTime_endmin);
2942}
2943else if (s == "Advanced_URLFilter_Content.asp")
2944{document.form.url_date_x.value = setDateCheck(
2945document.form.url_date_x_Sun,
2946document.form.url_date_x_Mon,
2947document.form.url_date_x_Tue,
2948document.form.url_date_x_Wed,
2949document.form.url_date_x_Thu,
2950document.form.url_date_x_Fri,
2951document.form.url_date_x_Sat);
2952document.form.url_time_x.value = setTimeRange(
2953document.form.url_time_x_starthour,
2954document.form.url_time_x_startmin,
2955document.form.url_time_x_endhour,
2956document.form.url_time_x_endmin);
2957}
2958else if (s == "Advanced_WebCam_Content.asp")
2959{document.form.usb_websecurity_date_x.value = setDateCheck(
2960document.form.usb_websecurity_date_x_Sun,
2961document.form.usb_websecurity_date_x_Mon,
2962document.form.usb_websecurity_date_x_Tue,
2963document.form.usb_websecurity_date_x_Wed,
2964document.form.usb_websecurity_date_x_Thu,
2965document.form.usb_websecurity_date_x_Fri,
2966document.form.usb_websecurity_date_x_Sat);
2967document.form.usb_websecurity_time_x.value = setTimeRange(
2968document.form.usb_websecurity_time_x_starthour,
2969document.form.usb_websecurity_time_x_startmin,
2970document.form.usb_websecurity_time_x_endhour,
2971document.form.usb_websecurity_time_x_endmin);
2972}
2973else if (s == "Advanced_WAdvanced_Content.asp" && window.top.isModel()!="WL300" && window.top.isModel()!="WL331")
2974{if (window.top.isModel()!="WL520gc" && window.top.isModel()!="SnapAP")
2975{document.form.wl_radio_date_x.value = setDateCheck(
2976document.form.wl_radio_date_x_Sun,
2977document.form.wl_radio_date_x_Mon,
2978document.form.wl_radio_date_x_Tue,
2979document.form.wl_radio_date_x_Wed,
2980document.form.wl_radio_date_x_Thu,
2981document.form.wl_radio_date_x_Fri,
2982document.form.wl_radio_date_x_Sat);
2983document.form.wl_radio_time_x.value = setTimeRange(
2984document.form.wl_radio_time_x_starthour,
2985document.form.wl_radio_time_x_startmin,
2986document.form.wl_radio_time_x_endhour,
2987document.form.wl_radio_time_x_endmin);
2988}
2989}
2990}
2991function startMenu(s)
2992{if (s=='Quick')
2993{document.form.action_mode.value = "Next";
2994document.form.submit();
2995}
2996else
2997{widzard = window.open("Advanced_PrinterSetup_Widzard.asp", "Printer Setup Widzard",
2998"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
2999if (!widzard.opener) widzard.opener = self;
3000}
3001}
3002function openWidzard(u, t)
3003{url = '"' + u + '"';
3004title = '"' + t + '"';
3005widzard = window.open(u, "Widzard",
3006"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=400");
3007if (!widzard.opener) widzard.opener = self;
3008}
3009function openWidzardNone(u, t)
3010{}
3011function openLink(s)
3012{if (s=='x_DDNSServer')
3013{if (document.form.ddns_server_x.value.indexOf("WWW.DYNDNS.ORG")!=-1)
3014tourl = "https://www.dyndns.org/account/create.html"
3015else if (document.form.ddns_server_x.value == 'WWW.ZONEEDIT.COM')
3016tourl = "https://www.zoneedit.com/signup.html"
3017else if (document.form.ddns_server_x.value == 'WWW.ASUS.COM')
3018tourl = "";
3019else
3020tourl = "https://controlpanel.tzo.com/cgi-bin/tzopanel.exe"
3021link = window.open(tourl, "DDNSLink",
3022"toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=480");
3023}
3024else if (s=='x_NTPServer1')
3025{tourl = "http://ntp.isc.org/bin/view/Servers/WebHome"
3026link = window.open(tourl, "NTPLink",
3027"toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=480");
3028}
3029else if (s=='x_WImageSize')
3030{tourl = "Advanced_ShowTime_Widzard.asp"
3031link = window.open(tourl, "WebCamera",
3032"toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=560");
3033}
3034else if (s=='x_WImageStatic')
3035{tourl = "ShowWebCamPic.asp"
3036link = window.open(tourl, "WebCamera",
3037"toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=560");
3038}
3039else if (s=='x_WRemote')
3040{tourl = "Advanced_RemoteControl_Widzard.asp"
3041link = window.open(tourl, "RemoteMonitor",
3042"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=0,left=0,width=" + screen.width + ",height=" + screen.height);
3043}
3044else if (s=='x_FIsAnonymous' || s=='x_FIsSuperuser')
3045{urlstr = location.href;
3046url = urlstr.indexOf("http://");
3047port = document.form.usb_ftpport_x.value;
3048if (url == -1) urlpref = LANIP;
3049else
3050{urlstr = urlstr.substring(7, urlstr.length);
3051url = urlstr.indexOf(":");
3052if (url!=-1)
3053{urlpref = urlstr.substring(0, url);
3054}
3055else
3056{url = urlstr.indexOf("/");
3057if (url!=-1) urlpref = urlstr.substring(0, url);
3058else urlpref = urlstr;
3059}
3060}
3061if (s=='x_FIsAnonymous')
3062{user = 'anonymous';
3063tourl = "ftp://" + urlpref;
3064}
3065else
3066{user = 'admin';
3067tourl = "ftp://" + user + "@" + urlpref;
3068}
3069if (port!=21) tourl = tourl + ":" + port;
3070link = window.open(tourl, "FTPServer",
3071"toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=640,height=560");
3072}
3073if (!link.opener) link.opener = self;
3074}
3075function blur_body()
3076{alert('<#JS_focus#>');
3077}
3078/* Used when WEP is changed */
3079function changeWEPType()
3080{if (document.form.wl_wep.value == "0")
3081{flag = 0;
3082}
3083else
3084{flag = 1;
3085}
3086inputCtrl(document.form.wl_phrase_x,  flag);
3087inputCtrl(document.form.wl_key1, flag);
3088inputCtrl(document.form.wl_key2, flag);
3089inputCtrl(document.form.wl_key3, flag);
3090inputCtrl(document.form.wl_key4, flag);
3091inputCtrl(document.form.wl_key,  flag);
3092}
3093/* Used when Authenication Method is changed */
3094function changeAuthType()
3095{if (document.form.wl_auth_mode.value == "shared")
3096{inputCtrl(document.form.wl_crypto,  0);
3097inputCtrl(document.form.wl_wpa_psk,  0);
3098inputCtrl(document.form.wl_wep,  1);
3099inputCtrl(document.form.wl_phrase_x,  1);
3100inputCtrl(document.form.wl_key1, 1);
3101inputCtrl(document.form.wl_key2, 1);
3102inputCtrl(document.form.wl_key3, 1);
3103inputCtrl(document.form.wl_key4, 1);
3104inputCtrl(document.form.wl_key,  1);
3105inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3106}
3107else if (document.form.wl_auth_mode.value == "psk")
3108{inputCtrl(document.form.wl_crypto,  1);
3109inputCtrl(document.form.wl_wpa_psk,  1);
3110inputCtrl(document.form.wl_wep,  1);
3111inputCtrl(document.form.wl_phrase_x,  1);
3112inputCtrl(document.form.wl_key1, 1);
3113inputCtrl(document.form.wl_key2, 1);
3114inputCtrl(document.form.wl_key3, 1);
3115inputCtrl(document.form.wl_key4, 1);
3116inputCtrl(document.form.wl_key,  1);
3117inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3118}
3119else if (document.form.wl_auth_mode.value == "wpa")
3120{inputCtrl(document.form.wl_crypto,  0);
3121inputCtrl(document.form.wl_wpa_psk,  0);
3122inputCtrl(document.form.wl_wep,  0);
3123inputCtrl(document.form.wl_phrase_x,  0);
3124inputCtrl(document.form.wl_key1, 0);
3125inputCtrl(document.form.wl_key2, 0);
3126inputCtrl(document.form.wl_key3, 0);
3127inputCtrl(document.form.wl_key4, 0);
3128inputCtrl(document.form.wl_key,  0);
3129inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3130}
3131else if (document.form.wl_auth_mode.value == "radius")
3132{inputCtrl(document.form.wl_crypto,  1);
3133inputCtrl(document.form.wl_wpa_psk,  1);
3134inputCtrl(document.form.wl_wep,  1);
3135inputCtrl(document.form.wl_phrase_x,  1);
3136inputCtrl(document.form.wl_key1, 1);
3137inputCtrl(document.form.wl_key2, 1);
3138inputCtrl(document.form.wl_key3, 1);
3139inputCtrl(document.form.wl_key4, 1);
3140inputCtrl(document.form.wl_key,  1);
3141inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3142}
3143else
3144{inputCtrl(document.form.wl_crypto,  0);
3145inputCtrl(document.form.wl_wpa_psk,  0);
3146inputCtrl(document.form.wl_wep,  1);
3147inputCtrl(document.form.wl_phrase_x, 1);
3148inputCtrl(document.form.wl_key1, 1);
3149inputCtrl(document.form.wl_key1, 1);
3150inputCtrl(document.form.wl_key1, 1);
3151inputCtrl(document.form.wl_key1, 1);
3152inputCtrl(document.form.wl_key1, 1);
3153inputCtrl(document.form.wl_key,  1);
3154inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3155}
3156}
3157/* input : s: service id, v: value name, o: current value */
3158/* output: wep key1~4       */
3159function is_wlphrase(s, v, o)
3160{var pseed = new Array;
3161var wep_key = new Array(5);
3162window.top.pageChanged = 1;
3163if (v=='wl_wpa_psk') return(valid_WPAPSK(o));
3164if (document.form.current_page.value != "Advanced_WirelessGuest_Content.asp")
3165{wepType = document.form.wl_wep_x.value;
3166wepKey1 = document.form.wl_key1;
3167wepKey2 = document.form.wl_key2;
3168wepKey3 = document.form.wl_key3;
3169wepKey4 = document.form.wl_key4;
3170}
3171else
3172{wepType = document.form.wl_guest_wep_x_1.value;
3173wepKey1 = document.form.wl_guest_key1_1;
3174wepKey2 = document.form.wl_guest_key2_1;
3175wepKey3 = document.form.wl_guest_key3_1;
3176wepKey4 = document.form.wl_guest_key4_1;
3177}
3178phrase = o.value;
3179if(wepType == "1")
3180{for (i=0; i<phrase.length; i++)
3181{pseed[i%4] ^= phrase.charCodeAt(i);
3182}
3183randNumber = pseed[0] | (pseed[1]<<8) | (pseed[2]<<16) | (pseed[3]<<24);
3184for (j=0; j<5; j++)
3185{randNumber = ((randNumber * 0x343fd) % 0x1000000);
3186randNumber = ((randNumber + 0x269ec3) % 0x1000000);
3187wep_key[j] = ((randNumber>>16) & 0xff);
3188}
3189wepKey1.value = binl2hex_c(wep_key);
3190for (j=0; j<5; j++)
3191{randNumber = ((randNumber * 0x343fd) % 0x1000000);
3192randNumber = ((randNumber + 0x269ec3) % 0x1000000);
3193wep_key[j] = ((randNumber>>16) & 0xff);
3194}
3195wepKey2.value = binl2hex_c(wep_key);
3196for (j=0; j<5; j++)
3197{randNumber = ((randNumber * 0x343fd) % 0x1000000);
3198randNumber = ((randNumber + 0x269ec3) % 0x1000000);
3199wep_key[j] = ((randNumber>>16) & 0xff);
3200}
3201wepKey3.value = binl2hex_c(wep_key);
3202for (j=0; j<5; j++)
3203{randNumber = ((randNumber * 0x343fd) % 0x1000000);
3204randNumber = ((randNumber + 0x269ec3) % 0x1000000);
3205wep_key[j] = ((randNumber>>16) & 0xff);
3206}
3207wepKey4.value = binl2hex_c(wep_key);
3208}
3209else if (wepType == "2" || wepType == "3")
3210{password = "";
3211if (phrase.length>0)
3212{for (i=0; i<64; i++)
3213{ch = phrase.charAt(i%phrase.length);
3214password = password + ch;
3215}
3216}
3217password = calcMD5(password);
3218if (wepType == "2")
3219{wepKey1.value = password.substr(0, 26);
3220}
3221else
3222{wepKey1.value = password.substr(0, 32);
3223}
3224wepKey2.value = wepKey1.value;
3225wepKey3.value = wepKey1.value;
3226wepKey4.value = wepKey1.value;
3227}
3228return true;
3229}
3230function wl_wep_change() {
3231var mode = document.form.wl_auth_mode.value;
3232var wep = document.form.wl_wep_x.value;
3233if (mode == "wpa" || mode == "psk" || mode == "wpa2") {
3234if (mode != "wpa" && mode != "wpa2")
3235inputCtrl(document.form.wl_crypto,  1);
3236if (mode != "wpa" && mode != "wpa2")
3237inputCtrl(document.form.wl_wpa_psk,  1);
3238inputCtrl(document.form.wl_wpa_gtk_rekey,  1);
3239inputCtrl(document.form.wl_wep_x,  0);
3240inputCtrl(document.form.wl_phrase_x,  0);
3241inputCtrl(document.form.wl_key1, 0);
3242inputCtrl(document.form.wl_key2, 0);
3243inputCtrl(document.form.wl_key3, 0);
3244inputCtrl(document.form.wl_key4, 0);
3245inputCtrl(document.form.wl_key,  0);
3246}
3247else {
3248inputCtrl(document.form.wl_crypto,  0);
3249inputCtrl(document.form.wl_wpa_psk,  0);
3250inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3251inputCtrl(document.form.wl_wep_x,  1);
3252if (wep != "0") {
3253inputCtrl(document.form.wl_phrase_x,  1);
3254inputCtrl(document.form.wl_key1,  1);
3255inputCtrl(document.form.wl_key2,  1);
3256inputCtrl(document.form.wl_key3,  1);
3257inputCtrl(document.form.wl_key4,  1);
3258inputCtrl(document.form.wl_key,   1);
3259}
3260else {
3261inputCtrl(document.form.wl_phrase_x,  0);
3262inputCtrl(document.form.wl_key1,  0);
3263inputCtrl(document.form.wl_key2,  0);
3264inputCtrl(document.form.wl_key3,  0);
3265inputCtrl(document.form.wl_key4,  0);
3266inputCtrl(document.form.wl_key,   0);
3267}
3268}
3269/*
3270if (wep != "0") {
3271if (mode == "wpa" || mode == "wpa2" || mode == "psk" || mode == "radius") {
3272inputCtrl(document.form.wl_key1,  0);
3273inputCtrl(document.form.wl_key4,  0);
3274}
3275else {
3276inputCtrl(document.form.wl_key1,  1);
3277inputCtrl(document.form.wl_key4,  1);
3278}
3279inputCtrl(document.form.wl_key2,  1);
3280inputCtrl(document.form.wl_key3,  1);
3281} else {
3282inputCtrl(document.form.wl_phrase_x,  0);
3283inputCtrl(document.form.wl_key1,  0);
3284inputCtrl(document.form.wl_key2,  0);
3285inputCtrl(document.form.wl_key3,  0);
3286inputCtrl(document.form.wl_key4,  0);
3287}
3288*
3289/*if (wep != "0")
3290inputCtrl(document.form.wl_key,  1);
3291else
3292inputCtrl(document.form.wl_key,  0);
3293*
3294/*if (wep != "0")
3295inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3296else {
3297if (mode == "wpa" || mode == "wpa2" || mode == "psk")
3298inputCtrl(document.form.wl_wpa_gtk_rekey,  1);
3299else
3300inputCtrl(document.form.wl_wpa_gtk_rekey,  0);
3301}
3302}
3303*/
3304}
3305function change_wep_type(mode)
3306{orig = document.form.wl_wep_x.value;
3307free_options(document.form.wl_wep_x);
3308if (mode == "shared" || mode == "radius") {
3309vitems = new Array("1", "2");
3310items = new Array("WEP-64bits", "WEP-128bits");
3311}
3312else {
3313vitems = new Array("0", "1", "2");
3314items = new Array("None", "WEP-64bits", "WEP-128bits");
3315}
3316add_options_x2(document.form.wl_wep_x, vitems, items, orig);
3317if ((mode == "shared" || mode == "radius") && orig == "0") {
3318change_wlweptype(document.form.wl_wep_x, "WLANConfig11b");
3319}
3320else if (mode == "psk") {
3321document.form.wl_wep_x.value="0";
3322change_wlweptype(document.form.wl_wep_x, "WLANConfig11b");
3323}
3324}
3325function wl_auth_mode_reconf()
3326{if (document.form.wl_auth_mode.value=="radius" ||
3327document.form.wl_auth_mode.value=="wpa")
3328document.form.wl_auth_mode.value="open";
3329document.form.wl_auth_mode.options[3].value = null;
3330document.form.wl_auth_mode.options[3] = null;
3331document.form.wl_auth_mode.options[3].value = null;
3332document.form.wl_auth_mode.options[3] = null;
3333}
3334function wl_auth_mode_change(isload)
3335{var mode = document.form.wl_auth_mode.value;
3336var i, cur, algos;
3337inputCtrl(document.form.wl_wep_x,  1);
3338/* enable/disable crypto algorithm */
3339if (mode == "wpa" || mode == "wpa2" || mode == "psk")
3340inputCtrl(document.form.wl_crypto,  1);
3341else
3342inputCtrl(document.form.wl_crypto,  0);
3343/* enable/disable psk passphrase */
3344if (mode == "psk")
3345inputCtrl(document.form.wl_wpa_psk,  1);
3346else
3347inputCtrl(document.form.wl_wpa_psk,  0);
3348/* update wl_crypto */
3349if (mode == "psk") {
3350/* Save current crypto algorithm */
3351for (i = 0; i < document.form.wl_crypto.length; i++) {
3352if (document.form.wl_crypto[i].selected) {
3353cur = document.form.wl_crypto[i].value;
3354break;
3355}
3356}
3357if (window.top.isModel()=="SnapAP" || window.top.isBand() == 'b' )
3358algos = new Array("TKIP");
3359else
3360{opts=document.form.wl_auth_mode.options;
3361if (opts[opts.selectedIndex].text == "WPA-Auto-Personal")
3362algos = new Array("TKIP", "AES", "TKIP+AES");
3363else
3364algos = new Array("TKIP+AES");
3365}
3366/* Reconstruct algorithm array from new crypto algorithms */
3367document.form.wl_crypto.length = algos.length;
3368for (var i in algos) {
3369document.form.wl_crypto[i] = new Option(algos[i], algos[i].toLowerCase());
3370document.form.wl_crypto[i].value = algos[i].toLowerCase();
3371if (algos[i].toLowerCase() == cur)
3372document.form.wl_crypto[i].selected = true;
3373}
3374}
3375else if(mode == "wpa") {
3376for (i = 0; i < document.form.wl_crypto.length; i++) {
3377if (document.form.wl_crypto[i].selected) {
3378cur = document.form.wl_crypto[i].value;
3379break;
3380}
3381}
3382opts=document.form.wl_auth_mode.options;
3383if (opts[opts.selectedIndex].text == "WPA-Auto-Enterprise")
3384algos = new Array("TKIP", "AES", "TKIP+AES");
3385else
3386algos = new Array("TKIP");
3387document.form.wl_crypto.length = algos.length;
3388for (var i in algos) {
3389document.form.wl_crypto[i] = new Option(algos[i], algos[i].toLowerCase());
3390document.form.wl_crypto[i].value = algos[i].toLowerCase();
3391if (algos[i].toLowerCase() == cur)
3392document.form.wl_crypto[i].selected = true;
3393}
3394}
3395else if(mode == "wpa2") {
3396algos = new Array("AES");
3397document.form.wl_crypto.length = algos.length;
3398document.form.wl_crypto[0] = new Option(algos[0], algos[0].toLowerCase());
3399}
3400change_wep_type(mode);
3401/* Save current network key index */
3402for (i = 0; i < document.form.wl_key.length; i++) {
3403if (document.form.wl_key[i].selected) {
3404cur = document.form.wl_key[i].value;
3405break;
3406}
3407}
3408/* Define new network key indices */
3409if (mode == "wpa" || mode == "wpa2" || mode == "psk" || mode == "radius")
3410algos = new Array("2", "3");
3411else {
3412algos = new Array("1", "2", "3", "4");
3413if (!isload) cur = "1";
3414}
3415/* Reconstruct network key indices array from new network key indices */
3416document.form.wl_key.length = algos.length;
3417for (var i in algos) {
3418document.form.wl_key[i] = new Option(algos[i], algos[i]);
3419document.form.wl_key[i].value = algos[i];
3420if (algos[i] == cur)
3421document.form.wl_key[i].selected = true;
3422}
3423wl_wep_change();
3424if ((mode == "wpa" || mode == "wpa2" || mode == "psk")) {
3425if(mode == "psk") {
3426document.form.wl_wep_x.value = 0;
3427inputCtrl(document.form.wl_wep_x,  0);
3428inputCtrl(document.form.wl_phrase_x,  0);
3429inputCtrl(document.form.wl_key1, 0);
3430inputCtrl(document.form.wl_key2, 0);
3431inputCtrl(document.form.wl_key3, 0);
3432inputCtrl(document.form.wl_key4, 0);
3433inputCtrl(document.form.wl_key,  0);
3434}
3435}
3436}
3437function wl_rate_change()
3438{orig = document.form.wl_rate.value;
3439free_options(document.form.wl_rate);
3440if (document.form.wl_gmode.value == "1")
3441{vitems = new Array("0", "1000000", "2000000", "5500000", "6000000", "9000000", "11000000", "12000000", "18000000", "24000000", "36000000", "48000000", "54000000");
3442items = new Array("Auto", "1", "2", "5.5", "6", "9", "11", "12", "18", "24", "36", "48", "54");
3443}
3444else if (document.form.wl_gmode.value == "4")
3445{vitems = new Array("0", "6000000", "9000000", "12000000", "18000000", "24000000", "36000000", "48000000", "54000000");
3446items = new Array("Auto", "6", "9", "12", "18", "24", "36", "48", "54");
3447}
3448else
3449{vitems = new Array("0", "1000000", "2000000", "5500000", "11000000");
3450items = new Array("Auto", "1", "2", "5.5", "11");
3451}
3452add_options_x2(document.form.wl_rate, vitems, items, orig);
3453}
3454function change_wan_type(v)
3455{if (v == "static")
3456{inputCtrl(document.form.wan_ipaddr, 1);
3457inputCtrl(document.form.wan_netmask, 1);
3458inputCtrl(document.form.wan_gateway, 1);
3459inputCtrl(document.form.wan_pppoe_username, 0);
3460inputCtrl(document.form.wan_pppoe_passwd, 0);
3461inputCtrl(document.form.wan_pppoe_idletime, 0);
3462inputCtrl(document.form.wan_pppoe_mtu, 0);
3463inputCtrl(document.form.wan_pppoe_mru, 0);
3464if(window.top.isModel3()!='WL550gE')
3465inputRCtrl1(document.form.wan_pppoe_relay_x, 1);
3466inputCtrl(document.form.wan_pppoe_idletime_check, 0);
3467inputCtrl(document.form.wan_pppoe_service, 0);
3468inputCtrl(document.form.wan_pppoe_ac, 0);
3469}
3470else if(v == "pppoe")
3471{inputCtrl(document.form.wan_ipaddr, 0);
3472inputCtrl(document.form.wan_netmask, 0);
3473inputCtrl(document.form.wan_gateway, 0);
3474inputCtrl(document.form.wan_pppoe_username, 1);
3475inputCtrl(document.form.wan_pppoe_passwd, 1);
3476inputCtrl(document.form.wan_pppoe_idletime, 1);
3477inputCtrl(document.form.wan_pppoe_idletime_check, 1);
3478inputCtrl(document.form.wan_pppoe_mtu, 1);
3479inputCtrl(document.form.wan_pppoe_mru, 1);
3480inputCtrl(document.form.wan_pppoe_service, 1);
3481inputCtrl(document.form.wan_pppoe_ac, 1);
3482if(window.top.isModel3()!='WL550gE')
3483inputRCtrl1(document.form.wan_pppoe_relay_x, 1);
3484}
3485else if(v == "pptp")
3486{inputCtrl(document.form.wan_ipaddr, 1);
3487inputCtrl(document.form.wan_netmask, 1);
3488inputCtrl(document.form.wan_gateway, 1);
3489inputCtrl(document.form.wan_pppoe_username, 1);
3490inputCtrl(document.form.wan_pppoe_passwd, 1);
3491inputCtrl(document.form.wan_pppoe_idletime, 1);
3492inputCtrl(document.form.wan_pppoe_idletime_check, 1);
3493inputCtrl(document.form.wan_pppoe_mtu, 0);
3494inputCtrl(document.form.wan_pppoe_mru, 0);
3495inputCtrl(document.form.wan_pppoe_service, 0);
3496inputCtrl(document.form.wan_pppoe_ac, 0);
3497if(window.top.isModel3()!='WL550gE')
3498inputRCtrl1(document.form.wan_pppoe_relay_x, 1);
3499}
3500else if (v == "bigpond" || v == "cdma")
3501{inputCtrl(document.form.wan_ipaddr, 0);
3502inputCtrl(document.form.wan_netmask, 0);
3503inputCtrl(document.form.wan_gateway, 0);
3504inputCtrl(document.form.wan_pppoe_username, 1);
3505inputCtrl(document.form.wan_pppoe_passwd, 1);
3506inputCtrl(document.form.wan_pppoe_idletime, 0);
3507inputCtrl(document.form.wan_pppoe_idletime_check, 0);
3508inputCtrl(document.form.wan_pppoe_mtu, 0);
3509inputCtrl(document.form.wan_pppoe_mru, 0);
3510inputCtrl(document.form.wan_pppoe_service, 0);
3511inputCtrl(document.form.wan_pppoe_ac, 0);
3512if(window.top.isModel3()!='WL550gE')
3513inputRCtrl1(document.form.wan_pppoe_relay_x, 1);
3514}
3515else
3516{inputCtrl(document.form.wan_ipaddr, 0);
3517inputCtrl(document.form.wan_netmask, 0);
3518inputCtrl(document.form.wan_gateway, 0);
3519inputCtrl(document.form.wan_pppoe_username, 0);
3520inputCtrl(document.form.wan_pppoe_passwd, 0);
3521inputCtrl(document.form.wan_pppoe_idletime, 0);
3522inputCtrl(document.form.wan_pppoe_idletime_check, 0);
3523inputCtrl(document.form.wan_pppoe_mtu, 0);
3524inputCtrl(document.form.wan_pppoe_mru, 0);
3525inputCtrl(document.form.wan_pppoe_service, 0);
3526inputCtrl(document.form.wan_pppoe_ac, 0);
3527if(window.top.isModel3()!='WL550gE')
3528inputRCtrl1(document.form.wan_pppoe_relay_x, 1);
3529}
3530}
3531function masq_wepkey()
3532{wep1 = document.form.wl_key1.value;
3533wep2 = document.form.wl_key2.value;
3534wep3 = document.form.wl_key3.value;
3535wep4 = document.form.wl_key4.value;
3536if (wep1.length == 10)
3537{wep = "**********";
3538}
3539else if (wep1.length == 26)
3540{wep = "**************************";
3541}
3542else wep = "";
3543document.form.wl_key1.value = wep;
3544document.form.wl_key2.value = wep;
3545document.form.wl_key3.value = wep;
3546document.form.wl_key4.value = wep;
3547}
3548function unmasq_wepkey()
3549{if (document.form.wl_key1.value.indexOf("**********") != -1)
3550document.form.wl_key1.value = wep1;
3551if (document.form.wl_key2.value.indexOf("**********") != -1)
3552document.form.wl_key2.value = wep2;
3553if (document.form.wl_key3.value.indexOf("**********") != -1)
3554document.form.wl_key3.value = wep3;
3555if (document.form.wl_key4.value.indexOf("**********") != -1)
3556document.form.wl_key4.value = wep4;
3557}
3558function masq_wepkey_guest()
3559{wep1 = document.form.wl_guest_key1_1.value;
3560wep2 = document.form.wl_guest_key2_1.value;
3561wep3 = document.form.wl_guest_key3_1.value;
3562wep4 = document.form.wl_guest_key4_1.value;
3563if (wep1.length == 10)
3564{wep = "**********";
3565}
3566else if (wep1.length = 26)
3567{wep = "**************************";
3568}
3569else wep = "";
3570document.form.wl_guest_key1_1.value = wep;
3571document.form.wl_guest_key2_1.value = wep;
3572document.form.wl_guest_key3_1.value = wep;
3573document.form.wl_guest_key4_1.value = wep;
3574}
3575function unmasq_wepkey_guest()
3576{if (document.form.wl_guest_key1_1.value.indexOf("**********") != -1)
3577document.form.wl_guest_key1_1.value = wep1;
3578if (document.form.wl_guest_key2_1.value.indexOf("**********") != -1)
3579document.form.wl_guest_key2_1.value = wep2;
3580if (document.form.wl_guest_key3_1.value.indexOf("**********") != -1)
3581document.form.wl_guest_key3_1.value = wep3;
3582if (document.form.wl_guest_key4_1.value.indexOf("**********") != -1)
3583document.form.wl_guest_key4_1.value = wep4;
3584}
3585function wl_wep_change_guest()
3586{var mode = document.form.wl_guest_auth_mode_1.value;
3587var wep = document.form.wl_guest_wep_x_1.value;
3588if (window.top.isModel()=="WL520gc" || window.top.isModel()=="SnapAP" || window.top.isCard()=="ralink")
3589{if (mode == "wpa" || mode == "psk" || mode == "radius")
3590{inputCtrl(document.form.wl_guest_crypto_1,  1);
3591inputCtrl(document.form.wl_guest_wpa_psk_1,  1);
3592inputCtrl(document.form.wl_guest_wpa_gtk_rekey_1,  1);
3593inputCtrl(document.form.wl_guest_wep_x_1,  0);
3594inputCtrl(document.form.wl_guest_phrase_x_1,  0);
3595inputCtrl(document.form.wl_guest_key1_1, 0);
3596inputCtrl(document.form.wl_guest_key2_1, 0);
3597inputCtrl(document.form.wl_guest_key3_1, 0);
3598inputCtrl(document.form.wl_guest_key4_1, 0);
3599inputCtrl(document.form.wl_guest_key_1,  0);
3600}
3601else
3602{inputCtrl(document.form.wl_guest_crypto_1,  0);
3603inputCtrl(document.form.wl_guest_wpa_psk_1,  0);
3604inputCtrl(document.form.wl_guest_wpa_gtk_rekey_1,  0);
3605inputCtrl(document.form.wl_guest_wep_x_1,  1);
3606if (wep != "0")
3607{inputCtrl(document.form.wl_guest_phrase_x_1,  1);
3608inputCtrl(document.form.wl_guest_key1_1,  1);
3609inputCtrl(document.form.wl_guest_key2_1,  1);
3610inputCtrl(document.form.wl_guest_key3_1,  1);
3611inputCtrl(document.form.wl_guest_key4_1,  1);
3612inputCtrl(document.form.wl_guest_key_1,   1);
3613}
3614else {
3615inputCtrl(document.form.wl_guest_phrase_x_1,  0);
3616inputCtrl(document.form.wl_guest_key1_1,  0);
3617inputCtrl(document.form.wl_guest_key2_1,  0);
3618inputCtrl(document.form.wl_guest_key3_1,  0);
3619inputCtrl(document.form.wl_guest_key4_1,  0);
3620inputCtrl(document.form.wl_guest_key_1,   0);
3621}
3622}
3623}
3624else
3625{/* enable/disable network key 1 to 4 */
3626if (wep != "0") {
3627if (mode == "wpa" || mode == "psk" || mode == "radius") {
3628inputCtrl(document.form.wl_guest_key1_1,  0);
3629inputCtrl(document.form.wl_guest_key4_1,  0);
3630}
3631else {
3632inputCtrl(document.form.wl_guest_key1_1,  1);
3633inputCtrl(document.form.wl_guest_key4_1,  1);
3634}
3635inputCtrl(document.form.wl_guest_key2_1,  1);
3636inputCtrl(document.form.wl_guest_key3_1,  1);
3637} else
3638{inputCtrl(document.form.wl_guest_phrase_x_1,  0);
3639inputCtrl(document.form.wl_guest_key1_1,  0);
3640inputCtrl(document.form.wl_guest_key2_1,  0);
3641inputCtrl(document.form.wl_guest_key3_1,  0);
3642inputCtrl(document.form.wl_guest_key4_1,  0);
3643}
3644/* enable/disable key index */
3645if (wep != "0")
3646inputCtrl(document.form.wl_guest_key_1,  1);
3647else
3648inputCtrl(document.form.wl_guest_key_1,  0);
3649/* enable/disable gtk rotation interval */
3650if (wep != "0")
3651inputCtrl(document.form.wl_guest_wpa_gtk_rekey_1,  0);
3652else {
3653if (mode == "wpa" || mode == "psk")
3654inputCtrl(document.form.wl_guest_wpa_gtk_rekey_1,  1);
3655else
3656inputCtrl(document.form.wl_guest_wpa_gtk_rekey_1,  0);
3657}
3658}
3659}
3660function change_wep_type_guest(mode)
3661{orig = document.form.wl_guest_wep_x_1.value;
3662free_options(document.form.wl_guest_wep_x_1);
3663if (mode == "shared" || mode == "radius")
3664{vitems = new Array("1", "2");
3665items = new Array("WEP-64bits", "WEP-128bits");
3666}
3667else
3668{vitems = new Array("0", "1", "2");
3669items = new Array("None", "WEP-64bits", "WEP-128bits");
3670}
3671add_options_x2(document.form.wl_guest_wep_x_1, vitems, items, orig);
3672if ((mode == "shared" || mode == "radius") && orig == "0")
3673{change_wlweptype_guest(document.form.wl_guest_wep_x_1, "WLANConfig11b");
3674}
3675}
3676function wl_auth_mode_reconf_guest()
3677{if (document.form.wl_guest_auth_mode_1.value=="radius" ||
3678document.form.wl_guest_auth_mode_1.value=="wpa")
3679document.form.wl_guest_auth_mode_1.value="open";
3680}
3681function wl_auth_mode_change_guest(isload)
3682{var mode = document.form.wl_guest_auth_mode_1.value;
3683var i, cur, algos;
3684inputCtrl(document.form.wl_guest_wep_x_1,  1);
3685/* enable/disable crypto algorithm */
3686if (mode == "wpa" || mode == "psk")
3687inputCtrl(document.form.wl_guest_crypto_1,  1);
3688else
3689inputCtrl(document.form.wl_guest_crypto_1,  0);
3690/* enable/disable psk passphrase */
3691if (mode == "psk")
3692inputCtrl(document.form.wl_guest_wpa_psk_1,  1);
3693else
3694inputCtrl(document.form.wl_guest_wpa_psk_1,  0);
3695/* update wl_crypto */
3696if (mode == "wpa" || mode == "psk") {
3697/* Save current crypto algorithm */
3698for (i = 0; i < document.form.wl_guest_crypto_1.length; i++) {
3699if (document.form.wl_guest_crypto_1[i].selected) {
3700cur = document.form.wl_guest_crypto_1[i].value;
3701break;
3702}
3703}
3704if (window.top.isModel()=="SnapAP" || window.top.isBand() == 'b' )
3705algos = new Array("TKIP");
3706else algos = new Array("TKIP", "AES", "TKIP+AES");
3707/* Reconstruct algorithm array from new crypto algorithms */
3708document.form.wl_guest_crypto_1.length = algos.length;
3709for (var i in algos) {
3710document.form.wl_guest_crypto_1[i] = new Option(algos[i], algos[i].toLowerCase());
3711document.form.wl_guest_crypto_1[i].value = algos[i].toLowerCase();
3712if (algos[i].toLowerCase() == cur)
3713document.form.wl_guest_crypto_1[i].selected = true;
3714}
3715}
3716change_wep_type_guest(mode);
3717/* Save current network key index */
3718for (i = 0; i < document.form.wl_guest_key_1.length; i++)
3719{if (document.form.wl_guest_key_1[i].selected) {
3720cur = document.form.wl_guest_key_1[i].value;
3721break;
3722}
3723}
3724/* Define new network key indices */
3725if (mode == "wpa" || mode == "psk" || mode == "radius")
3726algos = new Array("2", "3");
3727else
3728{algos = new Array("1", "2", "3", "4");
3729if (!isload) cur = "1";
3730}
3731/* Reconstruct network key indices array from new network key indices */
3732document.form.wl_guest_key_1.length = algos.length;
3733for (var i in algos) {
3734document.form.wl_guest_key_1[i] = new Option(algos[i], algos[i]);
3735document.form.wl_guest_key_1[i].value = algos[i];
3736if (algos[i] == cur)
3737document.form.wl_guest_key_1[i].selected = true;
3738}
3739wl_wep_change_guest();
3740if ((mode == "wpa" || mode == "psk"))
3741{if (window.top.isModel()=="WL520gc" || window.top.isModel()=="SnapAP" || window.top.isBand()=='b' )
3742{}
3743else if(document.form.wl_guest_crypto_1[2].selected == true)
3744{document.form.wl_guest_wep_x_1.value = 0;
3745inputCtrl(document.form.wl_guest_wep_x_1,  0);
3746inputCtrl(document.form.wl_guest_phrase_x_1,  0);
3747inputCtrl(document.form.wl_guest_key1_1, 0);
3748inputCtrl(document.form.wl_guest_key2_1, 0);
3749inputCtrl(document.form.wl_guest_key3_1, 0);
3750inputCtrl(document.form.wl_guest_key4_1, 0);
3751inputCtrl(document.form.wl_guest_key_1,  0);
3752}
3753}
3754}
3755function change_wlweptype_guest(o, s)
3756{change = 1;
3757window.top.pageChanged = 1;
3758document.form.wl_guest_phrase_x_1.value = "";
3759if (o.value=="0")
3760{wflag = 0;
3761wep = "";
3762document.form.wl_guest_key1_1.value = wep;
3763document.form.wl_guest_key2_1.value = wep;
3764document.form.wl_guest_key3_1.value = wep;
3765document.form.wl_guest_key4_1.value = wep;
3766}
3767else
3768{wflag = 1;
3769if (o.value=="1")
3770{wep = "0000000000";
3771}
3772else  if (o.value=="2")
3773{wep = "00000000000000000000000000";
3774}
3775else
3776{wep = "00000000000000000000000000000000";
3777}
3778is_wlphrase("WLANConfig11b", "wl_phrase_x", document.form.wl_guest_phrase_x_1);
3779}
3780inputCtrl(document.form.wl_guest_phrase_x_1,  wflag);
3781inputCtrl(document.form.wl_guest_key1_1,  wflag);
3782inputCtrl(document.form.wl_guest_key2_1,  wflag);
3783inputCtrl(document.form.wl_guest_key3_1,  wflag);
3784inputCtrl(document.form.wl_guest_key4_1,  wflag);
3785inputCtrl(document.form.wl_guest_key_1,  wflag);
3786wl_wep_change_guest();
3787if (wflag=="1")
3788{document.form.wl_guest_phrase_x_1.focus();
3789}
3790return true;
3791}
3792function showhide(element, sh)
3793{var status;
3794if (sh == 1)
3795{status = "block";
3796}
3797else
3798{status = "none"
3799}                                                                                                                                            if (document.getElementById)
3800{document.getElementById(element).style.display = status;
3801}
3802else if (document.all)
3803{document.all[element].style.display = status;
3804}
3805else if (document.layers)
3806{document.layers[element].display = status;
3807}
3808}
3809function change_ddns_setting(v)
3810{if (v == "WWW.ASUS.COM")
3811{inputCtrl(document.form.ddns_username_x, 0);
3812inputCtrl(document.form.ddns_passwd_x, 0);
3813document.form.ddns_wildcard_x[0].disabled= 1;
3814document.form.ddns_wildcard_x[1].disabled= 1;
3815document.form.LANHostConfig_x_DDNSHostnameCheck_button.disabled= 0;
3816document.getElementsByTagName("a")[0].removeAttribute("href");
3817showhide("link", 0);
3818showhide("Hostname_Note", 1);
3819}
3820else
3821{inputCtrl(document.form.ddns_username_x, 1);
3822inputCtrl(document.form.ddns_passwd_x, 1);
3823document.form.ddns_wildcard_x[0].disabled= 0;
3824document.form.ddns_wildcard_x[1].disabled= 0;
3825document.form.LANHostConfig_x_DDNSHostnameCheck_button.disabled= 1;
3826document.getElementsByTagName("a")[0].setAttribute("href","javascript:openLink('x_DDNSServer')");
3827showhide("link", 1);
3828showhide("Hostname_Note", 0);
3829}
3830}
3831