del_test=new Array(
"------ 0:root CA -------",
"[NAME='']|[ISS='']|[VALID='']",
"[NAME='S00750200']|[ISS='S00750B00']|[VALID='S00750C00']",
"------ 1~32:Local Certificates -------",
"[NAME='']|[ISS='']|[VALID='']|[k='0']",
"[NAME='S00750200']|[ISS='S00750B00']|[VALID='S00750C00']|[k='S0']",
"[NAME='']|[ISS='']|[VALID='']|[k='1']",
"[NAME='S00750201']|[ISS='S00750B01']|[VALID='S00750C01']|[k='S1']",
"[NAME='']|[ISS='']|[VALID='']|[k='2']",
"[NAME='S00750202']|[ISS='S00750B02']|[VALID='S00750C02']|[k='S2']",
"------ test -------",
"[NAME='true']|[ISS='true']|[VALID='true']",
"[NAME='true']|[ISS='true']|[VALID='true']",
"------ test2 -------",
""
)
function locateObj2(fobj,offset){
fm=fobj.form
for(var j=0;j<fm.length;j++)
{
if(fm.elements[j]==fobj)break;
}
return (arguments.length==1)?j:eval("fm.elements["+parseInt(j+offset)+"]");
}
function swDivs(divID,divx){
for(p=0;p<arguments.length/2;p++)
{
ww=document.getElementById(arguments[p*2])
if(ww!=null)  ww.disabled = !(arguments[p*2+1])
if(ww!=null)  ww.style.display=(arguments[p*2+1])?'inline':'none';
}
}
function sw_IPSecEncn(obj){
var ck0 = (typeof(obj) != 'object')?obj:obj.value
for(p=1;p<5;p++){
obj0 = eval("document.getElementById('_s_ipsec2_prop"+p+"_enc_0')")
obj0v= obj0.value
for(z=0;z<obj0.length;z++){
if(obj0.options[z].value == 0){
obj0.options[z].disabled = (ck0 == 1)
if((obj0.options[z].disabled)&&(obj0v == obj0.options[z].value)){
obj0.options[z+1].selected = true
}
}
}
}
sw_IPSecAuth(obj)
sw_ikevion(obj)
}
function sw_IPSecAuth(objx){
var ck0 = (typeof(objx) != 'object')?objx:objx.value
var ck1 = 0
if(objx == null){ ck0 = document.getElementById("_s_protocal_0").value }
for(p=1;p<5;p++){
obj0 = eval("document.getElementById('_s_ipsec2_prop"+p+"_auth_0')")
obj1 = eval("document.getElementById('c_ipsec2_prop"+p+"_en_0')")
obj0v= obj0.value
for(z=0;z<obj0.length;z++){
if(obj0.options[z].value == 3){  //Auth = None
obj0.options[z].disabled = ((ck0 == 0)&&(obj1.checked))
if((obj0.options[z].disabled)&&(obj0v == obj0.options[z].value)){
obj0.options[z+1].selected = true
ck1 += 1;
}
}
if(obj0.options[z].value == 4){  //Auth = SHA2-256
obj0.options[z].disabled = (ck0 == 0)
if((obj0.options[z].disabled)&&(obj0v == obj0.options[z].value)){
obj0.options[z-1].selected = true
ck1 += 1;
}
}
}
}
if((ck1 != 0)&&(ck0 == 0)){ alert(GetElmCont("vpn1_0","IPSec Proposal Definition of Authentication has been modified, please confirm again.")) }
}
function sw_ikevion(obj){
/*
obj = Encapsulation Protocol ; AH=0
obj0 = IKE Version ;v1=0;v2=1
obj1 = IKE Proposal Definition-Encryption;Encryption=7
obj2 = PSec Proposal Definition-Encryption;Encryption=7
AH=0 { v2.disabled =t ; obj0.options[0]=t}
(obj0=1)&&(obj1 == 7){ obj1.disabled=t ; obj1.options[0]=t }
(obj0=1)&&(obj2 == 7){ obj2.disabled=t ; obj2.options[0]=t }
*/
var ck0 = (typeof(obj) != 'object')?obj:obj.value
if(obj == null){ ck0 = document.getElementById("_s_protocal_0").value }
var obj0 = document.getElementById('_s_ipsec_tun_ike_ver')
var obj0v= obj0.value
for(z=0;z<obj0.length;z++){  //IKE Version
if(obj0.options[z].value == 1){ // IKE Version =v2
obj0.options[z].disabled = (ck0 == 0)
if((obj0.options[z].disabled)&&(obj0v == obj0.options[z].value)){
obj0.options[0].selected = true
alert(GetElmCont("vpn1_0","IKE Phase of IKE Version has been modified, please confirm again."))
}
for(p=1;p<5;p++){  //IKE Proposal Definition-Encryption
obj1 = eval("document.getElementById('_s_ipsec_prop"+p+"_enc_0')")
obj1v = obj1.value
var int0 = (p==1)?0:int0
for(q=0;q<obj1.length;q++){
if(obj1.options[q].value == 7){ //Aes-auto gray it out
obj1.options[q].disabled = (obj0v == 1)
if((obj1.options[q].disabled)&&(obj1v == obj1.options[q].value)){
obj1.options[0].selected = true;
int0 ++
}
}
}
if((p==4)&&(int0 > 0)){
alert(GetElmCont("vpn1_0","IKE Proposal Definition of Encryption has been modified, please confirm again."))
}
}
for(w=1;w<5;w++){  //PSec Proposal Definition-Encryption
obj2 = eval("document.getElementById('_s_ipsec2_prop"+w+"_enc_0')")
obj2v = obj2.value
var int1 = (w==1)?0:int1
for(e=0;e<obj2.length;e++){
if(obj2.options[e].value == 7){ //Aes-auto gray it out
obj2.options[e].disabled = (obj0v == 1)
if((obj2.options[e].disabled)&&(obj2v == obj2.options[e].value)){
obj2.options[0].selected = true
int1 ++
}
}
}
if((w==4)&&(int1 > 0)){
alert(GetElmCont("vpn1_0","IPSec Proposal Definition of Encryption has been modified, please confirm again."))
}
}
}
}
}
function setMKENCAP(){
hideobj=document.getElementById('MKENCAP')
selobj=document.getElementById('MKENCAP_sel')
authobj=document.getElementById('MKAUTH')
if(selobj.value==1)hideobj.value=1
else hideobj.value=(authobj.value==0)?3:5
}
function chgMKENCAP(sel){
swDivs('encap1',sel.value!=1,'encap01',sel.value!=1,'encap2',sel.value==1,'encap02',sel.value==1)
encap1=document.getElementById('encap1')
chgDES();
}
function chgDES(){
var key_obj = document.getElementById('MK_ENCAP_key_all');
var encryption_value = document.getElementById('encap1').value;
var n = parseInt(encryption_value);
switch (n)
{
case 1:
key_obj.maxLength = 16;
key_obj.size = 20;
break;
case 2:
key_obj.maxLength = 48;
key_obj.size = 50;
break;
case 3:
key_obj.maxLength = 32;
key_obj.size = 40;
break;
case 4:
key_obj.maxLength = 48;
key_obj.size = 50;
break;
case 5:
key_obj.maxLength = 64;
key_obj.size = 60;
break;
}
}
function chg_key_management(value){
/*  �� Key Management
���� IKE+Pre-shared Key �ɷ|����
IKE Phase,IKE Proposal Definition,IPSec Phase,IPSec Proposal Definition
���� Manually �ɷ|����
Manual Proposal
by kent  */
var ike = (value != 1);
var mk = (value == 1);
var gobj0 = document.getElementById("s_ipsec_lid_type_0")
var gobj1 = document.getElementById("s_ipsec_rid_type_0")
var gobj2 = (mk)?document.getElementById("t_ipsec_tun_mk_l_id_value_0"):document.getElementById("_t_ipsec_lid_value_0")
var gobj3 = (mk)?document.getElementById("t_ipsec_tun_mk_r_id_value_0"):document.getElementById("_t_ipsec_rid_value_0")
var gobj4 = document.getElementById("ike_psk")
var gobj5 = document.getElementById("ike_x509")
gobj4.style.display = (value == 0)?"":"none";
document.getElementById("t_preshare_key_0").disabled = (value != 0);
gobj5.style.display = (value == 2)?"":"none";
document.getElementById("s_x509_r_cert").disabled = (value != 2);
document.getElementById("s_x509_l_cert").disabled = (value != 2);
document.getElementById("h_x509_ipsec_cert_en").value = (value != 2)?0:1;
for(i=0;i<gobj0.length;i++)
{
if(mk){
gobj0.options[i].disabled = (gobj0.options[i].value == 3)?false:true
gobj1.options[i].disabled = (gobj0.options[i].value == 3)?false:true
if(gobj0.options[i].value == 3) { gobj0.options[i].selected = true; }
if(gobj1.options[i].value == 3) { gobj1.options[i].selected = true; }
}
else{
gobj0.options[i].disabled = false ;
gobj1.options[i].disabled = false ;
}
}
disable("conf_ike",ike);
disable("protocol_ike",ike);
disable("protocol_mk",mk);
disable("conf_mk",mk);
disable("ike_phase",ike);
disable("ike_proposal_defin",ike);
disable("ipsec_phase",ike);
disable("ipsec_phase_defin",ike);
disable("t_ipsec_tun_mk_l_id_value_0",mk);
disable("t_ipsec_tun_mk_r_id_value_0",mk);
disable("_t_ipsec_lid_value_0",ike);
disable("_t_ipsec_rid_value_0",ike);
disable("manual_proposal",mk);
mchk(gobj2);
mchk(gobj3);
}
function mchk(obj){
var gobj0 = document.getElementById("md")
if(gobj0.value == 1){
obj.maxLength = 4 ;chkN(obj,'o') ;
}
else { obj.maxLength = 63 ; chkS(obj,'b') ;}
}
function disable(id,dis_value){
/*  by kent
id => element id
dis_value => true or false for display   */
document.getElementById(id).style.display = (dis_value)?"":"none";
}
function ck_auth_LR_id(){
var s_lid = document.getElementById("s_ipsec_lid_type_0")
var s_rid = document.getElementById("s_ipsec_rid_type_0")
var t_lid = document.getElementById("_t_ipsec_lid_value_0")
var t_rid = document.getElementById("_t_ipsec_rid_value_0")
if((s_lid.value == 0)&&(chkN(t_lid,'a'))){
clear_valchk_for_undo()
alert(GetElmCont("vpn1_0","Local ID can not be all-digital"))
return false;
}
if((s_rid.value == 0)&&(chkN(t_rid,'a'))){
clear_valchk_for_undo()
alert(GetElmCont("vpn1_0","Remote ID can not be all-digital"))
return false;
}
return true;
}
function chk_save(){
var md_select = document.getElementById("md").value;
var gsipswan = document.getElementById('s_ipsce_tun_wan');
var obj1 = document.getElementById('s_keep_alive');
var obj2 = document.getElementById('h_ipsec_ike_keep_alive_ip');
var ike_chk = new Array("t_tun_name_0","t_ike_r_gateway","t_preshare_key_0");
var alert_message = new Array(GetElmCont("stavpn_0","Tunnel Name"),GetElmCont("wizvpn20_0","Remote Gateway"),GetElmCont("wiz30_0","Preshared Key"));
var mk_chk = new Array("t_tun_name_0","t_mk_r_sumnet_0","t_mk_r_mask_0","t_mk_r_gatway_0","t_mk_outbound_spi_0","t_mk_inbound_spi_0");
var alert_mk_message = new Array(GetElmCont("stavpn_0","Tunnel Name"),GetElmCont("stavpn_0","Remote Subnet"),GetElmCont("wizvpn20_0","Remote Netmask"),GetElmCont("wizvpn20_0","Remote Gateway"),GetElmCont("_0","Outbound SPI"),GetElmCont("_0","Inbound SPI"));
var chk_sta = true;
var alert_str = "";
var tmp_str = "";
var str1 ="";
if(md_select == 0){ //IKE+Pre
for(var a=0;a<ike_chk.length;a++)
{
tmp_str = document.getElementById(ike_chk[a]).value;
if(tmp_str == "")
{//alert("del 274 ike_chk[a]="+ike_chk[a]+", tmp_str="+tmp_str)
chk_sta = false;
alert_str += (alert_str == "")?alert_message[a]:" , "+alert_message[a];
}
}
}
else if(md_select == 2){ //X.509
for(var a=0;a<ike_chk.length-1;a++)
{
tmp_str = document.getElementById(ike_chk[a]).value;
if(tmp_str == "")
{
chk_sta = false;
alert_str += (alert_str == "")?alert_message[a]:" , "+alert_message[a];
}
}
}
else{  //  Manually
for(var a=0;a<mk_chk.length;a++)
{
tmp_str = document.getElementById(mk_chk[a]).value;
if(tmp_str == "")
{
chk_sta = false;
alert_str += (alert_str == "")?alert_mk_message[a]:" , "+alert_mk_message[a];
}
}
}
if(!chk_sta){ alert(alert_str+GetElmCont("_0"," can't be empty.")); }
else if(!Interfc_bfsmit(gsipswan)){ chk_sta = false ;}  // ck Interface
else if((md_select == 0)||(md_select == 2)){ //Remote Subnet,Remote Netmask  save ���ɭԤ����ť�.
chk_sta = set_Subnetlist()
if(chk_sta) { chk_sta = ck_auth_LR_id() }
}
else{
chk_sta = ck_auth_LR_id()
}
str1 = (obj1.value == 0)?"t_ipsec_ike_keep_alive_ip":"t_ipsec_ike_keep_alive_fqdn"
obj2.value = eval("document.getElementById('"+str1+"').value")
return chk_sta;
}
function setsubip(sun_ip,csid_ary){
ary_ip = sun_ip.split(',');
for(j=0;j<ary_ip.length;j++){
if(ary_ip[j] == ""){
alert(GetElmCont("vpn1_0","Subnet IP Address can't be empty."));
return true
}
else{ csid_ary[j] = csid_ary[j].substr(0,csid_ary[j].lastIndexOf("=")+1)+ary_ip[j] }
}
return false
}
function setsubmk(sun_mk,csid_ary){
ary_mk = sun_mk.split(',');
for(j=0;j<ary_mk.length;j++){
pos0 = csid_ary[j].substr(0,csid_ary[j].lastIndexOf("=")+1)
if(ary_mk[j] == ""){
alert(GetElmCont("vpn1_0","Subnet Mask can't be empty."));
return true
}
else if(j==0){ csid_ary[j] = pos0 + set_h_mask3(ary_mk[j]) }
else{ csid_ary[j] = pos0 + ary_mk[j] }
}
return false
}
function set_Subnetlist(){
var _sun_Lsubip = "";
var _sun_Lsubmk = "";
var _sun_Rsubip = "";
var _sun_Rsubmk = "";
var str0 = "";
var Lipc=Ripc=0;
var aryL = (Locsubnet.length-1)
var gobj0 = document.getElementById('h_slist') //span
var gmd = document.getElementById("md")
var gshb_sok = document.getElementById("s_hub_and_spoke")
for(q=0;q<aryL;q++){
defv ="0.0.0.0" ;
defv1="0" ;
if(Locsubnet[q].indexOf("=")!= -1){
pos0 = Locsubnet[q].substr(0,Locsubnet[q].lastIndexOf("=")+1)
Locsubnet[q] =  pos0 + defv
}
else { Locsubnet[q] = Locsubnet[q]+"="+defv }
if(LocNetmask[q].indexOf("=")!= -1){
pos0 = LocNetmask[q].substr(0,LocNetmask[q].lastIndexOf("=")+1)
LocNetmask[q] =  pos0 + defv1
}
else { LocNetmask[q] = LocNetmask[q]+"="+defv1 }
if(Resubnet[q].indexOf("=")!= -1){
pos0 = Resubnet[q].substr(0,Resubnet[q].lastIndexOf("=")+1)
Resubnet[q] =  pos0 + defv
}
else { Resubnet[q] = Resubnet[q]+"="+defv }
if(ReNetmask[q].indexOf("=")!= -1){
pos0 = ReNetmask[q].substr(0,ReNetmask[q].lastIndexOf("=")+1)
ReNetmask[q] =  pos0 + defv1
}
else {  ReNetmask[q] = ReNetmask[q]+"="+defv1 }
}
$('#lSublisttab [name=Lsubip]').each(function(a){
ck2 = $(this).prop( "disabled" )
if(!ck2){
var _subip = $(this).val();
_sun_Lsubip += (_sun_Lsubip =="")?_subip:","+_subip
Lipc ++;
};
});
$('#lSublisttab [name=Lsubmk]').each(function(a){
ck2 = $(this).prop( "disabled" )
if(!ck2){
var _submk = $(this).val();
_sun_Lsubmk += (_sun_Lsubmk =="")?_submk:","+_submk
}
});
$('#rSublisttab [name=Rsubip]').each(function(a){
ck2 = $(this).prop( "disabled" )
if(!ck2){
var _subip = $(this).val();
_sun_Rsubip += (_sun_Rsubip =="")?_subip:","+_subip
Ripc++;
}
});
$('#rSublisttab [name=Rsubmk]').each(function(a){
ck2 = $(this).prop( "disabled" )
if(!ck2){
var _submk = $(this).val();
_sun_Rsubmk += (_sun_Rsubmk =="")?_submk:","+_submk
}
});
ck0 = (($( '#b_Ladd' ).prop( "disabled" ))&&(Lipc == 0))
ck1 = (($( '#b_Radd' ).prop( "disabled" ))&&(Ripc == 0))
if((!ck0)&&(setsubip(_sun_Lsubip,Locsubnet))){ return false }
else if((!ck0)&&(setsubmk(_sun_Lsubmk,LocNetmask))){ return false }
else if((!ck1)&&(setsubip(_sun_Rsubip,Resubnet))){ return false }
else if((!ck1)&&(setsubmk(_sun_Rsubmk,ReNetmask))){ return false }
else {
for(a=0;a<aryL;a++){
ary0 = Locsubnet[a].split("=")
str0 += "<input type=hidden name="+ary0[0]+" value="+ary0[1]+">"
ary0 = LocNetmask[a].split("=")
str0 += "<input type=hidden name="+ary0[0]+" value="+ary0[1]+">"
ary0 = Resubnet[a].split("=")
str0 += "<input type=hidden name="+ary0[0]+" value="+ary0[1]+">"
ary0 = ReNetmask[a].split("=")
str0 += "<input type=hidden name="+ary0[0]+" value="+ary0[1]+">"
}
gobj0.innerHTML = str0;
return true
}
}
function xauth_chk(value){
document.getElementById("_t_ipsec_xauth_user_0").disabled = (value == 2)?false:true;
document.getElementById("_t_ipsec_xauth_pass_0").disabled = (value == 2)?false:true;
document.getElementById("_t_ipsec_xauth_pass_0").type = "password";
if(value!=2){
document.getElementById("show_pw").checked = false;
}
document.getElementById("show_pw").disabled = (value == 2)?false:true;
document.forms[0].xauth_acc.disabled = (value == 1)?false:true;
}
function clrSbkph(sw){
xhf0 = location.href
if(sw &&(xhf0.indexOf("||") != -1)){
xhf = xhf0.split('||Sbkph')
ary0 = xhf[1].split('&');
for(s=0;s<ary0.length;s++){
if(ary0[s].indexOf("Ntid") != -1){
ary0x = ary0[s].split('=');
Ndelntid =ary0x[1];
if(parent.Hide) sGURL("/vpnhid.htm?Ncmd=1&Ndelntid="+Ndelntid);
break ;
}
}
}
}
function chk_keep(value){
var alive_ip = document.getElementById("t_ipsec_ike_keep_alive_ip");
var alive_fqdn = document.getElementById("t_ipsec_ike_keep_alive_fqdn");
alive_ip.style.display = (value == 0)?"":"none";
alive_fqdn.style.display = (value == 1)?"":"none";
}
function swDPDbyEn(obj1){
var sw0 = obj1.checked  //_c_dpd_en_0
var dpd_timeout = document.getElementById("_t_dpd_timeout_0")
var dpd_delay = document.getElementById("_t_dpd_delay_0")
dpd_timeout.disabled = !sw0;
dpd_delay.disabled = !sw0;
}
function set_h_mask3(val){
sel0 = document.getElementById('Lsubmk')
for(a=0;a<sel0.length;a++){
gtext0= sel0.options[a].text;
text1 = "(/"+val+")"
if(gtext0.indexOf(text1)!= -1){
nb0 = parseInt(gtext0.lastIndexOf("("),10);
gtext0v =gtext0.substring(0, nb0);
return gtext0v
}
}
}
function sethost_site2(obj){
gtmk_lmask = document.getElementById("t_mk_l_mask_0")
ghmk_lmask = document.getElementById("h_mk_l_mask_0")
gtmk_remask = document.getElementById("t_mk_r_mask_0")
ghmk_remask = document.getElementById("h_mk_r_mask_0")
if((obj.value == 1)||(obj.value == 3)){
gtmk_remask.value = "255.255.255.255";
ghmk_remask.value = gtmk_remask.value;
ghmk_remask.name = gtmk_remask.name;
gtmk_remask.disabled = true;
ghmk_remask.disabled = false;
}
else {
gtmk_remask.disabled = false;
ghmk_remask.disabled = true;
}
if((obj.value == 2)||(obj.value == 3)){
gtmk_lmask.value = "255.255.255.255";
ghmk_lmask.value = gtmk_lmask.value;
ghmk_lmask.name = gtmk_lmask.name;
gtmk_lmask.disabled = true;
ghmk_lmask.disabled = false;
}
else{
ghmk_lmask.name = "x_ike";
gtmk_lmask.disabled = false;
ghmk_lmask.disabled = true;
}
}
function sethost_site3(){
gmd = document.getElementById("md")
gtun_sco = document.getElementById("tun_scenario")
ghb_sk = document.getElementById("s_hub_and_spoke")
gtrhb_sk = document.getElementById("tr_hub_and_spoke")
gtic = document.getElementById("tun_ic")
gshb_sok = document.getElementById("s_hub_and_spoke")
gipsec_full = document.getElementById("c_ipsec_tun_full")
gredir_traffic= document.getElementById("c_ipsec_redir_traffic_en")
fullisdis = (gipsec_full.disabled)  // Full Tunnel alway disabled
fullisck = (gipsec_full.checked)    // Full Tunnel checked or not
chg_key_management(gmd.value)
set_hubandspoke(gshb_sok,gtun_sco)  // set Hub and Spoke
gtrhb_sk.style.display = (gmd.value == 1)?"none":""; // sw Hub and Spoke
if((gmd.value == 0)||(gmd.value == 2)){  //[ md = 0 ->IKE+Pre-shared Key ; md = 2 ->IKE+X.509 ; ]
if(gtun_sco.value == 0){  //site-to-site
/*site-to-site="0" -> tun_ic=gtic=0
Hub and spoke = none( value=0)
->Local subnet  :max=10
->Remote subnet :max=10
Hub and spoke = hub( value=10)
->Local subnet  :max=10
->Remote subnet :max=1
Hub and spoke = spoke( value=11)
->Local subnet :max=1
->Remote subnet:max=10
->Redirect Traffic :disabled && C_IPSEC_REDIRECT_TRAFFIC_ENABLE[x] = 0
Full tunnel = checked
->Remote subnet:disabled
->CSID���M��
*/
gtic.value = 0;
if(gshb_sok.value == 0){ //Hub and spoke = none( value=0)
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd,'+
'#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd'
).each(function(a){
$(this).prop('disabled',false);
});
}
else if(gshb_sok.value == 10){ //Hub and spoke = hub( value=10)
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd').each(function(a){
$(this).prop('disabled',false);
});
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(c){
$(this).prop('disabled',true);
});
$('#rSublisttab [name=Rsubip]').eq(0).prop('disabled',false);
$('#rSublisttab [name=Rsubmk]').eq(0).prop('disabled',false);
}
else if(gshb_sok.value == 11){ //Hub and spoke = spoke( value=11)
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd').each(function(w){
$(this).prop('disabled',true);
});
$('#lSublisttab [name=Lsubip]').eq(0).prop('disabled',false);
$('#lSublisttab [name=Lsubmk]').eq(0).prop('disabled',false);
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(q){
$(this).prop('disabled',false);
});
}
}
else if(gtun_sco.value == 1){  //site-to-host
/*site-to-host="1" -> tun_ic=0
->Local subnet :max=10
->remote subnet :disabled
->Redirect Traffic :disabled && C_IPSEC_REDIRECT_TRAFFIC_ENABLE[x] = 0
->Full tunnel :disabled
*/
gtic.value = 0;
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd'
).each(function(a){
$(this).prop('disabled',false);
});
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(a){
$(this).prop('disabled',true);
});
}
else if(gtun_sco.value == 2){  //host-to site
/*host-to site="2" -> tun_ic=0
->Local subnet :disabled
->Remote subnet :max=10
->Redirect Traffic :can be selected
->Full tunnel :disabled
*/
gtic.value = 0;
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd'
).each(function(a){
$(this).prop('disabled',true);
});
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(a){
$(this).prop('disabled',false);
});
}
else if(gtun_sco.value == 3){  //host-to-host
/*host-to-host="3" -> tun_ic=1
->Local subnet :disabled
->Remote subnet :disabled
->Redirect Traffic :disabled && C_IPSEC_REDIRECT_TRAFFIC_ENABLE[x] = 0
->Full tunnel :disabled
*/
gtic.value = 1;
$('#lSublisttab [name=Lsubip],#lSublisttab [name=Lsubmk],'+
'#lSublisttab [name=b_Ldel],#b_Ladd,'+
'#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd'
).each(function(a){
$(this).prop('disabled',true);
});
}
if(gtun_sco.value == 2){ //Redirect Traffic
gredir_traffic.disabled = false;
}
else {
if(gredir_traffic.checked){ gredir_traffic.click() }
gredir_traffic.disabled = true;
}
if(full_dis == 1){ gipsec_full.disabled = true }
else if(gtun_sco.value == 0){
gipsec_full.disabled = (full_dis != 1)?false:true
chk_ike_full3() ;
}
else { gipsec_full.disabled = true; gipsec_full.checked = false; }
}
else if(gmd.value == 1){ //[ md = 1 ->Manually ]
sethost_site2(gtun_sco)
}
}
function chk_ike_full3(_sw){
var tun_scov = (document.getElementById("tun_scenario").value == 0)
var shb_sokv = (document.getElementById("s_hub_and_spoke").value == 10);
var obj = document.getElementById("c_ipsec_tun_full");
if( _sw != null ){ obj.checked = (_sw == 1 )?true:false; }
var ike_subnet = "";
var ike_mask = "";
if(obj.checked){
$('#rSublisttab tr').each(function(q){
if(q >1){ $(this).remove(); }
});
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(a){
$(this).prop('disabled',true);
})
$('#rSublisttab [name=Rsubip]').eq(0).val('');
$('#rSublisttab [name=Rsubmk]').eq(0).val('');
}
else if(!(tun_scov && shb_sokv)){
$('#rSublisttab [name=Rsubip],#rSublisttab [name=Rsubmk],'+
'#rSublisttab [name=b_Rdel],#b_Radd').each(function(a){
$(this).prop('disabled',false);
})
}
}
function set_interfc(obj){
var f = document.forms['CGI'];
gobj0 = document.getElementById('tun_scenario');
gobj1 = document.getElementById('s_ipsce_tun_wan');
gobj2 = document.getElementById("opmode_failover")
for(s=0;s<gobj0.length;s++){ gobj0.options[s].disabled = false ;}
for(q=0;q<gobj2.length;q++){ gobj2.options[q].disabled = false ;}
if((obj == gobj0)&&(obj.value != 3)&&(gobj1.value>29)){
alert(GetElmCont("vpn1_0","LAN and VLAN Only support Host to Host"))
gobj1.value = 0;
}
else if((obj == gobj1)&&(gobj1.value>29)){
gobj0.value = 3;
gobj2.value = (gobj2.value == 2)?0:gobj2.value;
for(s=0;s<gobj0.length;s++)
{ gobj0.options[s].disabled = (gobj0.options[s].value != gobj0.value) ;}
for(w=0;w<gobj2.length;w++)
{ gobj2.options[w].disabled = (gobj2.options[w].value == 2)?true:false;}
sethost_site3()
}
}
function set_hubandspoke(obj,obj0){
gobj2 = document.getElementById('h_hub_and_spoke_en');
gobj1 = document.getElementById('h_hub_and_spoke_role');
for(var e=0;e<obj.length;e++){
if(obj.options[e].value != 0){
obj.options[e].disabled = (obj0.value == 0)?false:true
}
if(obj.options[e].disabled){ obj.value = 0 }
}
gobj2.value = (obj.value.length == 1)?obj.value:1;
gobj1.value = (obj.value.length == 2)?obj.value.substr(1,obj.value.length):obj.value;
}
function show_keep_alive(){
var h_alive_ip = document.getElementById("h_ipsec_ike_keep_alive_ip").value;
var alive_ip = document.getElementById("t_ipsec_ike_keep_alive_ip");
var alive_fqdn = document.getElementById("t_ipsec_ike_keep_alive_fqdn");
var select  = document.getElementById("s_keep_alive");
var str_array = h_alive_ip.split('.');
if(select.options[1] != null) {
select.value = (str_array.length == 4)?0:1;
alive_ip.style.display = (str_array.length == 4)?"":"none";
alive_fqdn.style.display = (str_array.length == 4)?"none":"";
alive_ip.value = (str_array.length == 4)?h_alive_ip:"";
alive_fqdn.value = (str_array.length == 4)?"":h_alive_ip;
}
else{
alive_ip.style.display = "";
alive_fqdn.style.display = "none";
alive_ip.value = h_alive_ip;
alive_fqdn.value = "";
}
}
function submk2v4(){
var str0 = "255.0.0.0,255.128.0.0,255.192.0.0,255.224.0.0,255.240.0.0,255.248.0.0,255.252.0.0,255.254.0.05,255.255.0.0,255.255.128.0,255.255.192.0,255.255.224.0,255.255.240.0,255.255.248.0,255.255.252.0,255.255.254.0,255.255.255.0,255.255.255.128,255.255.255.192,255.255.255.224,255.255.255.240,255.255.255.248,255.255.255.252,255.255.255.255"
var str1 = "0.0.0.0/0.0.0.0"
var str2 = GetElmCont("wary_0","None")
var ary0 = str0.split(",");
$('[name=sn_RSub01]').each(function(i){
a = $(this).text();
$(this).text(ary0[(a-8)]);
});
$('[name=sn_RSub0]').each(function(q){
w = $(this).text();
if(w == str1){
$(this).text(str2);
}
});
}
function swInterfc3(obj){
gswan = document.getElementById("s_ipsce_tun_wan");
gswan.disabled = ((typeof(obj) == 'object')&&(obj.value == 2))?true:false;
}
function Interfc_bfsmit(obj){
var disop_ix = "X"
for(a=0;a<obj.length;a++){
if(obj.options[a].value==''){ disop_ix = obj.options[a].value ;break; }
}
if(obj.length == 0){ disop_ix = ""; }
/*
alert("del ss1="+(!obj.disabled)
+" ,ss2="+(disop_ix != "X")
+" ,ss3="+(obj.value == disop_ix)
+" ,disop_ix='"+disop_ix+"'"
+" ,obj.value='"+obj.value+"'"
+" ,(obj.length == 0)="+(obj.length == 0)
)
*/
if((!obj.disabled)&&(disop_ix != "X")&&(obj.value == disop_ix)){
alert(GetElmCont("gre_0","Interface has expired, please confirm again.")) ;
return false
}
return true
}
function Interfc_dyn_sel(sel0 , sel1 , sel2){
/* (sel2 != null) == for edit page
sel0: Name ; sel1: id ; sel2:Interface value
*/
var ary1 = new Array(
(true && true)? true : false, // _0
(false && false)? true : false, // _128
""
)
var ary2 = new Array(
"0", // 0?
"0", // 128?
""
)
arrw=Interfc_info(1) //arrw[0] = Wan1 ; arrw[1] = Wan2 ;arrw[2] = Wan3
var inxD = parseInt(document.getElementById("ntid").value)
var str0 ="<select name="+sel0+" id="+sel1+">"
inxD = (inxD ==0 )?0:(inxD-127)
for(o=0;o<arrw.length;o++){
if((arrw[o] == "0")&&(o == sel2)&&(ary1[inxD])) {
str0+="<option value='"+o+"' selected>WAN"+(o+1)+"</option>"
}
else if(arrw[o] == "0") {
var r =0;
for(a=0;a<ary2.length;a++){
var rrr=((o == ary2[a])&&(ary1[a]))
if(rrr) { r++ }
}
if(r==0){ str0+="<option value='"+o+"'>WAN"+(o+1)+"</option>" }
}
}
str0+="</select>"
return str0
}
function Interfc_sel(sel0 , sel1 , sel3 , sel2){
/* (sel2 != null) == for edit page
sel0: Name ; sel1: id
LAN and VLAN value �q30�}�l
*/
var p_nb0 = 30
arrw=Interfc_info(1)  //arrw[0] = Wan1 ; arrw[1] = Wan2 ;arrw[2] = Wan3 ;
arrVL=Interfc_info(0) //aryVL[0] = Lan ; aryVL[1] = VLan1 ; aryVL[2] = VLan2 ; aryVL[3] = VLan3
str0 ="<select name="+sel0+" id="+sel1+" onchange="+sel3+">"
for(o=0;o<arrw.length;o++){
if((sel2!= null)&&(o == sel2)&&(arrw[o] != "0")) { str0+="<option value='' selected>WAN"+(o+1)+"</option>" }
else if((sel2!= null)&&(o == sel2)) { str0+="<option value='"+o+"' selected>WAN"+(o+1)+"</option>" }
else if(arrw[o] == "0") { str0+="<option value='"+o+"'>WAN"+(o+1)+"</option>" }
}
if((sel2!= null)&&(p_nb0 == sel2)) { str0+="<option id=_wiz_0 value='"+p_nb0+"' selected>LAN</option>" }
else {str0+="<option id=_wiz_0 value='"+p_nb0+"'>LAN</option>"}
for(w=1;w<arrVL.length;w++){
if((sel2!= null)&&((p_nb0+w) == sel2)&&(arrVL[w] == "0")) { str0+="<option value='' selected>VLan"+w+"</option>" }
else if((sel2!= null)&&((p_nb0+w) == sel2)) { str0+="<option value='"+(p_nb0+w)+"' selected>VLan"+w+"</option>" }
else if(arrVL[w] != "0") { str0+="<option value='"+(p_nb0+w)+"'>VLan"+w+"</option>" }
}
str0+="</select>"
return str0
}