1var prevTagLabel = new Array(
2                       Array("Country",""),
3                       Array("Broadband",""),
4                       Array("PPPoE",""),
5                       Array("MacHost",""),
6                       Array("WANSetting",""),
7                       Array("Firewall",""),
8                       Array("Wireless",""));
9
10var countryTime = new Array();
11var prevTag = 0;
12var sameWireless=true;
13var tempSVC;
14var tempDate;
15var tempTime;
16
17function inputCtrl1(o, flag)
18{
19    if (flag == 0)
20    {
21       o.disabled = 1;
22       o.style.backgroundColor = "gray";
23    }
24    else
25    {
26       o.disabled = 0;
27       o.style.backgroundColor = "white";
28    }
29}
30
31function inputRCtrl1(o, flag)
32{
33    if (flag == 0)
34    {
35       o[0].disabled = 1;
36       o[1].disabled = 1;
37       //o.style.backgroundColor = "gray";
38    }
39    else
40    {
41       o[0].disabled = 0;
42       o[1].disabled = 0;
43       //o.style.backgroundColor = "white";
44    }
45}
46
47function inputRCtrl2(o, flag)
48{
49    if (flag == 0)
50    {
51       o[0].checked = true;
52       o[1].checked = false;
53       //o.style.backgroundColor = "gray";
54    }
55    else
56    {
57       o[0].checked = false;
58       o[1].checked = true;
59       //o.style.backgroundColor = "white";
60    }
61}
62
63function inputCCtrl4(o, flag)
64{
65    o[0].checked = false;
66    o[1].checked = false;
67    o[2].checked = false;
68    o[3].checked = false;
69    o[flag].checked = true;
70}
71
72function change_security(o, s, l)
73{
74    if (o.value == "0")
75    {
76    	pflag = 0;
77    	wflag = 0;
78
79    	authTypeValue = "0"; 	// Open or Shared
80    	wepTypeValue = "0";	// None
81    }
82    else if (o.value == "1")
83    {
84    	pflag = 1;
85    	wflag = 0;
86
87    	authTypeValue = "1";	// Shared
88    	wepTypeValue = "1";     // WEP-128 bits
89    }
90    else if (o.value == "2")
91    {
92    	pflag = 1;
93    	wflag = 0;
94
95    	authTypeValue = "2";	// WPA-PSK only
96    	wepTypeValue= "0";	// TKIP
97    }
98
99    else if (o.value == "3")
100    {
101    	pflag = 0;
102    	wflag = 0;
103    	authTypeValue = "";
104    	wepTypeValue = "";
105    }
106
107    if (o.options.length == 4 && o.value != "3")
108    {
109    	if (confirm("<#JS_wpa#>"))
110    	{
111    	     o.options[3].value = null;
112    	     o.options[3] = null;
113
114    	     document.form.WLANConfig11b_AuthenticationMethod.value = authTypeValue;
115             document.form.WLANConfig11b_WEPType.value = wepTypeValue;
116    	}
117    	else
118    	{
119    	     pflag = 0;
120    	     wflag = 0;
121    	     o.value = "3";
122    	     authTypeValue="";
123    	     wepTypeValue="";
124    	}
125    }
126
127    if (authTypeValue!="")
128    {
129    	document.form.WLANConfig11b_AuthenticationMethod.value = authTypeValue;
130        document.form.WLANConfig11b_WEPType.value = wepTypeValue;
131    }
132
133
134    if (l==0)
135    {
136       document.form.WLANConfig11b_x_Phrase.value = "";
137
138       if (o.value == "1")
139       {
140       		wep = "00000000000000000000000000";
141       		is_wlphrase("WLANConfig11b", document.form.WLANConfig11b_x_Phrase);
142       }
143       else
144       {
145       		wep = "";
146       		document.form.WLANConfig11b_WEPKey1.value = wep;
147       		document.form.WLANConfig11b_WEPKey2.value = wep;
148       		document.form.WLANConfig11b_WEPKey3.value = wep;
149       		document.form.WLANConfig11b_WEPKey4.value = wep;
150       }
151
152    }
153
154    inputCtrl(document.form.WLANConfig11b_x_Phrase, pflag);
155    inputCtrl(document.form.WLANConfig11b_WEPKey1, wflag);
156    inputCtrl(document.form.WLANConfig11b_WEPKey2, wflag);
157    inputCtrl(document.form.WLANConfig11b_WEPKey3, wflag);
158    inputCtrl(document.form.WLANConfig11b_WEPKey4, wflag);
159    inputCtrl(document.form.WLANConfig11b_WEPDefaultKey,  wflag);
160
161    if (pflag == "1" && l == 0)
162    {
163        document.form.WLANConfig11b_x_Phrase.focus();
164    }
165}
166
167function loadSecurity()
168{
169    authType = 	document.form.WLANConfig11b_AuthenticationMethod.value;
170    wepType = document.form.WLANConfig11b_WEPType.value;
171
172    if (authType == "0" && wepType == "0")
173    {
174    	document.form.SecurityLevel.value = "0";
175    }
176    else if (authType == "1" && wepType == "1")
177    {
178    	document.form.SecurityLevel.value = "1";
179    }
180    else if (authType == "2" && wepType == "0")
181    {
182    	document.form.SecurityLevel.value = "2";
183    }
184    else
185    {
186    	add_option_x(document.form.SecurityLevel, 3, "Extra", 1);
187    	document.form.SecurityLevel.value = "3";
188    }
189
190    change_security(document.form.SecurityLevel, "WLANConfig11b", 1);
191}
192
193function loadQuick()
194{
195    /* Transfer NATEnabled, Layer3Forwarding_x_ConnectionType to x_Mode, x_Connection Rule */
196     //alert(document.form.Layer3Forwarding_x_ConnectionType.value);
197    document.form.next_host.value = location.host;
198
199    //alert(document.form.IPConnection_x_DNSServerEnable[0].checked);
200    //alert(document.form.IPConnection_x_DNSServerEnable[1].checked);
201
202    if (document.form.IPConnection_NATEnabled.value == '1')
203    {
204    	document.form.x_Mode.value = 'Home Gateway';
205
206    	if (document.form.Layer3Forwarding_x_ConnectionType.value == 'PPPoE')
207    	{
208    	    //document.form.x_Connection.value = 'ADSL';
209    	    inputCCtrl4(document.form.x_WANType, 1);
210    	    //inputRCtrl2(document.form.x_ADSLType, 1);
211            inputRCtrl2(document.form.x_DHCPClient, 0);
212    	}
213    	else if (document.form.Layer3Forwarding_x_ConnectionType.value == 'PPTP')
214    	{
215    	    //document.form.x_Connection.value = 'ADSL';
216    	    inputCCtrl4(document.form.x_WANType, 2);
217    	    //inputRCtrl2(document.form.x_ADSLType, 1);
218            inputRCtrl2(document.form.x_DHCPClient, 1);
219    	}
220    	else
221    	{
222    	    if (document.form.Layer3Forwarding_x_ConnectionType.value == 'Static IP')
223    	    {
224    	    	inputCCtrl4(document.form.x_WANType, 3);
225    		//inputRCtrl2(document.form.x_ADSLType, 0);
226    		inputRCtrl2(document.form.x_DHCPClient, 1);
227    	    }
228    	    else
229    	    {
230    	    	inputCCtrl4(document.form.x_WANType, 0);
231    		//inputRCtrl2(document.form.x_ADSLType, 0);
232        	inputRCtrl2(document.form.x_DHCPClient, 0);
233    	    }
234    	    //document.form.x_Connection.value = 'Cable';
235    	}
236
237    	/* For firewall setting */
238    	/* Handle for LanWanActiveDateSVC */
239    	//tempSVC = document.form.FirewallConfig_LanWanActiveSVC.value;
240    	//tempDate = document.form.FirewallConfig_LanWanActiveDate.value;
241	//tempTime = document.form.FirewallConfig_LanWanActiveTime.value;
242    	//document.form.FirewallConfig_LanWanActiveSVC_0.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 0);
243    	//document.form.FirewallConfig_LanWanActiveSVC_1.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 1);
244    	//document.form.FirewallConfig_LanWanActiveSVC_2.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 2);
245    	//document.form.FirewallConfig_LanWanActiveSVC_3.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 3);
246    	//document.form.FirewallConfig_LanWanActiveSVC_4.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 4);
247    	//document.form.FirewallConfig_LanWanActiveSVC_5.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveSVC.value, 5);
248
249    	//document.form.FirewallConfig_LanWanActiveDate_Sun.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 0);
250    	//document.form.FirewallConfig_LanWanActiveDate_Mon.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 1);
251    	//document.form.FirewallConfig_LanWanActiveDate_Tue.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 2);
252    	//document.form.FirewallConfig_LanWanActiveDate_Wed.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 3);
253    	//document.form.FirewallConfig_LanWanActiveDate_Thu.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 4);
254    	//document.form.FirewallConfig_LanWanActiveDate_Fri.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 5);
255    	//document.form.FirewallConfig_LanWanActiveDate_Sat.checked = getDateCheck(document.form.FirewallConfig_LanWanActiveDate.value, 6);
256
257    	//document.form.FirewallConfig_LanWanActiveTime_starthour.value = getTimeRange(document.form.FirewallConfig_LanWanActiveTime.value, 0);
258        //document.form.FirewallConfig_LanWanActiveTime_startmin.value = getTimeRange(document.form.FirewallConfig_LanWanActiveTime.value, 1);
259        //document.form.FirewallConfig_LanWanActiveTime_endhour.value = getTimeRange(document.form.FirewallConfig_LanWanActiveTime.value, 2);
260        //document.form.FirewallConfig_LanWanActiveTime_endmin.value = getTimeRange(document.form.FirewallConfig_LanWanActiveTime.value, 3);
261    }
262    else if (document.form.IPConnection_ConnectionType.value == 'IP_Routed')
263    {
264    	document.form.x_Mode.value = 'Router';
265    	//document.form.x_Connection.value = '';
266    	//inputRCtrl2(document.form.x_ADSLType, 0);
267        inputRCtrl2(document.form.x_DHCPClient, 1);
268    }
269    else
270    {
271    	document.form.x_Mode.value = 'Access Point';
272    	//document.form.x_Connection.value = '';
273    }
274
275    if (window.top.isModel() == "WL600")
276    {
277       if (document.form.WLANConfig11a_SSID.value != document.form.WLANConfig11b_SSID.value ||
278          document.form.WLANConfig11a_WEPType.value != document.form.WLANConfig11b_WEPType.value ||
279          document.form.WLANConfig11a_WEPKey1.value != document.form.WLANConfig11b_WEPKey1.value ||
280          document.form.WLANConfig11a_WEPKey2.value != document.form.WLANConfig11b_WEPKey2.value ||
281          document.form.WLANConfig11a_WEPKey3.value != document.form.WLANConfig11b_WEPKey3.value ||
282          document.form.WLANConfig11a_WEPKey4.value != document.form.WLANConfig11b_WEPKey4.value ||
283          document.form.WLANConfig11a_WEPDefaultKey.value != document.form.WLANConfig11b_WEPDefaultKey.value)
284       {
285          sameWireless=false;
286       }
287       else
288       {
289          sameWireless=true;
290       }
291    }
292    else
293    {
294       loadSecurity();
295       sameWireless=true;
296    }
297
298    changeMode();
299}
300
301function loadMode()
302{
303    /* Transfer NATEnabled, Layer3Forwarding_x_ConnectionType to x_Mode, x_Connection Rule */
304     //alert(document.form.Layer3Forwarding_x_ConnectionType.value);
305    document.form.next_host.value = location.host;
306
307    //alert(document.form.IPConnection_x_DNSServerEnable[0].checked);
308    //alert(document.form.IPConnection_x_DNSServerEnable[1].checked);
309    if (window.top.isModel() == "WL300")
310    {
311    	if (document.form.IPConnection_NATEnabled.value == '1')
312    	{
313    		document.form.x_Mode[0].checked = false;
314    		document.form.x_Mode[1].checked = true;
315    	}
316    	else
317    	{
318    		document.form.x_Mode[0].checked = true;
319    		document.form.x_Mode[1].checked = false;
320    	}
321
322    }
323    else
324    {
325    	if (document.form.IPConnection_NATEnabled.value == '1')
326    	{
327    		document.form.x_Mode[0].checked = true;
328    		document.form.x_Mode[1].checked = false;
329    		//document.form.x_Mode[2].checked = false;
330    	}
331    	//else if (document.form.IPConnection_ConnectionType.value == 'IP_Routed')
332    	//{
333    	//	document.form.x_Mode[0].checked = false;
334    	//	document.form.x_Mode[1].checked = true;
335    	//	document.form.x_Mode[2].checked = false;
336    	//}
337    	else
338    	{
339    		document.form.x_Mode[0].checked = false;
340    		document.form.x_Mode[1].checked = true;
341        	//document.form.x_Mode[2].checked = true;
342    	}
343    }
344    //changeMode();
345}
346
347function setSVCCheck(d1, d2, d3, d4, d5, d6)
348{
349   str = "";
350
351   if (d6 == true ) str = "1" + str;
352   else str = "0" + str;
353   if (d5 == true ) str = "1" + str;
354   else str = "0" + str;
355   if (d4 == true ) str = "1" + str;
356   else str = "0" + str;
357   if (d3 == true ) str = "1" + str;
358   else str = "0" + str;
359   if (d2 == true ) str = "1" + str;
360   else str = "0" + str;
361   if (d1 == true ) str = "1" + str;
362   else str = "0" + str;
363
364   return str;
365}
366
367function saveQuick(o)
368{
369/*
370    if (document.form.IPConnection_NATEnabled.value == '1')
371    {
372    	document.form.x_Mode.value == 'Home Gateway'
373
374    	if (document.form.Layer3Forwarding_x_ConnectionType.value == 'PPPoE')
375    	   document.form.x_Connection.value == 'ADSL';
376    	else
377    	   document.form.x_Connection.value == 'Cable';
378    }
379    else if (document.form.IPConnection_ConnectionType.value == 'IP_Routed')
380    {
381    	document.form.x_Mode.value == 'Router'
382    }
383    else
384    {
385    	document.form.x_Mode.value == 'Access Point'
386    }
387*/
388    /* Copy Wireless 11b to Wireless 11a */
389    window.top.pageChanged = 0;
390    window.top.pageChangedCount = 0;
391
392    if (!sameWireless)
393    {
394       if (confirm('<#JS_dual#>'))
395       {
396           document.form.WLANConfig11a_SSID.value = document.form.WLANConfig11b_SSID.value;
397    	   document.form.WLANConfig11a_WEPType.value = document.form.WLANConfig11b_WEPType.value;
398    	   document.form.WLANConfig11a_WEPKey1.value = document.form.WLANConfig11b_WEPKey1.value;
399    	   document.form.WLANConfig11a_WEPKey2.value = document.form.WLANConfig11b_WEPKey2.value;
400    	   document.form.WLANConfig11a_WEPKey3.value = document.form.WLANConfig11b_WEPKey3.value;
401    	   document.form.WLANConfig11a_WEPKey4.value = document.form.WLANConfig11b_WEPKey4.value;
402    	   document.form.WLANConfig11a_WEPDefaultKey.value = document.form.WLANConfig11b_WEPDefaultKey.value;
403       }
404    }
405    else
406    {
407       document.form.WLANConfig11a_SSID.value = document.form.WLANConfig11b_SSID.value;
408       document.form.WLANConfig11a_WEPType.value = document.form.WLANConfig11b_WEPType.value;
409       document.form.WLANConfig11a_WEPKey1.value = document.form.WLANConfig11b_WEPKey1.value;
410       document.form.WLANConfig11a_WEPKey2.value = document.form.WLANConfig11b_WEPKey2.value;
411       document.form.WLANConfig11a_WEPKey3.value = document.form.WLANConfig11b_WEPKey3.value;
412       document.form.WLANConfig11a_WEPKey4.value = document.form.WLANConfig11b_WEPKey4.value;
413       document.form.WLANConfig11a_WEPDefaultKey.value = document.form.WLANConfig11b_WEPDefaultKey.value;
414    }
415    document.form.WLANConfig11a_x_AESEnable.value = "0";
416
417    inputCtrl(document.form.WLANConfig11b_x_Phrase, 1);
418    inputCtrl(document.form.WLANConfig11b_WEPKey1, 1);
419    inputCtrl(document.form.WLANConfig11b_WEPKey2, 1);
420    inputCtrl(document.form.WLANConfig11b_WEPKey3, 1);
421    inputCtrl(document.form.WLANConfig11b_WEPKey4, 1);
422    inputCtrl(document.form.WLANConfig11b_WEPDefaultKey, 1);
423    //document.form.next_page.value = 'Main_Content.asp';
424
425    if (document.form.x_Mode.value == 'Access Point')
426    {
427        document.form.IPConnection_NATEnabled.value = '0';
428        document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
429        document.form.IPConnection_ConnectionType.value = 'IP_Bridged';
430
431    }
432    else if (document.form.x_Mode.value == 'Router')
433    {
434        document.form.IPConnection_NATEnabled.value = '0';
435        document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
436        document.form.IPConnection_ConnectionType.value = 'IP_Routed';
437    }
438    else
439    {
440        document.form.IPConnection_NATEnabled.value = '1';
441        document.form.IPConnection_ConnectionType.value = 'IP_Routed';
442        if (document.form.x_WANType[1].checked == true)
443        {
444           document.form.Layer3Forwarding_x_ConnectionType.value = 'PPPoE';
445        }
446        else if (document.form.x_WANType[2].checked == true)
447        {
448           document.form.Layer3Forwarding_x_ConnectionType.value = 'PPTP';
449        }
450        else if (document.form.x_WANType[3].checked == true)
451        {
452           document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
453        }
454        else
455        {
456           document.form.Layer3Forwarding_x_ConnectionType.value = 'Automatic IP';
457        }
458
459        //if (document.form.FirewallConfig_LanWanActiveSVCFlag.value!="")
460        //{
461        //	document.form.FirewallConfig_LanWanActiveSVC.value = setSVCCheck(
462   	//   		document.form.FirewallConfig_LanWanActiveSVC_0.checked,
463   	//   		document.form.FirewallConfig_LanWanActiveSVC_1.checked,
464   	//   		document.form.FirewallConfig_LanWanActiveSVC_2.checked,
465   	//   		document.form.FirewallConfig_LanWanActiveSVC_3.checked,
466   	//   		document.form.FirewallConfig_LanWanActiveSVC_4.checked,
467   	//   		document.form.FirewallConfig_LanWanActiveSVC_5.checked);
468        //
469       	//	document.form.FirewallConfig_LanWanActiveDate.value = setDateCheck(
470   	//   		document.form.FirewallConfig_LanWanActiveDate_Sun,
471   	//   		document.form.FirewallConfig_LanWanActiveDate_Mon,
472   	//   		document.form.FirewallConfig_LanWanActiveDate_Tue,
473   	//   		document.form.FirewallConfig_LanWanActiveDate_Wed,
474   	//   		document.form.FirewallConfig_LanWanActiveDate_Thu,
475   	//   		document.form.FirewallConfig_LanWanActiveDate_Fri,
476   	//   		document.form.FirewallConfig_LanWanActiveDate_Sat);
477
478   	//		document.form.FirewallConfig_LanWanActiveTime.value = setTimeRange(
479   	//   		document.form.FirewallConfig_LanWanActiveTime_starthour,
480   	//   		document.form.FirewallConfig_LanWanActiveTime_startmin,
481   	//   		document.form.FirewallConfig_LanWanActiveTime_endhour,
482   	//   		document.form.FirewallConfig_LanWanActiveTime_endmin);
483
484   	   		// Embeded rule here
485	//		if (document.form.FirewallConfig_LanWanActiveSVC_5.checked == true )
486   	//   		{
487   	//
488   	//   			document.form.FirewallConfig_WanLanFirewallEnable.value = "1";
489   	//   			document.form.FirewallConfig_LanWanDefaultAct.value = "DROP";
490   	//   			document.form.FirewallConfig_LanWanActiveSVCFlag.value = setSVCCheck(
491	//			!document.form.FirewallConfig_LanWanActiveSVC_0.checked,
492	//			!document.form.FirewallConfig_LanWanActiveSVC_1.checked,
493	//			!document.form.FirewallConfig_LanWanActiveSVC_2.checked,
494	//			!document.form.FirewallConfig_LanWanActiveSVC_3.checked,
495	//			!document.form.FirewallConfig_LanWanActiveSVC_4.checked,
496	//			false);
497   	   			// insert rule of SVC that not checked
498   	//   		}
499   	//  		else
500   	//   		{
501   	//   			document.form.FirewallConfig_WanLanFirewallEnable.value = "1";
502   	//   			document.form.FirewallConfig_LanWanDefaultAct.value = "ACCEPT";
503   	//   			document.form.FirewallConfig_LanWanActiveSVCFlag.value = setSVCCheck(
504	//			document.form.FirewallConfig_LanWanActiveSVC_0.checked,
505	//			document.form.FirewallConfig_LanWanActiveSVC_1.checked,
506	//			document.form.FirewallConfig_LanWanActiveSVC_2.checked,
507	//			document.form.FirewallConfig_LanWanActiveSVC_3.checked,
508	//			document.form.FirewallConfig_LanWanActiveSVC_4.checked,
509	//			false);
510	//			if (document.form.FirewallConfig_LanWanActiveSVCFlag.value == "000000" )
511	//			{
512	//				document.form.FirewallConfig_WanLanFirewallEnable.value = "0";
513	//			}
514   	//   			// insert rule of SVC that check
515   	//   		}
516	//		//alert(document.form.FirewallConfig_LanWanActiveSVCFlag.value);
517   	//	}
518   	//	else
519   	//	{
520   	//		document.form.FirewallConfig_LanWanActiveSVC.value = tempSVC;
521   	//		document.form.FirewallConfig_LanWanActiveDate.value = tempDate;
522	//		document.form.FirewallConfig_LanWanActiveTime.value = tempTime;
523   	//	}
524
525   	//	document.form.FirewallConfig_LanWanActiveSVC_0.checked = false;
526    	//	document.form.FirewallConfig_LanWanActiveSVC_1.checked = false;
527    	//	document.form.FirewallConfig_LanWanActiveSVC_2.checked = false;
528    	//	document.form.FirewallConfig_LanWanActiveSVC_3.checked = false;
529    	//	document.form.FirewallConfig_LanWanActiveSVC_4.checked = false;
530    	//	document.form.FirewallConfig_LanWanActiveSVC_5.checked = false;
531    		document.form.SecurityLevel.disabled = true;
532
533    		//document.form.x_Connection.disabled = true;
534    		document.form.x_DHCPClient.disabled = true;
535    		//document.form.x_ADSLType.disabled = true;
536    		document.form.x_DHCPClient[0].checked = false;
537    		document.form.x_DHCPClient[1].checked = false;
538    		//document.form.x_ADSLType[0].checked = false;
539    		//document.form.x_ADSLType[1].checked = false;
540
541
542    		if (window.top.isModel() != "WL600")
543    		{
544    		    document.form.WLANConfig11a_SSID.disabled = true;
545          	    document.form.WLANConfig11a_WEPType.disabled = true;
546          	    document.form.WLANConfig11a_WEPKey1.disabled = true;
547          	    document.form.WLANConfig11a_WEPKey2.disabled = true;
548          	    document.form.WLANConfig11a_WEPKey3.disabled = true;
549          	    document.form.WLANConfig11a_WEPKey4.disabled = true;
550          	    document.form.WLANConfig11a_WEPDefaultKey.disabled = true;
551    		}
552    }
553
554    //if (o.value == ' Finish ')
555    //{
556    //   o.value = '  Save  ';
557    //}
558    o.value = '  Save  ';
559    document.form.action_mode.value = '  Save  ';
560    return true;
561}
562
563function changeMode()
564{
565    if (document.form.x_Mode.value == 'Home Gateway')
566    {
567    	 if (document.form.x_WANType[0].checked == true)
568    	 {
569    	     inputCtrl1(document.form.PPPConnection_UserName, 0);
570    	     inputCtrl1(document.form.PPPConnection_Password, 0);
571
572    	     inputRCtrl1(document.form.x_DHCPClient, 1);
573    	     inputRCtrl2(document.form.x_DHCPClient, 0);
574    	     inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
575    	     inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
576    	     inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
577
578    	     //inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
579    	     //inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 0);
580    	     //inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
581    	     //inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
582
583    	     changeDHCPClient();
584    	     changeDNSServer();
585    	 }
586    	 else
587    	 {
588
589    	     // require account
590    	     if (document.form.x_WANType[1].checked == true || document.form.x_WANType[2].checked == true)
591    	     {
592    	        inputCtrl1(document.form.PPPConnection_UserName, 1);
593    	        inputCtrl1(document.form.PPPConnection_Password, 1);
594    	     }
595    	     else
596    	     {
597    	     	inputCtrl1(document.form.PPPConnection_UserName, 0);
598    	        inputCtrl1(document.form.PPPConnection_Password, 0);
599    	     }
600
601    	     // require IP
602    	     if (document.form.x_WANType[0].checked == true || document.form.x_WANType[1].checked == true)
603    	     {
604    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
605    	     	inputRCtrl2(document.form.x_DHCPClient, 0);
606    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
607    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
608    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
609
610    	     	//inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
611    	     	//inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 0);
612    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
613    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
614    	     }
615    	     else if(document.form.x_WANType[2].checked == true) // PPTP
616    	     {
617    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
618    	     	inputRCtrl2(document.form.x_DHCPClient, 1);
619    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
620    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
621    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
622
623    	     	//inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
624    	     	//inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 1);
625    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
626    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
627    	     }
628    	     else // static IP
629    	     {
630    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
631    	     	inputRCtrl2(document.form.x_DHCPClient, 1);
632    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
633    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
634    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
635
636    	     	//inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
637    	     	//inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 1);
638    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
639    	     	//inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
640    	     }
641    	     changeDHCPClient();
642    	     changeDNSServer();
643    	 }
644    }
645    else if (document.form.x_Mode.value == 'Access Point')
646    {
647         //inputCtrl1(document.form.x_Connection, 0);
648    	 //inputCtrl1(document.form.PPPConnection_UserName, 0);
649    	 //inputCtrl1(document.form.PPPConnection_Password, 0);
650
651    	 //inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 0);
652    	 //inputCtrl1(document.form.IPConnection_x_DNSServer1, 0);
653    	 //inputCtrl1(document.form.IPConnection_x_DNSServer2, 0);
654
655
656    	 //inputCtrl1(document.form.LANHostConfig_IPRouters, 1);
657    	 //inputCtrl1(document.form.LANHostConfig_SubnetMask, 1);
658    	 //inputRCtrl1(document.form.LANHostConfig_DHCPServerConfigurable, 0);
659    	 //inputCtrl1(document.form.LANHostConfig_MinAddress, 0);
660    	 //inputCtrl1(document.form.LANHostConfig_MaxAddress, 0);
661
662    	 //inputRCtrl1(document.form.x_DHCPClient, 0);
663    	 //inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
664    	 //inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
665    	 //inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
666    	 //changeDHCPClient();
667    }
668    else if (document.form.x_Mode.value == 'Router')
669    {
670    	 //inputCtrl1(document.form.x_Connection, 0);
671    	 //inputCtrl1(document.form.PPPConnection_UserName, 0);
672    	 //inputCtrl1(document.form.PPPConnection_Password, 0);
673
674    	 //inputRCtrl1(document.form.x_DHCPClient, 0);
675    	 inputRCtrl2(document.form.x_DHCPClient, 1);
676    	 inputRCtrl1(document.form.x_DHCPClient, 0);
677    	 inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
678    	 inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
679    	 inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
680
681    	 inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 0);
682    	 inputCtrl1(document.form.IPConnection_x_DNSServer1, 0);
683    	 inputCtrl1(document.form.IPConnection_x_DNSServer2, 0);
684
685    	 changeDHCPClient();
686    	 //changeDNSServer();
687
688    	 //inputCtrl1(document.form.LANHostConfig_IPRouters, 1);
689    	 //inputCtrl1(document.form.LANHostConfig_SubnetMask, 1);
690    	 //inputRCtrl1(document.form.LANHostConfig_DHCPServerConfigurable, 1);
691    	 //inputCtrl1(document.form.LANHostConfig_MinAddress, 1);
692    	 //inputCtrl1(document.form.LANHostConfig_MaxAddress, 1);
693
694    	 //changeDHCPServer();
695    }
696}
697
698function changeWANType()
699{
700         if (document.form.x_WANType[0].checked == true)
701    	 {
702    	     inputCtrl1(document.form.PPPConnection_UserName, 0);
703    	     inputCtrl1(document.form.PPPConnection_Password, 0);
704
705    	     inputRCtrl1(document.form.x_DHCPClient, 1);
706    	     inputRCtrl2(document.form.x_DHCPClient, 0);
707    	     inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
708    	     inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
709    	     inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
710
711    	     inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
712    	     inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 0);
713    	     inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
714    	     inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
715
716    	     changeDHCPClient();
717    	     changeDNSServer();
718    	 }
719    	 else
720    	 {
721
722    	     // require account
723    	     if (document.form.x_WANType[1].checked == true || document.form.x_WANType[2].checked == true)
724    	     {
725    	        inputCtrl1(document.form.PPPConnection_UserName, 1);
726    	        inputCtrl1(document.form.PPPConnection_Password, 1);
727    	     }
728    	     else
729    	     {
730    	     	inputCtrl1(document.form.PPPConnection_UserName, 0);
731    	        inputCtrl1(document.form.PPPConnection_Password, 0);
732    	     }
733
734    	     // require IP
735    	     if (document.form.x_WANType[0].checked == true || document.form.x_WANType[1].checked == true)
736    	     {
737    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
738    	     	inputRCtrl2(document.form.x_DHCPClient, 0);
739    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
740    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
741    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
742
743    	     	inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
744    	     	inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 0);
745    	     	inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
746    	     	inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
747    	     }
748    	     else if(document.form.x_WANType[2].checked == true) // PPTP
749    	     {
750    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
751    	     	inputRCtrl2(document.form.x_DHCPClient, 1);
752    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
753    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
754    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
755
756    	     	inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
757    	     	inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 1);
758    	     	inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
759    	     	inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
760    	     }
761    	     else // static IP
762    	     {
763    	     	inputRCtrl1(document.form.x_DHCPClient, 1);
764    	     	inputRCtrl2(document.form.x_DHCPClient, 1);
765    	     	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
766    	     	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
767    	     	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
768
769    	     	inputRCtrl1(document.form.IPConnection_x_DNSServerEnable, 1);
770    	     	inputRCtrl2(document.form.IPConnection_x_DNSServerEnable, 1);
771    	     	inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
772    	     	inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
773    	     }
774    	     changeDHCPClient();
775    	     changeDNSServer();
776    	 }
777}
778
779function changeDHCPClient()
780{
781    if (document.form.x_DHCPClient[0].checked == true)
782    {
783    	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 0);
784    	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 0);
785    	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 0);
786    }
787    else
788    {
789    	inputCtrl1(document.form.IPConnection_ExternalIPAddress, 1);
790    	inputCtrl1(document.form.IPConnection_x_ExternalSubnetMask, 1);
791    	inputCtrl1(document.form.IPConnection_x_ExternalGateway, 1);
792    }
793}
794
795function changeADSLType()
796{
797    if (document.form.x_WANType[0].checked == true || document.form.x_WANType[3].checked == true)
798    {
799    	inputCtrl1(document.form.PPPConnection_UserName, 0);
800    	inputCtrl1(document.form.PPPConnection_Password, 0);
801    }
802    else
803    {
804    	inputCtrl1(document.form.PPPConnection_UserName, 1);
805    	inputCtrl1(document.form.PPPConnection_Password, 1);
806    }
807}
808
809function changeDNSServer()
810{
811    if (document.form.IPConnection_x_DNSServerEnable[0].checked == true)
812    {
813    	inputCtrl1(document.form.IPConnection_x_DNSServer1, 0);
814    	inputCtrl1(document.form.IPConnection_x_DNSServer2, 0);
815    }
816    else
817    {
818
819    	inputCtrl1(document.form.IPConnection_x_DNSServer1, 1);
820    	inputCtrl1(document.form.IPConnection_x_DNSServer2, 1);
821    }
822}
823
824function changeDHCPServer()
825{
826
827    //if (document.form.LANHostConfig_DHCPServerConfigurable[0].checked == true)
828    //{
829    //	inputCtrl1(document.form.LANHostConfig_MinAddress, 1);
830    //    inputCtrl1(document.form.LANHostConfig_MaxAddress, 1);
831    //}
832    //else
833    //{
834    //	inputCtrl1(document.form.LANHostConfig_MinAddress, 0);
835    //    inputCtrl1(document.form.LANHostConfig_MaxAddress, 0);
836    //}
837}
838
839function saveMode(o)
840{
841    //changeMode();
842
843    document.form.next_page.value = 'Main_Operation.asp';
844
845    if (window.top.isModel() == "WL300")
846    {
847    if (document.form.x_Mode[0].checked == true) //Access Point
848    {
849        document.form.IPConnection_NATEnabled.value = '0';
850        document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
851        document.form.IPConnection_ConnectionType.value = 'IP_Bridged';
852    }
853    else if (document.form.x_Mode[1].checked == true) //Home Gateway
854    {
855        document.form.IPConnection_NATEnabled.value = '1';
856        document.form.IPConnection_ConnectionType.value = 'IP_Routed';
857        document.form.Layer3Forwarding_x_ConnectionType.value = 'PPPoE';
858    }
859    }
860    else
861    {
862    if (document.form.x_Mode[1].checked == true) //Access Point
863    {
864        document.form.IPConnection_NATEnabled.value = '0';
865        document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
866        document.form.IPConnection_ConnectionType.value = 'IP_Bridged';
867    }
868    //else if (document.form.x_Mode[1].checked == true) //Router
869    //{
870    //    document.form.IPConnection_NATEnabled.value = '0';
871    //    document.form.Layer3Forwarding_x_ConnectionType.value = 'Static IP';
872    //    document.form.IPConnection_ConnectionType.value = 'IP_Routed';
873    //}
874    else if (document.form.x_Mode[0].checked == true) //Home Gateway
875    {
876        document.form.IPConnection_NATEnabled.value = '1';
877        document.form.IPConnection_ConnectionType.value = 'IP_Routed';
878        document.form.Layer3Forwarding_x_ConnectionType.value = 'PPPoE';
879    }
880    }
881    o.value = "  Save  ";
882    document.form.action_mode.value = "  Save  ";
883    document.form.submit();
884}
885
886function toTag(s)
887{
888	if (s == 'Mode')
889	{
890	    if (document.form.x_Mode.value == 'Access Point')
891	    {
892	       t = 'Wireless';
893	    }
894	    else if (document.form.x_Mode.value == 'Router')
895	    {
896	       t = 'WANSetting';
897	    }
898	    else
899	    {
900	       t = 'Broadband';
901	    }
902	}
903	else if (s == 'Country')
904	{
905	    if (window.top.isMode() == 'Access Point')
906	    {
907	       t = 'Wireless';
908	    }
909	    else if (window.top.isMode() == 'Router')
910	    {
911	       t = 'WANSetting';
912	    }
913	    else
914	    {
915	       t = 'Broadband';
916	    }
917	}
918	else if (s=='Broadband')
919	{
920	    if (document.form.x_WANType[1].checked == true || document.form.x_WANType[2].checked == true)
921	    {
922	       //inputRCtrl2(document.form.x_ADSLType, 1);
923	       changeADSLType();
924	       t = 'PPPoE';
925	    }
926	    else if (document.form.x_WANType[0].checked == true)
927	    {
928	       t = 'MacHost';
929	    }
930	    else
931	    {
932	       t = 'WANSetting';
933	    }
934        }
935        else if (s=='PPPoE')
936	{
937	    if (document.form.x_WANType[1].checked == true || document.form.x_WANType[2].checked == true)
938	    {
939	       if (document.form.PPPConnection_UserName.value == "" || document.form.PPPConnection_Password.value == "")
940	       {
941	    	   alert("<#JS_ADSL#>");
942	    	   return;
943	       }
944	       // if (document.form.x_WANType[1].checked == true)
945	       //{
946	       //		inputRCtrl2(document.form.x_DHCPClient, 0);
947	       //}
948	       //else if(document.form.x_WANType[2].checked == true)
949	       //{
950	       //		inputRCtrl2(document.form.x_DHCPClient, 1);
951	       //}
952	       //changeDHCPClient();
953	       //t = 'Wireless';
954	       if (document.form.x_WANType[2].checked == true)
955	       {
956	          t = 'WANSetting';
957	       }
958	       else
959	       {
960	          t = 'Wireless';
961	       }
962	    }
963	    else
964	    {
965	       inputRCtrl2(document.form.x_DHCPClient, 1);
966	       changeDHCPClient();
967	       t = 'WANSetting';
968	    }
969
970        }
971        else if (s=='PPPoE_IP')
972	{
973	    t = 'WANSetting';
974        }
975        else if (s=='MacHost')
976	{
977	    t = 'WANSetting';
978        }
979        else if (s=='WANSetting')
980	{
981	    if ((document.form.x_DHCPClient[1].checked == true) && (document.form.IPConnection_ExternalIPAddress.value == "" || document.form.IPConnection_x_ExternalSubnetMask.value == ""))
982	    {
983	        //if (document.form.x_Mode.value == 'Router')
984	        //{
985	           alert("<#JS_router_ip#>");
986	           return;
987		//}
988		//else
989		//{
990	    	//   alert("<#JS_dhcp_ip#>");
991  	        //   inputRCtrl2(document.form.x_DHCPClient, 0);
992  	        //}
993	    }
994
995	    if (window.top.isMode() == 'Gateway')
996	    {
997	    	t='Wireless';
998	    }
999	    else t = 'Wireless';
1000        }
1001        //else if (s=='Firewall')
1002        //{
1003        //    if (document.form.FirewallConfig_WanLanFirewallEnable.value == "1" &&
1004	//    		(document.form.FirewallConfig_LanWanRuleCount.value != "0" ||
1005	//    		 document.form.FirewallConfig_LanWanDefaultAct.value == "DROP"))
1006	//    {
1007	//    	if (confirm('Internet Access setting has been modified before, would you like to overwrite your previous setting?'))
1008       	//    	{
1009       	//	    document.form.FirewallConfig_LanWanActiveSVCFlag.value = "000000";
1010	//    	}
1011	//    	else
1012	//    	{
1013	//    	    document.form.FirewallConfig_LanWanActiveSVCFlag.value = "";
1014	//    	}
1015	//    }
1016	//    else
1017	//    {
1018	//    	document.form.FirewallConfig_LanWanActiveSVCFlag.value = "000000";
1019	//    }
1020        //    t = 'Wireless';
1021        //}
1022        else if (s=='LANSetting')
1023	{
1024            if (document.form.x_Mode.value == 'Access Point')
1025	       t = 'Wireless';
1026	    else
1027	    {
1028	       checkSubnet();
1029	       t = 'DHCPSetting';
1030	    }
1031        }
1032        else if (s=='DHCPSetting')
1033        {
1034            t = 'Wireless';
1035        }
1036        else
1037        {
1038            t = 'Wireless';
1039        }
1040
1041        for(i=0; i< prevTagLabel.length; i++)
1042        {
1043           if (prevTagLabel[i][0] == t)
1044           {
1045              prevTagLabel[i][1]=s;
1046              break;
1047           }
1048        }
1049        location.href = document.form.current_page.value + '#' + t;
1050}
1051
1052function toPrevTag(s)
1053{
1054	prevTag = "";
1055
1056	for(i=0; i< prevTagLabel.length; i++)
1057        {
1058           if (prevTagLabel[i][0] == s)
1059           {
1060              prevTag=prevTagLabel[i][1];
1061              break;
1062           }
1063        }
1064
1065	if ( prevTag != "")
1066	{
1067	    location.href = document.form.current_page.value + '#' + prevTag;
1068	}
1069	else
1070	{
1071	    location.href = document.form.current_page.value;
1072	}
1073}
1074
1075function matchSubnet(ip1, ip2, count)
1076{
1077	c = 0;
1078	v1 = 0;
1079	v2 = 0;
1080
1081
1082	for(i=0;i<ip1.length;i++)
1083	{
1084	   if (ip1.charAt(i) == '.')
1085	   {
1086	      c++;
1087
1088	      if (v1!=v2) return false;
1089	      v1 = 0;
1090	      v2 = 0;
1091	   }
1092	   else
1093	   {
1094	      if (ip2.charAt(i)=='.') return false;
1095
1096	      v1 = v1*10 + (ip1.charAt(i) - '0');
1097	      v2 = v2*10 + (ip2.charAt(i) - '0');
1098	   }
1099	   if (c==count) return true;
1100	}
1101	return false;
1102}
1103
1104function subnetPrefix(ip, orig, count)
1105{
1106	r='';
1107	c=0;
1108
1109	for(i=0;i<ip.length;i++)
1110	{
1111	   if (ip.charAt(i) == '.')
1112	      c++;
1113
1114	   if (c==count) break;
1115
1116	   r = r + ip.charAt(i);
1117	}
1118
1119	c=0;
1120
1121	for(i=0;i<orig.length;i++)
1122	{
1123	   if (orig.charAt(i) == '.')
1124	   {
1125	      c++;
1126	   }
1127
1128	   if (c>=count)
1129	     r = r + orig.charAt(i);
1130	}
1131	return (r);
1132}
1133
1134function checkSubnet()
1135{
1136        /* Rule : If addresses in pool are match to subnet, don't change */
1137        /* Rule : If addresses in pool are not match to subnet, change to subnet.2~subnet.254 */
1138        if (!matchSubnet(document.form.LANHostConfig_IPRouters.value, document.form.LANHostConfig_MinAddress.value, 3) ||
1139            !matchSubnet(document.form.LANHostConfig_IPRouters.value, document.form.LANHostConfig_MaxAddress.value, 3))
1140        {
1141            document.form.LANHostConfig_MinAddress.value = subnetPrefix(document.form.LANHostConfig_IPRouters.value, document.form.LANHostConfig_MinAddress.value, 3);
1142            document.form.LANHostConfig_MaxAddress.value = subnetPrefix(document.form.LANHostConfig_IPRouters.value, document.form.LANHostConfig_MaxAddress.value, 3);
1143        }
1144}
1145
1146function changeCountry(o, s, v)
1147{
1148}
1149
1150function changeFirewall(o, s)
1151{
1152  if (s == "WLANConfig11a")
1153  {
1154      if (document.form.WLANConfig11a_WEPType.value == 'None' || document.form.WLANConfig11a_WEPType.value == 'FromServer')
1155      {
1156      	 inputRCtrl2(document.form.WLANConfig11a_x_AESEnable, 1);
1157         flag = 0;
1158         wep = "";
1159      }
1160      else
1161      {
1162      	 flag = 1;
1163
1164      	 if (document.form.WLANConfig11a_WEPType.value == "64bits")
1165      	    wep = "0000000000";
1166      	 else  if (document.form.WLANConfig11a_WEPType.value == "128bits")
1167      	    wep = "00000000000000000000000000";
1168      	 else
1169      	    wep = "00000000000000000000000000000000";
1170      }
1171
1172      document.form.WLANConfig11a_x_Phrase.value = '';
1173      document.form.WLANConfig11a_WEPKey1.value = wep;
1174      document.form.WLANConfig11a_WEPKey2.value = wep;
1175      document.form.WLANConfig11a_WEPKey3.value = wep;
1176      document.form.WLANConfig11a_WEPKey4.value = wep;
1177
1178      inputCtrl(document.form.WLANConfig11a_x_Phrase, flag);
1179      inputCtrl(document.form.WLANConfig11a_WEPKey1, flag);
1180      inputCtrl(document.form.WLANConfig11a_WEPKey2, flag);
1181      inputCtrl(document.form.WLANConfig11a_WEPKey3, flag);
1182      inputCtrl(document.form.WLANConfig11a_WEPKey4, flag);
1183      inputCtrl(document.form.WLANConfig11a_WEPDefaultKey,  flag);
1184  }
1185  else if (s == "WLANConfig11b")
1186  {
1187      if (document.form.WLANConfig11b_WEPType.value == 'None' || document.form.WLANConfig11b_WEPType.value == 'FromServer')
1188      {
1189         flag = 0;
1190         wep = "";
1191      }
1192      else
1193      {
1194         flag = 1;
1195
1196         if (document.form.WLANConfig11b_WEPType.value == "64bits")
1197      	    wep = "0000000000";
1198      	 else  if (document.form.WLANConfig11b_WEPType.value == "128bits")
1199      	    wep = "00000000000000000000000000";
1200      	 else
1201      	    wep = "00000000000000000000000000000000";
1202      }
1203
1204      document.form.WLANConfig11b_x_Phrase.value = '';
1205      document.form.WLANConfig11b_WEPKey1.value = wep;
1206      document.form.WLANConfig11b_WEPKey2.value = wep;
1207      document.form.WLANConfig11b_WEPKey3.value = wep;
1208      document.form.WLANConfig11b_WEPKey4.value = wep;
1209
1210      inputCtrl(document.form.WLANConfig11b_x_Phrase,  flag);
1211      inputCtrl(document.form.WLANConfig11b_WEPKey1,  flag);
1212      inputCtrl(document.form.WLANConfig11b_WEPKey2,  flag);
1213      inputCtrl(document.form.WLANConfig11b_WEPKey3,  flag);
1214      inputCtrl(document.form.WLANConfig11b_WEPKey4,  flag);
1215      inputCtrl(document.form.WLANConfig11b_WEPDefaultKey,  flag);
1216  }
1217  else
1218  {
1219 	return false;
1220  }
1221
1222  return true;
1223}
1224
1225function change_internet_access()
1226{
1227    if (!document.form.FirewallConfig_LanWanActiveSVC_0.checked &&
1228        !document.form.FirewallConfig_LanWanActiveSVC_1.checked &&
1229        !document.form.FirewallConfig_LanWanActiveSVC_2.checked &&
1230        !document.form.FirewallConfig_LanWanActiveSVC_3.checked &&
1231        !document.form.FirewallConfig_LanWanActiveSVC_4.checked &&
1232        !document.form.FirewallConfig_LanWanActiveSVC_5.checked)
1233    {
1234    	document.form.InternetAccess_img.src = "graph/internet_none.gif";
1235    }
1236    else if (document.form.FirewallConfig_LanWanActiveSVC_0.checked &&
1237        document.form.FirewallConfig_LanWanActiveSVC_1.checked &&
1238        document.form.FirewallConfig_LanWanActiveSVC_2.checked &&
1239        document.form.FirewallConfig_LanWanActiveSVC_3.checked &&
1240        document.form.FirewallConfig_LanWanActiveSVC_4.checked &&
1241        document.form.FirewallConfig_LanWanActiveSVC_5.checked &&
1242        document.form.FirewallConfig_LanWanActiveDate_Sun.checked &&
1243        document.form.FirewallConfig_LanWanActiveDate_Mon.checked &&
1244        document.form.FirewallConfig_LanWanActiveDate_Tue.checked &&
1245        document.form.FirewallConfig_LanWanActiveDate_Wed.checked &&
1246        document.form.FirewallConfig_LanWanActiveDate_Thu.checked &&
1247        document.form.FirewallConfig_LanWanActiveDate_Fri.checked &&
1248        document.form.FirewallConfig_LanWanActiveDate_Sun.checked &&
1249        document.form.FirewallConfig_LanWanActiveTime_starthour.value == "00" &&
1250        document.form.FirewallConfig_LanWanActiveTime_startmin.value == "00" &&
1251        document.form.FirewallConfig_LanWanActiveTime_endhour.value == "23" &&
1252        document.form.FirewallConfig_LanWanActiveTime_endmin.value == "59"
1253        )
1254    {
1255    	document.form.InternetAccess_img.src = "graph/internet_all.gif";
1256    }
1257    else
1258    {
1259    	document.form.InternetAccess_img.src = "graph/internet_some.gif";
1260    }
1261}
1262
1263