DHCP_CNT_TYPE=[];
PPPOE_CNT_TYPE=[];
PPTP_CNT_TYPE=[];
L2TP_CNT_TYPE=[];
DHCP_CNT_TYPE.push("N0003500E");
PPPOE_CNT_TYPE.push("N00040912");
PPTP_CNT_TYPE.push("N00050911");
L2TP_CNT_TYPE.push("N00060002");
DHCP_CNT_TYPE.push("N000351D0"); //0
PPPOE_CNT_TYPE.push("N00040940");
PPTP_CNT_TYPE.push("N00050920");
L2TP_CNT_TYPE.push("N00062910");
DHCP_CNT_TYPE.push("N000351D1"); //1
PPPOE_CNT_TYPE.push("N00040941");
PPTP_CNT_TYPE.push("N00050921");
L2TP_CNT_TYPE.push("N00062911");
DHCP_CNT_TYPE.push("N000351D2"); //2
PPPOE_CNT_TYPE.push("N00040942");
PPTP_CNT_TYPE.push("N00050922");
L2TP_CNT_TYPE.push("N00062912");
DHCP_CNT_TYPE.push("N000351D3"); //3
PPPOE_CNT_TYPE.push("N00040943");
PPTP_CNT_TYPE.push("N00050923");
L2TP_CNT_TYPE.push("N00062913");
DHCP_CNT_TYPE.push("N000351D4"); //4
PPPOE_CNT_TYPE.push("N00040944");
PPTP_CNT_TYPE.push("N00050924");
L2TP_CNT_TYPE.push("N00062914");
DHCP_CNT_TYPE.push("N000351D5"); //5
PPPOE_CNT_TYPE.push("N00040945");
PPTP_CNT_TYPE.push("N00050925");
L2TP_CNT_TYPE.push("N00062915");
DHCP_CNT_TYPE.push("N000351D6"); //6
PPPOE_CNT_TYPE.push("N00040946");
PPTP_CNT_TYPE.push("N00050926");
L2TP_CNT_TYPE.push("N00062916");
DHCP_CNT_TYPE.push("N000351D7"); //7
PPPOE_CNT_TYPE.push("N00040947");
PPTP_CNT_TYPE.push("N00050927");
L2TP_CNT_TYPE.push("N00062917");
DHCP_CNT_TYPE.push("N000351D8"); //8
PPPOE_CNT_TYPE.push("N00040948");
PPTP_CNT_TYPE.push("N00050928");
L2TP_CNT_TYPE.push("N00062918");
DHCP_CNT_TYPE.push("N000351D9"); //9
PPPOE_CNT_TYPE.push("N00040949");
PPTP_CNT_TYPE.push("N00050929");
L2TP_CNT_TYPE.push("N00062919");
DHCP_CNT_TYPE.push("N000351DA"); //10
PPPOE_CNT_TYPE.push("N0004094A");
PPTP_CNT_TYPE.push("N0005092A");
L2TP_CNT_TYPE.push("N0006291A");
DHCP_CNT_TYPE.push("N000351DB"); //11
PPPOE_CNT_TYPE.push("N0004094B");
PPTP_CNT_TYPE.push("N0005092B");
L2TP_CNT_TYPE.push("N0006291B");
DHCP_CNT_TYPE.push("N000351DC"); //12
PPPOE_CNT_TYPE.push("N0004094C");
PPTP_CNT_TYPE.push("N0005092C");
L2TP_CNT_TYPE.push("N0006291C");
DHCP_CNT_TYPE.push("N000351DD"); //13
PPPOE_CNT_TYPE.push("N0004094D");
PPTP_CNT_TYPE.push("N0005092D");
L2TP_CNT_TYPE.push("N0006291D");
DHCP_CNT_TYPE.push("N000351DE"); //14
PPPOE_CNT_TYPE.push("N0004094E");
PPTP_CNT_TYPE.push("N0005092E");
L2TP_CNT_TYPE.push("N0006291E");
DHCP_CNT_TYPE.push("N000351DF"); //15
PPPOE_CNT_TYPE.push("N0004094F");
PPTP_CNT_TYPE.push("N0005092F");
L2TP_CNT_TYPE.push("N0006291F");
var selectable1="0";
var selectable2="0";
var wopband1="0";
var wopband2="1";
var csid_wopband1="N00190012";
var csid_wopband2="N00440012";
var csid_wmode1="N00190C00";
var csid_wmode2="N00440C00";
var chkippass=false;
var ippass="N000103FD"
var ippass2="N000103FE"
if((ALL_INDEXV[0]=="14"&&"0"=="1")) chkippass=true;
if((ALL_INDEXV[0]=="15"&&"0"=="1")) chkippass=true;
if(typeof(swm_wan1set)=="undefined"){ swm_wan1set=false; }
use_phy=[] //記錄剩下的WAN的狀態 (1:開啟，可當WAN及被Failover 2:開啟，只能被Failover 3:開啟，只有Always on)
disEdit=false; //若WAN-1為4(只能當主WAN(WAN-1)且其它WAN(WAN-X)不能Edit)將值記成true
function useWAN(){
a=0;
for (i=0;i<phy_all.length;i++){
for (j=0;j<Nwans;j++){
if(phy_allv[i]==ALL_INDEXV[j]||phy_all_type[i]==4){ addphy=false; break;}
else addphy=true;
}
if(addphy){
use_phy[use_phy.length]=phy_all_type[i];
a=a+1;
}
if((phy_allv[i]==ALL_INDEXV[0])&&(phy_all_type[i]==4)){ disEdit=true; break;}
}
return a
}
swm_line_speed=false;  //(CTA H31 reomve Line Speed)
function sw_wanlist(){
var div = document.getElementById("sw_wan_list");
var table_str = "";
table_str += "<table width=100% border=0 align=center cellpadding=0 cellspacing=0 class=staball>";
table_str += "<tr>";
table_str += "<th width='15%'><span id='_1'>Interface Name</span></th>";
table_str += "<th width='15%'><span id='_sta_0'>Physical Interface</span></th>";
table_str += "<th width='15%'><span id='_2'>Operation Mode</span></th>";
if(swm_line_speed) table_str += "<th width='15%'><span id='_3'>Line Speed</span></th>";
table_str += "<th width='5%'><span id='_sta_1'>Action</span></th>";
table_str += "</tr>";
usewanx=useWAN(); //代表剩下可用的Physical Interface數量
var nwansckd ="";
for(i=0;i<Nwans;i++){
listset=LIST_SET[i].split("|")  //listset陣列值，詳細見*3
if(i==0) nwansckd += listset[1];
else nwansckd += "-"+listset[1];
table_str += "<tr><td>WAN-"+(i+1)+"</td>";

if(i==0)
{g="3G/4G";}
else
{g="-";}	

table_str += "<td><div id='interface_w"+(i+1)+"'>"+g+"</div></td>";
table_str += "<td><div id='setting_w"+(i+1)+"'>"+mod[listset[1]]+"&nbsp;</div></td>";
if(swm_line_speed){
ups=WAN_UPV[i];
if(ups!=""){
ups=(WAN_UP_UNITV[i]==0)?ups/1024:ups;
}else ups=0;
downs=WAN_DOWNV[i];
if(downs!=""){
downs=(WAN_DOWN_UNITV[i]==0)?downs/1024:downs;
}else downs=0;
unit_up=(WAN_UP_UNITV[i]==0)?GetElmCont('phy_0',"Mbps"):GetElmCont('phy_0',"Kbps");
unit_down=(WAN_DOWN_UNITV[i]==0)?GetElmCont('phy_0',"Mbps"):GetElmCont('phy_0',"Kbps");
if(listset[0]==" - ")      table_str += "<td><div id='speed_w"+(i+1)+"'>0 ("+GetElmCont('phy_0',"Mbps")+") / 0 ("+GetElmCont('phy_0',"Mbps")+")</div></td>";
else      table_str += "<td><div id='speed_w"+(i+1)+"'>"+ ups + " ("+unit_up+") / " + downs +" ("+unit_down+")</div></td>";
}
if(listset[1]!=2){Nmonitoring=Nmonitoring+1}
listset1=LIST_SET[0].split("|")
isEidt="";
if(i!=0&&listset1[0]==" - "&&listset[0]==" - "&&!swm_wan1set)	isEidt="disabled"; //WAN-1如果沒設定將其餘的Edit反白,若可設WAN1 Operation Mode時則沒此限制
else if(usewanx==1&&use_phy[0]==2&&showFailoverWAN(i,false)&&ALL_INDEXV[i]=="0") isEidt="disabled"; //在剩下的WAN為只能被failover時，若無failover的WAN，將Edit反白
else if(usewanx<1&&ALL_INDEXV[i]=="0")	 isEidt="disabled";  //若無WAN可選時，將Edit反白
else if(i!=0&&disEdit)	isEidt="disabled"; //WAN-1為4(只能當主WAN(WAN-1)且其它WAN(WAN-X)不能Edit)
else if(i!=0&&chkippass) isEidt="disabled";
table_str += "<td><input type=button id='_wary_0' value='Edit' onclick='swtab("+i+")' "+isEidt+"></td></tr>";
}
sGURL("hide.htm?S002010F8="+nwansckd);
table_str += "</table>";
div.innerHTML = table_str;
}


function swtab(wanx){
wanx=parseInt(wanx)
f = document.forms[0];
f.Nsw.value = 1;
f.Nwanx.value = wanx;
swNwanx = wanx;
if(ALL_INDEXV[wanx]=="0"||ALL_INDEXV[wanx]==""){
swNwanif = "x";
}else{
swNwanif = (ALL_INDEXV[wanx]=="99")?0:ALL_INDEXV[wanx];
}

var swConfig = document.getElementById("swConfig");
swConfig.innerHTML =GetElmCont('phy_0','Interface Configuration')+" ( "+GetElmCont('wiz_0','WAN')+" - "+(wanx+1)+" )"
var opmode = document.getElementById("opera_item_w1");
mod1.length=0;
mod1.push(new Option(GetElmCont("phy_0","Always on"),"0"),new Option(GetElmCont("phy_0","Failover"),"1"),new Option(GetElmCont("wary_0","Disable"),"2"))
mod2.length=0;
mod2.push(new Option(GetElmCont("phy_0","Failover"),"1"),new Option(GetElmCont("wary_0","Disable"),"2"))
mod3.length=0;
mod3.push(new Option(GetElmCont("phy_0","Always on"),"0"),new Option(GetElmCont("wary_0","Disable"),"2"))
mod4.length=0;
mod4.push(new Option(GetElmCont("phy_0","Failover"),"1"),new Option(GetElmCont("wary_0","Disable"),"2"))
phy_value.length=0;
phy_type.length=0;
showWAN(wanx);
set_wan(wanx);
showFailoverWAN(wanx);
}



function showWAN(wanx){ //顯示可選的Physical Interface
var div = document.getElementById("td_swan");
var select_str = "";

select_str="<select select id='wi_w1'>";
select_str += "<option>Ethernet</option>";
if(wanx==0)
{select_str += "<option>3G/4G</option>";}
select_str += "<option>WiFi Module One</option>";
select_str += "<option>WiFi Module Two</option>";
select_str += "</select>";

/*
select_str += "<select id='wi_w1' onchange=\"swVLAN_TAG('w1',this.value);swMode(this.value);chk_line('chg_face');swobj(this.value)\">";
noFailover=showFailoverWAN(wanx,false);
for (i=0;i<phy_all.length;i++){
for (j=0;j<Nwans;j++){
if((j!=wanx)&&(phy_allv[i]==ALL_INDEXV[j])){ addphy=false; break;}
else if((wanx!=0)&&(phy_all_type[i]==4)){ addphy=false; break;} //只能當主WAN(WAN-1)
else addphy=true;
}
if(noFailover&&(phy_all_type[i]==2)){ addphy=false;} //如果沒可Failover的WAN且只能被Failover時不出現
if(addphy){
select_str += "<option id=_o_w1_"+phy_allv[i]+" value="+phy_allv[i]+">"+phy_all[i]+"</option>";
phy_value.push(phy_allv[i]);
phy_type.push(phy_all_type[i]);
}
}
select_str += "</select>";*/
div.innerHTML = select_str;

if(wanx==0)
{document.getElementById("wi_w1").selectedIndex = "1";}
else
{document.getElementById("wi_w1").selectedIndex = "0";}

}


function set_wan(swNwanx){
f = document.forms[0];
if(ALL_INDEXV[swNwanx]!=""&&ALL_INDEXV[swNwanx]!=0){
listset=LIST_SET[swNwanx].split("|")
swMode(ALL_INDEXV[swNwanx]);
for(k=0;k<document.getElementById("opera_item_w1").length;k++){
if(document.getElementById("opera_item_w1").options[k].value==listset[1]){
document.getElementById("opera_item_w1").value=listset[1];
break;
}
}

//document.getElementById("wi_w1").value=ALL_INDEXV[swNwanx];

/*
ups=WAN_UPV[swNwanx];
if(ups!=""){
ups=(WAN_UP_UNITV[swNwanx]==0)?ups/1024:ups;
}
downs=WAN_DOWNV[swNwanx];
if(downs!=""){
downs=(WAN_DOWN_UNITV[swNwanx]==0)?downs/1024:downs;
}*/


//document.getElementById("t_line_up_w1").value=ups;
//document.getElementById("t_line_down_w1").value=downs;
//document.getElementById("s_line_unit_up").value=(WAN_UP_UNITV[swNwanx]=="")?0:WAN_UP_UNITV[swNwanx];
//document.getElementById("s_line_unit_down").value=(WAN_DOWN_UNITV[swNwanx]=="")?0:WAN_DOWN_UNITV[swNwanx];


/*
if(swNwanif==99||swNwanif<14)	{
document.getElementById("tag_item_w1").checked=(listset[4]==0)?false:true;
document.getElementById("tag_value_w1").value=listset[5];
}else{ //3G VLAN Tag disabled
document.getElementById("tag_item_w1").checked=false;
document.getElementById("tag_value_w1").value=0;
}
document.getElementById("c_seamless").checked=(SEAMLESS_ENABLEV[swNwanif]==1)?true:false;
}else{ //Disabled
var phyv="";
for(i=0;i<phy_type.length;i++){
if(phy_type[i]!=2){
phyv=phy_value[i];
break;
}
}
*/

document.getElementById("wandetail_w1").style.display="";
document.getElementById("swbtn").style.display="";
document.getElementById("swsave").style.display="";

if(phyv=="") phyv=document.getElementById("wi_w1").value;
else document.getElementById("wi_w1").value=phyv;
swMode(phyv);
document.getElementById("opera_item_w1").value=2;
chk_line('chg_face')
swVLAN_TAG('w1',document.getElementById("wi_w1").value);
}
if(swNwanx==0&&!swm_wan1set) document.getElementById("opera_item_w1").value=0;
document.getElementById("opera_item_w1").disabled=(swNwanx==0&&!swm_wan1set)?true:false;
disabled_id();
showalive("w1")
chk_line()
swobj(document.getElementById("wi_w1").value);
//document.getElementById("wandetail_w1").style.display="";
//document.getElementById("swbtn").style.display="";
//document.getElementById("swsave").style.display="";
}



function swobj(idx){
if (idx==14 &&swName_3G1.indexOf("USB")==-1 ){
document.getElementById('tr_antenna').style.display = "";
}else if (idx==15 && swm_phy_3g_4g2>0 && swName_3G2.indexOf("USB")==-1 ){
document.getElementById('tr_antenna').style.display = "";
}else{
document.getElementById('tr_antenna').style.display = "none";
}
document.getElementById('tr_wifiselect').style.display = ((idx==16 && selectable1=="1")||(idx==15 && swm_phy_wisp2>0 && selectable2=="1"))?"":"none";
if(idx==16) document.getElementById("s_wifiselet").value = wopband1;
else if(idx==15 && swm_phy_wisp2>0) document.getElementById("s_wifiselet").value = wopband2;
}
function showFailoverWAN(wanx,swbtn){
var div = document.getElementById("sfover");
var select_str = "";
select_str += "<select id=s_fover_wan>";
wanxinfo=LIST_SET[wanx].split("|")
wanx_failover=(wanxinfo[1]==1)?wanxinfo[2]:"";
var fnm=0;
for (j=0;j<Nwans;j++){
listset=LIST_SET[j].split("|");
sw_fover=(listset[1]!=2)?(wanx_failover==listset[2]||listset[2]==0):false;
set_select=(wanx_failover==listset[2])?"selected":"";
if(wanxinfo[1]==1||wanxinfo[2]==0){
if((j!=wanx)&&sw_fover){
if(swbtn==null){
idv=ALL_INDEXV[j];
select_str += "<option id=_0 value="+idv+" "+set_select+">WAN-"+(j+1)+"</option>";
}
fnm++;
}
}
}
if(fnm==0){ //代表沒有WAN可選，刪除Failover選項
if(swbtn==null){
for(k=0;k<document.getElementById("opera_item_w1").length;k++){
if(document.getElementById("opera_item_w1").options[k].value==1){
document.getElementById("opera_item_w1").options[k]=null;
mod1[1]=null;
mod2[0]=null;
break;
}
}
}
if(swbtn!=null) swbtn=true;
}
select_str += "</select>";
if(swbtn==null) {
div.innerHTML = select_str;
}
if(swbtn!=null&&wanx==0){ swbtn=true;}
if(swbtn!=null) return swbtn;
}
function swMode(phy_value) //用來顯示對應的Operation Mode
{
var addary = null;
listset=LIST_SET[swNwanx].split("|")
for (i=0;i<phy_all.length;i++){
if(swNwanx==1){ addary=eval("mod"+2); break}
if(phy_allv[i]==phy_value){ addary=eval("mod"+phy_all_type[i]); break}
}
opera_value=document.getElementById("opera_item_w1").value;
var chk_v = 0;
document.getElementById("opera_item_w1").length=0;
for(var aa = 0; aa < addary.length; aa++){
document.getElementById("opera_item_w1").options[document.getElementById("opera_item_w1").length] = addary[aa];
}
for(j=0;j<	document.getElementById("opera_item_w1").length;j++){
if(document.getElementById("opera_item_w1")[j].value==opera_value){
document.getElementById("opera_item_w1").selectedIndex=j;
chk_v=1;
break;
}
}
if(chk_v==0) document.getElementById("opera_item_w1").selectedIndex=0;
showalive("w1")
}
function sendvalue(f){
var div_obj =  document.getElementById("d_hidden_element");
var account_str = "";
var del_str = "";
var alter_str = "";
Nwanxinfo=LIST_SET[swNwanx].split("|") //WAN的資訊 同*3-listset
if(document.getElementById("opera_item_w1").value==2){
if(swNwanif!="x"){
del_str += disable_set(f,swNwanx,swNwanif,"all");
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[swNwanif]+"'>";
var alterv=[1,1,1]
alter_str += alter_set(f,swNwanx,swNwanif,alterv);
}
bfover=(Nwanxinfo[2]==99)?0:Nwanxinfo[2];
if(Nwanxinfo[1]==1){ //代表此WAN上次設定為被failover
for(i=0;i<FAILOVER_ENABLE.length-1;i++){
if(FAILOVER_ENABLEV[i]==Nwanxinfo[2]&&i!=bfover){ //等於被failover的值且Physical Interface有改變
del_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[i]+"' value='0'>";
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[i]+"'>";
}
}
}
delfidx=(FAILOVER_ENABLEV[swNwanif]==99)?0:FAILOVER_ENABLEV[swNwanif];
if(Nwanxinfo[1]=="0"&&Nwanxinfo[2]!="0"){
for(i=0;i<ALL_INDEX.length-1;i++){
if((ALL_INDEXV[i]==Nwanxinfo[2])&&(i!=swNwanx)){
delNwanx=i;
break;
}
}
del_str += disable_set(f,delNwanx,delfidx,"all");
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[delfidx]+"'>";
}
} else {
newphy=(document.getElementById("wi_w1").value==99)?0:document.getElementById("wi_w1").value;
if(swNwanif!="x"&&(swNwanif!=newphy)) del_str += disable_set(f,swNwanx,swNwanif,"part");
for (i=0;i<phy_all.length;i++){
if(phy_allv[i]==document.getElementById("wi_w1").value){ wtype=phy_all_default[i];	 break;}
}
wtype=(swNwanif!=newphy)?wtype:ALL_WANTYPEV[swNwanif];
account_str += "<input typt='hidden' name='"+ALL_INDEX[swNwanx]+"' value='"+document.getElementById("wi_w1").value+"'>";
account_str += "<input typt='hidden' name='"+ALL_ENABLE[newphy]+"' value='1'>";
account_str += "<input typt='hidden' name='"+ALL_WANTYPE[newphy]+"' value='"+wtype+"'>";
if(newphy==14){
account_str += "<input typt='hidden' name='"+MAPPING_INDEX[newphy]+"' value='1'>";
if(name1=="USB"&&usb_port_enable_arr[support1_index]=="2"){
alert(GetElmCont('phy_0',"USB Storage Mode is enabled!"));
return false;
}
}
if(newphy==15 && swm_phy_3g_4g2>0){
account_str +="<input typt='hidden' name='"+MAPPING_INDEX[newphy]+"' value='2'>";
if(name2=="USB"&&usb_port_enable_arr[support2_index]=="2"){
alert(GetElmCont('phy_0',"USB Storage Mode is enabled!"));
return false;
}
}
if(newphy==16||(newphy==15 && swm_phy_wisp2>0)){
var module_num=1;
if(newphy==15) module_num=2;
var alterv=[0,0,0];
var csid_wband = eval("csid_wopband"+module_num);
var csid_wmode = eval("csid_wmode"+module_num);
if(eval("selectable"+module_num) == "1"){  //supportable
if(eval("wopband"+module_num) != document.getElementById("s_wifiselet").value){
account_str += "<input typt='hidden' name='"+csid_wband+"' value='"+document.getElementById("s_wifiselet").value+"'>";
alterv=[1,1,0];
wmode_value=(document.getElementById("s_wifiselet").value==0)?9:14;
account_str += "<input typt='hidden' name='"+csid_wmode+"' value='"+wmode_value+"'>";
}
}
var set_arr=eval("WIFISET"+module_num);
var setv_arr=eval("WIFISET"+module_num+"V");
account_str += "<input typt='hidden' name='"+set_arr[0]+"' value='1'>";
account_str += "<input typt='hidden' name='"+set_arr[1]+"' value='1'>";
account_str += "<input typt='hidden' name='"+set_arr[2]+"' value='8'>";
if(setv_arr[2]!="8"){
alterv=[1,1,1];
}
alter_str += alter_set(f,swNwanx,newphy,alterv);
}
if(newphy==6)
account_str += "<input typt='hidden' name='N00410101' value='1'>";
bfover=(Nwanxinfo[2]==99)?0:Nwanxinfo[2];
setf=(document.getElementById("s_fover_wan").value==99)?0:document.getElementById("s_fover_wan").value;
seamless_enable=(document.getElementById("c_seamless").checked)?1:0;
if(document.getElementById("opera_item_w1").value==0){//Always on
if(Nwanxinfo[1]==0&&Nwanxinfo[2]!=0){ //Always on (have failover) -> Always on
account_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[newphy]+"' value='"+FAILOVER_ENABLEV[swNwanif]+"'>";
}
if(Nwanxinfo[1]==1){
if(Nwanxinfo[1]==1){ //代表此WAN上次設定為被failover
for(i=0;i<FAILOVER_ENABLE.length-1;i++){
if(FAILOVER_ENABLEV[i]==Nwanxinfo[2]){ //等於被failover的值
del_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[i]+"' value='0'>";
}
}
}
del_str += "<input typt='hidden' name='"+SEAMLESS_ENABLE[bfover]+"' value='0'>";
}
}
if(document.getElementById("opera_item_w1").value==1){ //Failover
if(Nwanxinfo[1]==1){ //代表此WAN上次設定為被failover
for(i=0;i<FAILOVER_ENABLE.length-1;i++){
if(FAILOVER_ENABLEV[i]==Nwanxinfo[2]&&i!=bfover){ //等於被failover的值且Physical Interface有改變
del_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[i]+"' value='0'>";
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[i]+"'>";
}
}
}
account_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[newphy]+"' value='"+document.getElementById("wi_w1").value+"'>";
account_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[setf]+"' value='"+document.getElementById("wi_w1").value+"'>";
account_str += "<input typt='hidden' name='"+SEAMLESS_ENABLE[newphy]+"' value='"+seamless_enable+"'>";
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[setf]+"'>";
account_str += setAuto(f,newphy,wtype);
account_str += setAuto(f,document.getElementById("s_fover_wan").value,ALL_WANTYPEV[setf]);
}
if(swm_line_speed){
line_unit_upv=document.getElementById("s_line_unit_up").value;
line_unit_downv=document.getElementById("s_line_unit_down").value;
use_up_chg=(line_unit_upv==0)?1024:1
use_down_chg=(line_unit_downv==0)?1024:1
line_up=document.getElementById("t_line_up_w1").value;
line_up=(line_up!="")?line_up*use_up_chg:"";
line_down=document.getElementById("t_line_down_w1").value;
line_down=(line_down!="")?line_down*use_down_chg:"";
if(line_up==""||line_down=="") {
alert(GetElmCont('phy_0','Line Speed can not be empty.'))
return false;
}
account_str += "<input typt='text' name='"+WAN_UP_UNIT[swNwanx]+"' value='"+line_unit_upv+"'>";
account_str += "<input typt='text' name='"+WAN_DOWN_UNIT[swNwanx]+"' value='"+line_unit_downv+"'>";
account_str += "<input typt='text' name='"+WAN_UP[swNwanx]+"' value='"+line_up+"'>";
account_str += "<input typt='text' name='"+WAN_DOWN[swNwanx]+"' value='"+line_down+"'>";
}
if(swm_vlan_tag&&newphy<14){
vtag=(document.getElementById("tag_item_w1").checked)?1:0;
account_str += "<input typt='hidden' name='"+VLAN_TAG[newphy]+"' value='"+vtag+"'>";
if(newphy!=6){
for (i=0;i<VLAN_WAN_VIDV.length;i++){
if(document.getElementById("tag_item_w1").checked){
if((WAN_PVID[newphy]!=VLAN_WAN_VID[i])&&(document.getElementById("tag_value_w1").value==VLAN_WAN_VIDV[i])){
alert(GetElmCont('phy_0','This vid has already been used by vlan bridge WAN VID, Please use another vid.'))
return false;
}
}
}
}
if(document.getElementById("tag_item_w1").checked)
account_str += "<input typt='hidden' name='"+WAN_PVID[newphy]+"' value='"+document.getElementById("tag_value_w1").value+"'>";
}
if((swNwanif=="x"&&Nmonitoring==1)||(Nmonitoring>1)){
account_str += "<input typt='hidden' name='"+WANCHK_ENABLE[newphy]+"' value='1'>";
for(i=0;i<Nwans;i++){
if(ALL_INDEXV[i]!="0"&&Nmonitoring>0&&i!=swNwanx){
wanchk_idx=(ALL_INDEXV[i]==99)?0:ALL_INDEXV[i];
if(WANCHK_ENABLEV[wanchk_idx]!="1")
account_str += "<input typt='hidden' name='"+WANCHK_ENABLE[wanchk_idx]+"' value='1'>";
}
}
}
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[newphy]+"'>";
if(swNwanif!="x"&&(swNwanif!=newphy)){
alter_str += "<input typt='hidden' name='_cce' value='"+WAN_ALTERED[swNwanif]+"'>";
var alterv=[1,1,1];
if((swNwanif==16 && newphy==15 && swm_phy_wisp2>0)||(newphy==16 && swNwanif==15 && swm_phy_wisp2>0)) {
alterv=[0,0,0];
}else{
alter_str += alter_set(f,swNwanx,swNwanif,alterv);
}
}
}
div_obj.innerHTML = del_str+account_str+alter_str;
if(document.getElementById("wi_w1").value==15&&parseInt("14")==14){
var wifi_module2 = document.getElementById("wifi_module2");
wifi_module2.disabled = false;
wifi_module2.value = 8;
}
var ipv6_con_type = document.getElementById("_wt_");
if(document.getElementById("wi_w1").value==99){
var wan_type_v = "0";
if(wan_type_v == 32){// Static IP
ipv6_con_type.disabled = false;
ipv6_con_type.value = "0x0100";
}else if(wan_type_v == 0){// Dynamic IP
ipv6_con_type.disabled = false;
ipv6_con_type.value = "0x0200";
}else if(wan_type_v == 64){// PPPoE
ipv6_con_type.disabled = false;
ipv6_con_type.value = "0x0300";
}
}else if(document.getElementById("wi_w1").value==14){
ipv6_con_type.disabled = false;
ipv6_con_type.value = "0x0200";
}
return true;
}
function disable_set(f,Nwanx,idx,types){
var del_str = "";
if(types=="all") del_str += "<input typt='hidden' name='"+ALL_INDEX[Nwanx]+"' value='0'>";
del_str += "<input typt='hidden' name='"+ALL_ENABLE[idx]+"' value='0'>";
del_str += "<input typt='hidden' name='"+ALL_WANTYPE[idx]+"' value='0'>";
del_str += "<input typt='hidden' name='"+FAILOVER_ENABLE[idx]+"' value='0'>";
del_str += "<input typt='hidden' name='"+SEAMLESS_ENABLE[idx]+"' value='0'>";
if(types=="all") del_str += "<input typt='text' name='"+WAN_UP_UNIT[Nwanx]+"' value='0'>";
if(types=="all") del_str += "<input typt='text' name='"+WAN_DOWN_UNIT[Nwanx]+"' value='0'>";
if(types=="all") del_str += "<input typt='text' name='"+WAN_UP[Nwanx]+"' value=''>";
if(types=="all") del_str += "<input typt='text' name='"+WAN_DOWN[Nwanx]+"' value=''>";
if(idx<14){
del_str += "<input typt='hidden' name='"+VLAN_TAG[idx]+"' value='0'>";
del_str += "<input typt='hidden' name='"+WAN_PVID[idx]+"' value='0'>";
}
del_str += "<input typt='hidden' name='"+WANCHK_ENABLE[idx]+"' value='0'>";
if(idx==6)
del_str += "<input typt='hidden' name='N00410101' value='0'>";
if(idx==14||(idx==15 && swm_phy_3g_4g2>0)){
if(chkippass){
del_str += "<input typt='hidden' name='N000103FD' value='0'>";
del_str += "<input typt='hidden' name='N000103FE]' value='0'>";
del_str += "<input typt='hidden' name='N001E2170' value='0'>";
del_str += "<input typt='hidden' name='N001E2171' value='0'>";
}
}
if(idx==0)
del_str += "<input typt='hidden' name='00900004' value='0'>";
if(idx==16||(idx==15 && swm_phy_wisp2>0)){
var module_num=1;
if(idx==15) module_num=2;
del_str += "<input typt='hidden' name='"+eval("WIFISET"+module_num+"[0]")+"' value='0'>";
del_str += "<input typt='hidden' name='"+eval("WIFISET"+module_num+"[2]")+"' value='0'>";
}
return  del_str
}
function alter_set(f,Nwanx,idx,alterv){
var alter_str = "";
f = document.forms[0];
if(idx==16||(idx==15 && swm_phy_wisp2>0)){
var module_num=1;
if(idx==15) module_num=2;
var alter_arr=eval("WIFIALTER"+module_num)
alter_str+="<input typt='hidden' name='"+alter_arr[0]+"' value='"+alterv[0]+"'>";
alter_str+="<input typt='hidden' name='"+alter_arr[1]+"' value='"+alterv[1]+"'>";
alter_str+="<input typt='hidden' name='"+alter_arr[2]+"' value='"+alterv[2]+"'>";
if(alterv[0]==1||alterv[1]==1||alterv[2]==1) f.Nscanap.value=1;
}
return  alter_str
}
sw_wanlist()
f = document.forms[0];
if(f.Nsw.value == 1){
swtab(f.Nwanx.value)
}