dprofiles=new Array()
div_id=new Array(
"_0x20" //Static IP Address
,"_0x00" //Dynamic IP Address
,"_0x40,ses0"      //PPP over Ethernet/Multisession PPPoE
,"_0x60"      //PPTP
,"_0x80"      //L2TP
,"_0x10"      //3G
,"_0x11"      //iBurst
,"_0x50,ipmode,ipmode_ipoa,adslitems"      //PPPoA
,"_0x02" //Bridge WAN type
,"_0x90"      //Dial-up Network
,"")
div_ses=new Array(
"ses0,masel0",
"ses1,masel1",
"ses2,masel2",
"ses3,masel3",
"ses4,masel4",
"ses5,masel5",
"ex"
)
selary=new Array(
"N00042000",
"N00042001",
"N00042002",
"N00042003",
"N00042004",
"N00042005",
""
)
pppoepw=new Array(
"S00040200",
"S00040201",
"S00040202",
"S00040203",
"S00040204",
"S00040205",
""
)
function setPW(ff)
{
var mult_type=ff.wit11.value;
var ip_type=ff.s_ip_type.value;
pptp_pw=document.getElementById('pptppw');
if(pptp_pw.value=="*****") { pptp_pw.name="ignorethis"};
l2tp_pw=document.getElementById('l2tppw');
if(l2tp_pw.value=="*****") { l2tp_pw.name="ignorethis"};
wtpppoe_pw=document.getElementById('pppoepw');
if(wtpppoe_pw.value=="*****") { wtpppoe_pw.name="ignorethis"};
for(fi=0;fi<ff.length;fi++)
{
if(ff.elements[fi].name.substr(0,15)=="pppoe_ml_master")
{ff.elements[fi].disabled=true;}
}
wtpppoa_pw=document.getElementById('pppoapw');
if(wtpppoa_pw.value=="*****") { wtpppoa_pw.name="ignorethis"};
wt3g_pw=document.getElementById('w3gpw');
if(wt3g_pw.value=="*****") { wt3g_pw.name="ignorethis"};
wtiburst_pw=document.getElementById('iburstpw');
if(wtiburst_pw.value=="*****") { wtiburst_pw.name="ignorethis"};
if(ff.Nwanx.value==0){
if(mult_type=="0x40"&&ip_type!=0){
document.getElementById('ipv6_user').value=document.getElementById('pppoe_user').value;
if(wtpppoe_pw.value=="*****"){ document.getElementById('ipv6pw').name="ignorethis";}
else{ document.getElementById('ipv6pw').value=wtpppoe_pw.value;}
document.getElementById('ipv6_service').value=document.getElementById('pppoe_service').value;
if(ip_type==2){ document.getElementById('ipv6_dualstack').value=1; }
else { document.getElementById('ipv6_dualstack').value=0; }
document.getElementById('ipv6_type').disabled=false;
document.getElementById('ipv6_type').value="0x0300";
document.getElementById('ipv6_enable').disabled=false;
document.getElementById('ipv6_ct').disabled=false;
}else{
document.getElementById('ipv6_user').disabled=true;
document.getElementById('ipv6pw').disabled=true;
document.getElementById('ipv6_service').disabled=true;
document.getElementById('ipv6_dualstack').value=0;
document.getElementById('ipv6_ct').disabled=true;
if(mult_type=="0x60"||mult_type=="0x80"){
document.getElementById('ipv6_enable').value=0;
document.getElementById('ipv6_enable').disabled=false;
document.getElementById('ipv6_alter').disabled=false;
}
}
}
if (mult_type=="0x20" || mult_type=="0x52"){
if (document.getElementById("t_static_ip_0").value==""){
alert(GetElmCont('wiz22_0','WAN IP Address is invalid!'));
return false;
}
} else if (mult_type=="0x40"){
if (document.getElementById("pppoe_user").value==""){
alert(GetElmCont('wiz22_0','PPPoE Account is invalid!'));
return false;
}
if (document.getElementById("pppoepw").value==""){
alert(GetElmCont('wiz22_0','PPPoE Password is invalid!'));
return false;
}
} else if (mult_type=="0x50"){
if (document.getElementById("pppoa_user").value==""){
alert(GetElmCont('wiz22_0','PPPoA Account is invalid!'));
return false;
}
if (document.getElementById("pppoapw").value==""){
alert(GetElmCont('wiz22_0','PPPoA Password is invalid!'));
return false;
}
} else if (mult_type=="0x60"){
if (document.getElementById("s_pptp_phase1_type_0").value==1&&document.getElementById("t_pptp_ip_0").value==""){
alert(GetElmCont('wiz22_0','WAN IP Address is invalid!'));
return false;
}
if (document.getElementById("t_pptp_pns_server_0").value==""){
alert(GetElmCont('wiz22_0','Server IP Address / Name is invalid!'));
return false;
}
if (document.getElementById("t_pptp_user_0").value==""){
alert(GetElmCont('wiz22_0','PPTP Account is invalid!'));
return false;
}
if (document.getElementById("pptppw").value==""){
alert(GetElmCont('wiz22_0','PPTP Password is invalid!'));
return false;
}
} else if (mult_type=="0x80"){
if (document.getElementById("s_l2tp_phase1_type_0").value==1&&document.getElementById("t_l2tp_ip_0").value==""){
alert(GetElmCont('wiz22_0','WAN IP Address is invalid!'));
return false;
}
if (document.getElementById("t_l2tp_lns_server_0").value==""){
alert(GetElmCont('wiz22_0','Server IP Address / Name is invalid!'));
return false;
}
if (document.getElementById("t_l2tp_user_0").value==""){
alert(GetElmCont('wiz22_0','L2TP Account is invalid!'));
return false;
}
if (document.getElementById("l2tppw").value==""){
alert(GetElmCont('wiz22_0','L2TP Password is invalid!'));
return false;
}
}
if(ff.wit11.value=="0x40"&&document.getElementById("_ipdu").style.display=="")
return chkipv6(ff);
else return true;
}
function chkipv6(fm)
{
if (ipv6_dualstackv!=document.getElementById('ipv6_dualstack').value){
document.getElementById('wanset_alter').name="N80010009";
document.getElementById('wanset_alter').value=1;
}
ipals=GetElmCont("prim_0","Would you like to configure IPv6? Please click OK to proceed.")
if(fm.s_ip_type.value!=0){
if (confirm(ipals)){
fm.action="/ipv6.htm"
}else{
return true;
}
}
}
function DisplayMenu(idd,fromAry)
{
ary=new Array();
ary=ary.concat((arguments.length>1)?fromAry:div_id);
hideAllDiv(ary)
hideAllDiv(div_ses)
if(arguments.length>1){
if(ary[idd].indexOf(',')==-1)
{
dwt=ary[idd]
}
else
{
dis=ary[idd].split(',')
dwt=dis[0]
for(d1=1;d1<dis.length;d1++)
{ swDiv(dis[d1],1);}
}
swDiv(dwt,1)
} else {
swDiv("_"+idd,true)
if(idd=="0x50"){dielm("s_0x40","e_0x40",false);dielm("s_0x50","e_0x50",true);}
else {dielm("s_0x50","e_0x50",false);dielm("s_0x40","e_0x40",true);}
if(idd=="0x40")swDiv("ses0",true)
}
}
function diid(divs,tf)
{
ddiv=document.getElementById(divs)
if(ddiv!=null)
{
ddiv.disabled=!tf;
ddiv.style.display=(tf)?'':'none';
}
}
function diids(divs,tf)
{
ddiv=document.getElementById(divs)
if(ddiv!=null)
{
ddiv.disabled=!tf;
}
}
function chgSession(selse,fms,ix)
{
selseix=selse.selectedIndex
selsev=selse.value
DisplayMenu(selseix,div_ses)
eval("fms.pppoe_ml_master_"+selseix+".selectedIndex="+selseix)
eval("fms."+selary[selseix]+".value='"+selsev+"'")
fms.Ssession.value=selseix
if(arguments.length < 3) saveResult()
}
function dielm(estart,eend,sw)
{
ffm=document.forms[0]
flag=sw;
cc=0;
for(o=0;o<ffm.length;o++)
{
if(ffm.elements[o]==document.getElementById(estart))
{flag=!sw;cc=1;}
if(ffm.elements[o]==document.getElementById(eend))
{flag=sw;cc=2;}
if((cc>0)&&(cc<3))ffm.elements[o].disabled=flag
if(cc==2)break;
}
}
function chgwi()
{
intv="99";
if(intv>=0 && intv==99){//Ethernet
swids('wit1',true);
diids('wit11',true);
swids('show_alias',true);//avril 201211-for Wan IP Alias
DisplayMenu(document.getElementById('wit11').value);
}
}
function chk3gautobk(v)
{
/*
�Y�OFailover�ɷ|�N
(1)Connection Control���áA�ȼg��Auto
(2)Network Monitoring disable�A�]��failover�ͮĻݭnNetwork Monitoring Enable
�bConnection Control�U�Կ���Auto�ɡA�|�NNetwork Monitoring Enable
*/
lwv=document.getElementById('wit11') //Ethernet
autobk3gd=false;
hid_idletime=false;
if(lwv.value=="0x00"){ //Dynamic
if(v==1){
document.getElementById('h_wanchk').value=0;
document.getElementById('c_wanchk').checked=false;
vwan_switch('c_wanchk',false,'fover')
}
swid('dhcp_idletime',document.getElementById('ct_0x00').value!=1);
}
else if(lwv.value=="0x20"){//Static
autobk3gd=true;
}
else if(lwv.value=="0x40"){ //PPPoE
if(v==1){
document.getElementById('h_wanchk').value=0;
document.getElementById('c_wanchk').checked=false;
vwan_switch('c_wanchk',false,'fover')
}
swid('pppoe_idletime',document.getElementById('ct_0x40').value!=1);
}
else if(lwv.value=="0x60"){ //PPTP
if(v==1){
document.getElementById('h_wanchk').value=0;
document.getElementById('c_wanchk').checked=false;
vwan_switch('c_wanchk',false,'fover')
}
swid('pptp_idletime',document.getElementById('ct_0x60').value!=1);
}
else if(lwv.value=="0x80"){ //L2TP
if(v==1){
document.getElementById('h_wanchk').value=0;
document.getElementById('c_wanchk').checked=false;
vwan_switch('c_wanchk',false,'fover')
}
swid('l2tp_idletime',document.getElementById('ct_0x80').value!=1);
}
}
function setselix(oid,ix)
{
div=document.getElementById(oid)
if(div!=null)div.selectedIndex=ix
}
function undoact()
{
divwi=document.getElementById('wi')
if(divwi!=null) chgwi(divwi)
showtsel(cseled)
setselix('countrysel',cseled)
setselix('telecomsel',tseled)
setselix('networksel',nseled)
}
/*  CTA remove 3g keep alive
function chk3gkeepalive(chk)
{
ff=document.forms[0];//chk.form
if(arguments.length==0)chkv="";
else chkv=chk.value;
pingip=document.getElementById('pingip')
pingival=document.getElementById('pingival')
lcpival=document.getElementById('lcpival')
lcptime=document.getElementById('lcptime')
if(pingip!=null)pingip.disabled=(chkv!="1")
if(pingival!=null)pingival.disabled=(chkv!="1")
if(lcpival!=null)lcpival.disabled=(chkv!="2")
if(lcptime!=null)lcptime.disabled=(chkv!="2")
}
*/
function chg3gcnttype(cntype)
{
fm=cntype.form
fm.N001E000C.disabled=(cntype.value=="1")
diid('maxitime',(cntype.value!="1"))
}
function swipmode(sw)
{
dyn=(arguments.length>1)?(arguments[1]):(sw.selectedIndex==1)
swid('_0x20',!dyn)  //Static IP
swid('_0x00',dyn)   //Dynamic IP
swid('adslitems',true)
document.getElementById('wit01').options[0].value=sw.value
document.getElementById('localwth').value=sw.value
}
function swip_ppp(){
fs=document.forms[0];
ppv=(fs.N00050E00.value==0)?"none":""
l2v=(fs.N00060E00.value==0)?"none":""
document.getElementById('pp1').style.display=document.getElementById('pp2').style.display=document.getElementById('pp3').style.display=ppv
document.getElementById('l21').style.display=document.getElementById('l22').style.display=document.getElementById('l23').style.display=l2v
}
function chg_pppoecc(t){
if(t.value != 2){
document.getElementById('pppoe_cc').style.display=""
if (document.getElementById('ct_0x40').value!=1)
document.getElementById('pppoe_idletime').style.display="none"
}
else{
document.getElementById('pppoe_cc').style.display="none"
if (document.getElementById('ct_0x40').value!=1)
document.getElementById('pppoe_idletime').style.display=""
}
}
function chg_pppoacc(t){
if(t.checked){
document.getElementById('pppoa_cc').style.display="none"
if (document.getElementById('ct_0x50').value!=1)
document.getElementById('pppoa_idletime').style.display="none"
}
else{
document.getElementById('pppoa_cc').style.display=""
if (document.getElementById('ct_0x50').value!=1)
document.getElementById('pppoa_idletime').style.display=""
}
}
function setigmp(s){
igmpface="";
if(s.selectedIndex=="0"){ //Disable
document.getElementById('igmp_proxy').style.display='none';
if(igmpface=="99"){
document.getElementById('igmp_version').value='';
document.getElementById('igmp_snoop').value=0;
document.getElementById('igmp_interface').value='';
document.getElementById('igmp_enable').value='';
}else{
document.getElementById('igmp_version').disabled=true;
document.getElementById('igmp_snoop').disabled=true;
document.getElementById('igmp_interface').disabled=true;
document.getElementById('igmp_enable').disabled=true;
}
}else{
document.getElementById('igmp_proxy').style.display='';
document.getElementById('igmp_version').value=s.value;
document.getElementById('igmp_snoop').value=1;
document.getElementById('igmp_interface').value=99;
document.getElementById('igmp_version').disabled=false;
document.getElementById('igmp_snoop').disabled=false;
document.getElementById('igmp_interface').disabled=false;
document.getElementById('igmp_enable').disabled=false;
}
}
function dis_wanip2nd()
{
document.getElementById('wanip_2nd').disabled=(document.forms[0].N00010220.value==0)?true:false
}
function set_target(){
c_wanchk=document.getElementById("c_wanchk").checked;
for(i=1;i<3;i++){
document.getElementById("t_fover_ping"+i).style.display=(document.getElementById("s_target"+i).value==4)?"":"none";
document.getElementById("t_fover_ping"+i).disabled=(document.getElementById("s_target"+i).value==4&&c_wanchk)?false:true;
}
}
function chk_target(){
icmp_enable=document.getElementById("r_fover_chk_1").checked
clear_valchk(document.getElementById("t_fover_ping1"));
clear_valchk(document.getElementById("t_fover_ping2"));
if(icmp_enable){
if(document.getElementById("s_target1").value==4)  showmsg(document.getElementById("t_fover_ping1"),(document.getElementById("t_fover_ping1").value!=''&&chkI(document.getElementById("t_fover_ping1"),'l')));
if(document.getElementById("s_target2").value==4)  showmsg(document.getElementById("t_fover_ping2"),(document.getElementById("t_fover_ping2").value!=''&&chkI(document.getElementById("t_fover_ping2"),'l')));
}else{
if(document.getElementById("s_target1").value==4)  showmsg(document.getElementById("t_fover_ping1"),(document.getElementById("t_fover_ping1").value!=''));
if(document.getElementById("s_target2").value==4)  showmsg(document.getElementById("t_fover_ping2"),(document.getElementById("t_fover_ping2").value!=''));
}
}
function chgsport(num){
l2tp_sportv=document.getElementById("s_l2tp_sport").value;
if(!num){
document.getElementById("t_l2tp_sport").value=(l2tp_sportv!=1)?l2tp_sportv:0;
document.getElementById("h_l2tp_sport").value=(l2tp_sportv!=1)?l2tp_sportv:0;
}
document.getElementById("t_l2tp_sport").disabled=(l2tp_sportv!=1)?true:false;
document.getElementById("h_l2tp_sport").disabled=(l2tp_sportv!=1)?false:true;
}
ALL_INDEXV=new Array(
"99", //0
"0", //1
"")


function swWANx(wanx)
{
/*	
_Nwanif=(ALL_INDEXV[wanx]==99)?0:(ALL_INDEXV[wanx]-1);
_pvc="";
if(_Nwanif==5) _pvc=0; if(_Nwanif==6)  _pvc=16; if(_Nwanif==7)  _pvc=32;  if(_Nwanif==8)  _pvc=48;
if(_Nwanif==9) _pvc=64; if(_Nwanif==10) _pvc=80; if(_Nwanif==11) _pvc=96; if(_Nwanif==12) _pvc=112;
if (ALL_INDEXV[wanx]==99){ //�O�_��Local-Ethernet
go_url="prim.htm?Nwanif=0&Nwanx="+wanx+"&Nsw=1";
}else if (ALL_INDEXV[wanx]==14&&swm_dualsim1==true){  //�N��3G1+Dualsim
go_url="primx_sim.htm?Nwanif="+_Nwanif+"&Nwanx="+wanx+"&Npvc="+_pvc+"&Nsw=1";
}else if (ALL_INDEXV[wanx]==15&&swm_phy_3g_4g2>0&&swm_dualsim2==true){  //�N��3G2+Dualsim
go_url="primx_sim.htm?Nwanif="+_Nwanif+"&Nwanx="+wanx+"&Npvc="+_pvc+"&Nsw=1";
}else if (ALL_INDEXV[wanx]==16||(ALL_INDEXV[wanx]==15&&swm_phy_wisp2>0)){  //�N��WISP
go_url="primx_wisp.htm?Nwanif="+_Nwanif+"&Nwanx="+wanx+"&Npvc="+_pvc+"&Nsw=1";
}
else{
go_url="primx.htm?Nwanif="+_Nwanif+"&Nwanx="+wanx+"&Npvc="+_pvc+"&Nsw=1";
}
*/
go_url="primx_sim.htm";
setTimeout("GURL('"+go_url+"')",500);
}


var fover=[];
fover.push(GetElmCont("wary_0","Disable"))
fover.push(GetElmCont("phy_0","Always on"))
fover.push(GetElmCont("phy_0","Failover"))
fover.push(GetElmCont("phy_0","Failover"))  //for seamless failover, value=3
var wantype = [];
wantype["0x00000000"] = GetElmCont("prim_0","Dynamic IP");
wantype["0x00000002"] = GetElmCont("wiz20_0","RFC 1483 Bridged");
wantype["0x00000010"] = GetElmCont("sta_0","3G/4G");
wantype["0x00000013"] = GetElmCont("wiz20_0","Uplink");
wantype["0x00000020"] = GetElmCont("sta_0","Static IP");
wantype["0x00000030"] = GetElmCont("wiz20_0","Ethernet over ATM with NAT");
wantype["0x00000031"] = GetElmCont("wiz20_0","Ethernet over ATM with NAT");
wantype["0x00000040"] = GetElmCont("sta_0","PPPoE");
wantype["0x00000043"] = GetElmCont("wiz20_0","PPPoE (ADSL)");
wantype["0x00000050"] = GetElmCont("wiz20_0","PPP over ATM");
wantype["0x00000051"] = GetElmCont("wiz20_0","IP over ATM");
wantype["0x00000052"] = GetElmCont("wiz20_0","IP over ATM");
wantype["0x00000060"] = GetElmCont("sta_0","PPTP");
wantype["0x00000080"] = GetElmCont("sta_0","L2TP");
wantype["0x00000090"] = GetElmCont("wiz20_0","Dial-up Network");
function swWanList()
{
var sw_phy="";
var sw_faover="";
var sw_wtype="";
var nwansckd ="";
var wtype="";
var w1=0;
var w2=0;
var div = document.getElementById("d_wan_list");
table_str = "<table width=100% border=0 align=center cellpadding=0 cellspacing=0 class='staball'>"
table_str += "<tr>";
table_str += "<th width='14%'><span id='_phy_0'>Interface Name</span></th>";
table_str += "<th width='15%'><span id='_sta_0'>Physical Interface</span></th>";
table_str += "<th width='15%'><span id='_phy_0'>Operation Mode</span></th>";
table_str += "<th width='16%'><span id='_sta_0'>WAN Type</span></th>";
table_str += "<th width='5%'><span id='_sta_0'>Action</span></th>";
table_str += "</tr>";
wiface="99";
sw_phy=swName_idx[wiface];
sw_faover=fover[1];
wtype="0xFFFFFFFF";
if(wtype=="0xFFFFFFFF")  wtype="0x00000000";
sw_wtype=wantype[wtype];
table_str += "<tr><td>WAN-1</td>";
table_str += "<td><div >3G/4G</div>";
table_str += "</td>";
table_str += "<td><div>"+sw_faover+"&nbsp;</div></td>";
table_str += "<td><div>3G/4G</td>";
isEidt=(sw_wtype==" - ")?"disabled":"";
table_str += "<td><input id='_wary_0' type=button value='Edit' onclick=\"swWANx('0')\" "+isEidt+"></td></tr>"
sw_phy=" - ";
sw_faover=GetElmCont("wary_0","Disable")
sw_wtype=" - ";
table_str += "<tr><td>WAN-2</td>";
table_str += "<td><div >"+sw_phy+"&nbsp;</div>";
table_str += "</td>";
table_str += "<td><div>"+sw_faover+"&nbsp;</div></td>";
table_str += "<td><div>"+sw_wtype+"&nbsp;</td>";
isEidt=(sw_wtype==" - ")?"disabled":"";
table_str += "<td><input id='_wary_0' type=button value='Edit' onclick=\"swWANx('1')\" "+isEidt+"></td></tr>"
table_str += "</table>"
div.innerHTML = table_str;
}
manuals=new Array("cou","tel","gne","apn","din","acpw","auth","dns1","dns2")
function chgprof(objv)
{
for(p=0;p<manuals.length;p++)
{
diid(manuals[p],objv==1)
}
swids('swprofile',true)
}
iclifm(dlprfn)
syslanip="192.168.20.1";
cseled=0;
tseled=0;
nseled=0;
existschedulerule=new Array(
" : "+GetElmCont("prim_0","Add New Schedule"),
"")
function displayschesel()
{
fm=document.forms[0]
sobj=fm.N001E0040
clrsel(sobj,1)
for(k=0;k<existschedulerule.length-1;k++)
{
sches=existschedulerule[k].split(" : ")
stexts=((sches[0]=="")?sches[1]:("("+sches[0]+") "+sches[1]))
pushselopt(sobj,stexts,sches[0])
if(sches[0]=="0")sobj.selectedIndex=k+1
}
}
function setsche(val)
{
schenoid=document.getElementById("scheno")
if(schenoid!=null)
{
schenoid.selectedIndex=findSelectIndex(schenoid,val)
}
}