var diprofile_record_next_index = 0;   //�ثe�Ĥ@���� �s�W�����X
var diprofile_record_edit_index = 0;
var diprofile_max_number = 10;         //�ثeCTA���w�}�X�̤j�Ӽ�
var diprofile_count =0;
var delete_check_arr = [];
for(var a=0;a<63;a++)
{
delete_check_arr[a] = 0;
}
/*
Add/Delete/Edit external server
diprofile_account_next_index => �n���J C_WEBUI_VPNPPTPACC_RECORD_RULE ���U�@�� index �ΨӰO��Ū��CSID �o����
diprofile_record_next_index => �U�@���� index  ���Ĥ@�Ӫťժ�CSID
by kent
*/
var diprofile_account_csid = [];
var diprofile_name_csid = [];
var diprofile_desc_csid = [];
var diprofile_source_csid = [];
var diprofile_normallvl_csid = [];
var diprofile_acttime_csid = [];
var diprofile_enable_csid = [];
diprofile_account_csid.push("N00201214");
diprofile_name_csid.push("S003B8000");
diprofile_desc_csid.push("S003BB300");
diprofile_source_csid.push("N003B8100");
diprofile_normallvl_csid.push("N003B8200");
diprofile_acttime_csid.push("N003B8300");
diprofile_enable_csid.push("N003BA200");
diprofile_account_csid.push("N00201215");
diprofile_name_csid.push("S003B8001");
diprofile_desc_csid.push("S003BB301");
diprofile_source_csid.push("N003B8101");
diprofile_normallvl_csid.push("N003B8201");
diprofile_acttime_csid.push("N003B8301");
diprofile_enable_csid.push("N003BA201");
diprofile_account_csid.push("N00201216");
diprofile_name_csid.push("S003B8002");
diprofile_desc_csid.push("S003BB302");
diprofile_source_csid.push("N003B8102");
diprofile_normallvl_csid.push("N003B8202");
diprofile_acttime_csid.push("N003B8302");
diprofile_enable_csid.push("N003BA202");
diprofile_account_csid.push("N00201217");
diprofile_name_csid.push("S003B8003");
diprofile_desc_csid.push("S003BB303");
diprofile_source_csid.push("N003B8103");
diprofile_normallvl_csid.push("N003B8203");
diprofile_acttime_csid.push("N003B8303");
diprofile_enable_csid.push("N003BA203");
diprofile_account_csid.push("N00201218");
diprofile_name_csid.push("S003B8004");
diprofile_desc_csid.push("S003BB304");
diprofile_source_csid.push("N003B8104");
diprofile_normallvl_csid.push("N003B8204");
diprofile_acttime_csid.push("N003B8304");
diprofile_enable_csid.push("N003BA204");
diprofile_account_csid.push("N00201219");
diprofile_name_csid.push("S003B8005");
diprofile_desc_csid.push("S003BB305");
diprofile_source_csid.push("N003B8105");
diprofile_normallvl_csid.push("N003B8205");
diprofile_acttime_csid.push("N003B8305");
diprofile_enable_csid.push("N003BA205");
diprofile_account_csid.push("N0020121A");
diprofile_name_csid.push("S003B8006");
diprofile_desc_csid.push("S003BB306");
diprofile_source_csid.push("N003B8106");
diprofile_normallvl_csid.push("N003B8206");
diprofile_acttime_csid.push("N003B8306");
diprofile_enable_csid.push("N003BA206");
diprofile_account_csid.push("N0020121B");
diprofile_name_csid.push("S003B8007");
diprofile_desc_csid.push("S003BB307");
diprofile_source_csid.push("N003B8107");
diprofile_normallvl_csid.push("N003B8207");
diprofile_acttime_csid.push("N003B8307");
diprofile_enable_csid.push("N003BA207");
diprofile_account_csid.push("N0020121C");
diprofile_name_csid.push("S003B8008");
diprofile_desc_csid.push("S003BB308");
diprofile_source_csid.push("N003B8108");
diprofile_normallvl_csid.push("N003B8208");
diprofile_acttime_csid.push("N003B8308");
diprofile_enable_csid.push("N003BA208");
diprofile_account_csid.push("N0020121D");
diprofile_name_csid.push("S003B8009");
diprofile_desc_csid.push("S003BB309");
diprofile_source_csid.push("N003B8109");
diprofile_normallvl_csid.push("N003B8209");
diprofile_acttime_csid.push("N003B8309");
diprofile_enable_csid.push("N003BA209");
function add_edit_diprofile_account(type,edit_arr_index,edit_csid_index)
{
var add_edit_table = document.getElementById("add_edit_table");
var add_button = document.getElementById("add_save_button");
var edit_button = document.getElementById("edit_save_button");
var diprofile_name = document.getElementById("t_name");
var diprofile_desc = document.getElementById("t_desc");
var diprofile_source = document.getElementById("t_source");
var diprofile_normallvl = document.getElementById("t_normallvl");
var diprofile_acttime = document.getElementById("t_acttime");
var diprofile_checked = document.getElementById("c_enable");
var anchor = document.getElementById("_a_anchor");
if(type == 'add')
{
if(diprofile_account_next_index == diprofile_max_number)
{
alert("rule can't more than "+diprofile_max_number);
return false;
}
diprofile_name.value = "";
diprofile_desc.value = "";
diprofile_source.value = 1;
diprofile_normallvl.value = 0;
diprofile_acttime.value = 1;
diprofile_checked.checked = true;
}
else
{
diprofile_name.value = diprofile_name_arr[edit_arr_index];
diprofile_desc.value = diprofile_desc_arr[edit_arr_index];
diprofile_source.value = diprofile_source_arr[edit_arr_index];
diprofile_normallvl.value = diprofile_normallvl_arr[edit_arr_index];
diprofile_acttime.value = parseInt(diprofile_acttime_arr[edit_arr_index]);
diprofile_checked.checked = (diprofile_enable_arr[edit_arr_index] == 1)?"checked":"";
diprofile_record_edit_index = edit_csid_index;
}
sw_configtab(add_edit_table)
add_edit_table.style.display = "";
add_button.style.display = (type == "add")?"":"none";
edit_button.style.display = (type == "add")?"none":"";
anchor.click();
chkN(diprofile_acttime,'c','1-10');
}

function save_diprofile(type,obj)
{
var add_name = get_encode_value("t_name");
var add_desc = get_encode_value("t_desc");
var add_source = get_encode_value("t_source");
var add_normallvl = get_encode_value("t_normallvl");
var add_acttime = get_encode_value("t_acttime");
var add_checked = document.getElementById("c_enable").checked;
var add_enable = (add_checked)?1:0;
var index = (type == 'add')?diprofile_record_next_index:diprofile_record_edit_index;
var account_str = "hide.htm?";
var str_message = "";
var iframe = document.getElementById("iframeH");
saveResult();
if(add_name == "" || add_acttime == "")
{
str_message = (add_name == "")?"Name can not be empty":"Signal Active Time can not be empty";
alert(str_message);
return false;
}
if(add_desc=="") {alert(GetElmCont("_0","Description can not be empty"));return false;}
if(!chkForm())
{
return false;
}
if(type == 'add')
{
account_str += diprofile_account_csid[diprofile_account_next_index]+"="+(index+1)+"&";
}
account_str += diprofile_name_csid[index]+"="+add_name;
account_str += "&"+diprofile_desc_csid[index]+"="+add_desc;
account_str += "&"+diprofile_source_csid[index]+"="+add_source;
account_str += "&"+diprofile_normallvl_csid[index]+"="+add_normallvl;
account_str += "&"+diprofile_acttime_csid[index]+"="+add_acttime;
account_str += "&"+diprofile_enable_csid[index]+"="+add_enable;
account_str += "&N803B0001=1&N80420715=1"
iframe.src = account_str+"&csrftok="+get_csrf_token();
setTimeout("show_diprofile_list();saveResult('9999')",2000);
swids("add_edit_table",false);
}
function del_diprofile()
{
var tmp_del = document.getElementsByName("diprofile_del");
var del_arr = new Array();
var index = 0;
var del_index =0;
var new_index = 0;
var sent_str ="hide.htm?";
var iframe = document.getElementById("iframeH");
var reset_del = "";
var show_message = 0;
var show_message_str = "";
for(var t=0;t<tmp_del.length;t++)
{
var index = (tmp_del[t].value-1);
if(tmp_del[t].checked)
{
del_arr[del_index] = tmp_del[t].value;  //del_arr[del_index] �n�R����item
del_index++;
}
}
if(del_arr.length == 0)
{
alert(GetElmCont("lb_0","Please choose one or more rule."));
return false;
}
for(var r=0;r<diprofile_account_index.length;r++)
{
for(var n=0;n<del_arr.length;n++)
{
if(diprofile_account_index[r] == del_arr[n])
{
diprofile_account_index[r] = "";
}
}
}
for(var a=0;a<diprofile_account_csid.length;a++)
{
if(diprofile_account_index[a] != "")
{
sent_str += (sent_str == "hide.htm?")?diprofile_account_csid[new_index]+"="+diprofile_account_index[a]:"&"+diprofile_account_csid[new_index]+"="+diprofile_account_index[a];
new_index++;
}
}
for(var c=new_index;c<diprofile_account_csid.length;c++)
{
sent_str += (sent_str == "hide.htm?")?diprofile_account_csid[c]+"=":"&"+diprofile_account_csid[c]+"=";
}
for(var x=0;x<del_arr.length;x++)
{
var xx = del_arr[x]-1;
sent_str += (sent_str == "hide.htm?")?diprofile_name_csid[xx]+"=":"&"+diprofile_name_csid[xx]+"=";
sent_str += "&"+diprofile_enable_csid[xx]+"=0";
}
sent_str += "&N803B0001=1&N80420715=1"
iframe.src = sent_str+"&csrftok="+get_csrf_token();
setTimeout("show_diprofile_list();saveResult('9999')",2000);
}
function get_encode_value(id)
{
var obj = document.getElementById(id);
return (obj != null)?encodeURIComponent(obj.value):"";
}
