var authsel11nopt = new Array(//N00191300
"_wiz30_0:0:Open",
"_wiz30_0:1:Shared",
"_wary_0:2:Auto",
"_wiz30_0:5:WPA2-PSK",
"_wiz30_0:6:WPA2",
"_wiz30_0:7:WPA-PSK / WPA2-PSK",
"_wiz30_0:8:WPA / WPA2"
);
var authsel11nopthybrid = new Array(
"_wiz30_0:0:Open",
"_wiz30_0:1:Shared",
"_wary_0:2:Auto",
"_wiz30_0:5:WPA2-PSK"
);
var encry01_11n = new Array(
new Option(GetElmCont("wary_0","None"),"0")
);
var encry02_11n = new Array();
var encry1_11n = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3")
);
var encry01_normal = new Array(
new Option(GetElmCont("wary_0","None"),"0"),
new Option(GetElmCont("wiz30_0","WEP"),"1")
);
var encry02_normal = new Array(
new Option(GetElmCont("wiz30_0","WEP"),"1")
);
var encry1_normal = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3")
);
var encry1_wds_normal = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3")
);
var encry01 = new Array(
new Option(GetElmCont("wary_0","None"),"0"),
new Option(GetElmCont("wiz30_0","WEP"),"1")
);
var encry02 = new Array(
new Option(GetElmCont("wiz30_0","WEP"),"1")
);
var encry1 = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3")
);
var encry1_1 = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3"),
new Option(GetElmCont("wiz30_0","TKIP / AES"), "4")
);
var encry1_wds = new Array(
new Option(GetElmCont("wiz30_0","AES"), "3")
);
var authmodestr = new Array(
GetElmCont("wiz30_0","Open"),
GetElmCont("wiz30_0","Shared"),
GetElmCont("wary_0","Auto"),
GetElmCont("wiz30_0","WPA-PSK"),
GetElmCont("wiz30_0","WPA"),
GetElmCont("wiz30_0","WPA2-PSK"),
GetElmCont("wiz30_0","WPA2"),
GetElmCont("wiz30_0","WPA-PSK/WPA2-PSK"),
GetElmCont("wiz30_0","WPA/WPA2"),
"&nbsp;"
);
var encryptypestr = new Array(
GetElmCont("wary_0","None"),
GetElmCont("wiz30_0","WEP"),
GetElmCont("wiz30_0","AES")
);
var apmodestr = new Array(
GetElmCont("stawireless_0","b/g Mixed"),
GetElmCont("stawireless_0","b Only"),
GetElmCont("stawireless_0","a Only"),
"",
GetElmCont("stawireless_0","g Only"),
"",
GetElmCont("stawireless_0","n Only"),
GetElmCont("stawireless_0","g/n Mixed"),
GetElmCont("stawireless_0","a/n Mixed"),
GetElmCont("stawireless_0","b/g/n Mixed")
);
var basicrate = new Array(
"0|15",    	//BG_MIXED
"1|3",     	//B_ONLY
"2|0",     	//WMODE_A_ONLY
"4|351",   	//G_ONLY
"6|15",    	//N_ONLY
"7|351",   	//GN_MIXED
"8|0",     	//AN_MIXED
"9|15",    	//BGN_MIXED
"11|15"		//5G 11N_ONLY
);
var txmodes = new Array(
"0|OFDM",   //BG_MIXED
"1|CCK",    //B_ONLY
"2|",      	//WMODE_A_ONLY
"4|OFDM",   //G_ONLY
"6|HT" ,    //N_ONLY
"7|HT" ,    //GN_MIXED
"8|",      	//AN_MIXED
"9|HT",     //BGN_MIXED
"11|HT"     //11A only
);
var aplist_ary = [];
var tableIDArray = new Array(
"div_CHANNEL",
"div_NSSID",
"div_WLAN_Partition",
"div_WIRELESSMODE",
"div_AUTH",
"div_8021X",
"div_ENCRY",
"div_WDS",
"div_adapter",
"lazy_mode",
"div_MULTIAPS",
"div_SCHED",
"div_VAP_Isolation",
"div_Profile"
);
var wpaTabs = new Array(		//for swWLAN()
"tab0", "div_MULTIAPS", "div_SCHED", "div_NSSID", "tab4", "div_CHANNEL",
"div_WIRELESSMODE", "div_AUTH", "tab8", "div_ENCRY", "w3","w1",
"w2","div_WDS","div_adapter","wcl1","wcl2","div_VAP_Isolation"
);
var clientMAC = null;			//repeater mode: to record mac
function chk_buttons()
{
var wopmode_value = document.getElementById('WOpMode').value;
if(wopmode_value == "3"){
}
if(wopmode_value != "4" && wopmode_value != "5"){
document.forms[0]._scann.style.display = "none";
}
}
/****************************************************************/
function returnWopMode()
{
var r_wmode = N_wmode;
if(r_wmode == "0"){
return document.getElementById("WOpMode").value;
}
else{
r_wmode = parseInt(r_wmode) - 1;
return r_wmode;
}
}
function changeAp(ApSelect, page)
{
var nextUrl = null;
var apNum = ApSelect.value;
var c_wmode = document.getElementById("WOpMode").value;
c_wmode = parseInt(c_wmode) + 1;
nextUrl = page + ".htm?Nrule=" + apNum;		/** 選擇的是哪個ap **/
nextUrl += "&Nwmode=" + c_wmode;			/** 選擇的是哪個wireless operation mode **/
nextUrl += "&Ndoing=1&Nsingle=1";
nextUrl += "&Nband="+ N_band;
GURL(nextUrl);
}
function chgWOpMode(wmodeObj, page)
{
var nextUrl = null
var s_wmode = wmodeObj.value;
s_wmode = parseInt(s_wmode) + 1;
nextUrl = page + ".htm?Nrule=0&Nwmode=" + s_wmode;
nextUrl += "&Ndoing=1&Nsingle=1";
nextUrl += "&Nband="+ N_band;
GURL(nextUrl);
}
function chkWlanEnable(fr)
{
var wlan_enable = document.getElementById("id_wlenable");
if(N_doing == "1"&&fr=="init"){ //當ndoing=1 and from init時才固定在enable,不然會關不掉功能..done
swWLAN(true, wpaTabs);
wlan_enable.checked = true;
}
else{ //當click時一定要可以開關功能...done
if(wlan_enable.checked == false){
swWLAN(false, wpaTabs);
}
else{
swWLAN(true, wpaTabs);
}
}
displayWOPDiv();
}
function displayWOPDiv()
{
var divID;
var f = document.forms[0];
var wopMode_value = returnWopMode();
document.getElementById("WOpMode").value = wopMode_value;
var ap_number = document.getElementById("id_apNum").value;
if(document.getElementById("id_wlenable").checked) document.getElementById('id_apNum').disabled=false; //for Universal Repeater show VAP1 ,other when WiFi Module Enable,Multiple AP Names not disable
if(wopMode_value > 1&& wopMode_value!=8){ 							/** 當選擇的非ap router mode和ap only mode **/
if(wopMode_value == 2){						//WDS Hybrid mode(wds+ap)
for (var tabIndex = 0, divID; divID = tableIDArray[tabIndex]; tabIndex++){
if( divID == "div_8021X"	|| divID == "div_adapter"  || divID == "div_Profile"){
document.getElementById(divID).style.display = "none";
if(divID != "div_8021X"){
disablebyDiv(divID, true);
}
}
else{
if(divID == "div_CHANNEL" || divID == "div_WIRELESSMODE" || divID == "div_WDS" || divID == "lazy_mode"){
if(ap_number != "0"){		//only AP1 has channel, wireless mode,WDS, Lazy Mode
document.getElementById(divID).style.display = "none";
}
else{
document.getElementById(divID).style.display = "";
}
}
else{
document.getElementById(divID).style.display = "";
}
}
}
getEnable("ap_enable_check", "ap_enable");
show_mac(document.getElementById("lazy_mode_check")); //fix when WiFi Module disable and Lazy Mode enable,div_WDS should not be shown
}
else if(wopMode_value == 3){ 					//WDS only mode
for (var tabIndex = 0, divID; divID = tableIDArray[tabIndex]; tabIndex++){
if( divID == "div_CHANNEL" || divID == "div_ENCRY" ||
divID == "div_WDS" 	   || divID == "div_AUTH"	){
document.getElementById(divID).style.display = "";
}
else{
document.getElementById(divID).style.display = "none";
if(divID != "div_8021X"){
disablebyDiv(divID, true);
}
}
}
}
else if(wopMode_value == 4){ //Adapter
for (var tabIndex = 0, divID; divID = tableIDArray[tabIndex]; tabIndex++){
if(divID == "div_adapter"){
document.getElementById(divID).style.display = "";
}
else{
document.getElementById(divID).style.display = "none";
if(divID != "div_8021X"){
disablebyDiv(divID, true);
}
}
}
}
else{ 						//Universal Repeater
for (var tabIndex = 0, divID; divID = tableIDArray[tabIndex]; tabIndex++){
if( divID == "div_NSSID" || divID == "div_CHANNEL" || divID == "div_MULTIAPS" ||
divID == "div_AUTH" 		  || divID == "div_ENCRY"  || divID == "div_WLAN_Partition" || divID == "div_VAP_Isolation" ){
document.getElementById(divID).style.display = "";
document.getElementById('id_apNum').disabled=true; //for Universal Repeater only show VAP1
}
else{
document.getElementById(divID).style.display = "none";
if(divID != "div_8021X"){
disablebyDiv(divID, true);
}
}
}
getEnable("ap_enable_check", "ap_enable");
}
}
else{ 										//AP ONLY MODE, AP ROUTER MODE
for (var tabIndex = 0, divID; divID = tableIDArray[tabIndex]; tabIndex++){
if(divID == "div_adapter" || divID == "div_WDS" || divID == "lazy_mode" || divID == "div_Profile"){
document.getElementById(divID).style.display = "none";
disablebyDiv(divID, true);
}else{
if(divID == "div_CHANNEL" || divID == "div_WIRELESSMODE"){
if(ap_number != "0"){		//only AP1 has channel, wireless mode
document.getElementById(divID).style.display = "none";
}
else{
document.getElementById(divID).style.display = "";
}
}
else{
document.getElementById(divID).style.display = "";
}
}
}
if(wopMode_value==8){
document.getElementById("id_wlenable").disabled=true;
document.getElementById("WOpMode").disabled=true;
document.getElementById('id_wchannel').disabled=true;
document.getElementById('auto_ch_0').disabled=true;
document.getElementById('auto_ch_1').disabled=true;
document.getElementById('div_Profile').style.display = "";
disablebyDiv('div_Profile', false)
document.getElementById("div_8021X").style.display = "none";
document.getElementById("h_8021x").value=0;
document.getElementById("id_8021x").checked=false;
}
getEnable("ap_enable_check", "ap_enable");
/***********************************************************************
if(ap_number == "0"){
document.getElementById("ap_enable_check").disabled = true;
document.getElementById("span_ap").style.display = "none";
}
***********************************************************************/
}
if(sel_supportv=="1"&&document.getElementById("WOpMode").value==8){
document.getElementById("s_wopband").disabled=true;
document.getElementById("id_wlenable").disabled=true;
}
chgWmode(document.getElementById("id_wmode"));	/** 設定對應的頁面 **/
chk_buttons();									/** 判斷button的顯示 **/
}
function chkkeylen(wopmode_v)
{
var fm = document.forms[0];
var auth = null;
if(wopmode_v == "4"){
auth = document.getElementById("id_cliauth");
}
else{
auth = document.getElementById("id_auth");
}
var auth_value = auth.value;
if(auth_value == "1"){													//shared
return chkwepkeylen(wopmode_v);
}
else if(auth_value == "3" || auth_value == "5" || auth_value == "7"){	//wpa-psk, wpa2-psk, wpa-psk/wpa2-psk
return chkpresharekeylen(wopmode_v);
}
else if(auth_value == "4" || auth_value == "6" || auth_value == "8"){	//wpa, wpa2, wpa/wpa2
srvip=document.getElementById("r_serverip")
srvport=document.getElementById("r_port")
if (chkI(srvip,'a')&&chkN(srvport,'p')){
return true;
}
else{
alert(GetElmCont("valChk_0","Please check the settings again!"));
return false;
}
}
else{
var ency = null;
if(wopmode_v == "4"){
ency = document.getElementById("id_cliencry");
}
else{
ency = document.getElementById("id_encry");
}
if(auth_value == "0"){												//open
var mode1x = document.getElementById("id_8021x");
if(mode1x.checked){
return true;
}
else{
if(ency.value == "1"){
return chkwepkeylen(wopmode_v);
}
else{
return true;
}
}
}
else{																//auto
if(ency.value == "1"){
return chkwepkeylen(wopmode_v);
}
else{
return true;
}
}
}
}
function chkwepkeylen(wep_wopmodev)
{
var fm = document.forms[0];
var c = 0;
var defkeyid = null;
var keyidselect = (wep_wopmodev == "4") ? "id_clidefkeyid" : "id_defkeyid";
var wepkey_length = 4;
for(kf = 0; kf < wepkey_length; kf++){
eval("defkeyid = document.getElementById('" + keyidselect + kf + "')" );
if(defkeyid.checked){
var keyid = ((wep_wopmodev == "4") ? "id_cliwkey" : "id_wkey") + kf;
for(j = 0; j < fm.length; j++){
if(fm.elements[j].id == keyid){
break;
}
}
var keylen = fm.elements[j].value.length;
if(fm.elements[j - 1].value == 0){	//Hex
if((keylen != 10) && (keylen != 26)){
alert(GetElmCont("valChk_0","Please input 10 or 26 hexadecimal digits in WEP Key field!"));
return false;
}
}
else{ //ASCII
if((keylen != 5) && (keylen != 13)){
alert(GetElmCont("valChk_0","Please input 5 or 13 ASCII characters in WEP Key field!"));
return false;
}
}
c++;
}
}
if(c == 1){
return true;
}
else{
alert(GetElmCont("wpa_0","Please select a WEP key!"));
return false;
}
}
function chkpresharekeylen(pres_wopmodev)
{
var fm = document.forms[0];
var pkeylen = null;
if(pres_wopmodev == "4"){
pkeylen = document.getElementById("id_clipskey").value.length;
}
else{
pkeylen = document.getElementById("id_pskey").value.length;
}
if((pkeylen > 64) || (pkeylen < 8)){
alert(GetElmCont("valChk_0","Please input 64 hexadecimal digits or 8~63 ASCII character in Preshared Key field!"));
return false;
}
return true;
}
function chgwepkeylen(keytype, ix)
{
var f = keytype.form;
for(kt = 0; kt < f.length; kt++){
if(f.elements[kt] == keytype){
break;
}
}
f.elements[kt + 1].maxLength = (keytype.value == 0) ? "26" : "13";
chkS(f.elements[kt + 1], 'w');
}
function clearoptions(selectobj)
{
var sl = selectobj.length;
for(var j = 0; j < sl; j++){
selectobj.options[0] = null;
}
}
function txmode(wm)
{
for(var p = 0; p < txmodes.length; p++){
tm = txmodes[p].split("|");
if(tm[0] == wm){
return tm[1];
}
}
}
function brate(wm)
{
for(var p = 0; p < basicrate.length; p++){
br = basicrate[p].split("|");
if(br[0] == wm){		//br[0]:wirelss mode。 ex: B only, G only... ； br[1]: basic rate
return br[1];
}
}
}
function chgWmode(wmode)
{
var f = wmode.form;
document.getElementById("id_brate").value = brate(wmode.value);
document.getElementById("id_fixmode").value = txmode(wmode.value);
var wmodev = wmode.options[wmode.selectedIndex].value;
var wopmode_value = document.getElementById("WOpMode").value;
var c_auth = null;
if(wopmode_value == "4"){
c_auth = document.getElementById("id_cliauth");
}
else{
c_auth = document.getElementById("id_auth");
}
swbyAry(wmodev, c_auth);
chgauthmode(c_auth);
}
function clrsel(b)
{
var cfrom = (arguments.length == 1) ? 0 : arguments[1];
var bl = b.length;
for(var j = 0; j < bl - cfrom; j++){
b.options[cfrom].value = "";
b.options[cfrom] = null;
}
}
function pushselopt(sel,stext,sval,sid)
{
var sopt = new Option(stext, sval);
var sellen = sel.length;
sel.options[sellen] = sopt;
sel.options[sellen].id = sid;
}
function swbyAry(wmode_value, obj)
{
var ary = new Array();
var wopmodev = document.getElementById('WOpMode').value;
var auth_preselect = obj.value;
var isAPmode_11n = false;					/** 當為 AP router mode 或 AP only mode，且wireless mode 為11n時 **/
if(wopmodev == "0" || wopmodev == "1"){
ary = authsel11nopt;
}
else{    /** 當wireless operation mode 為 wds系列和Universal Repeater,wifi uplink **/
ary = authsel11nopthybrid;
}
clrsel(obj);
for(var p = 0; p < ary.length; p++){
var arys = ary[p].split(":");
var oid = arys[0];
var oval = arys[1];
var otext = GetElmCont(lang + oid, arys[2]);
if(oval == "1"){
if(wopmodev == "0" || wopmodev == "1" || wopmodev == "2" || wopmodev == "8"){	/** ap router mode, ap only mode, WDS Hybrid Mode ,WISP Mode**/
if(wmode_value == "6" || wmode_value == "11"){				/** N only 無 shared, auto **/
isAPmode_11n = true;
continue;
}
}
}
else if(oval == "2"){
if(wopmodev == "0" || wopmodev == "1" || wopmodev == "2" || wopmodev == "8"){	/** ap router mode, ap only mode, WDS Hybrid Mode ,WISP Mode**/
if(wmode_value == "6" || wmode_value == "11"){				/** N only 無 shared, auto  **/
isAPmode_11n = true;
continue;
}
}
if(wopmodev == "4"){
continue;
}
}
pushselopt(obj, otext, oval, oid);
}
obj.selectedIndex = findSelectIndex(obj, auth_preselect);
var new_ary = new Array();
encry01 = new_ary.concat(isAPmode_11n ? encry01_11n : encry01_normal);
encry02 = new_ary.concat(isAPmode_11n ? encry02_11n : encry02_normal);
encry1 = new_ary.concat(isAPmode_11n ? encry1_11n : encry1_normal);
encry1_wds = new_ary.concat(isAPmode_11n ? encry1_11n : encry1_wds_normal);
}
function chgauthmode(auth)
{
var c_wopmodev = document.getElementById("WOpMode").value;
var authv = auth.value;					        /** 取得 authentication 的值 **/
var c8021X_enable = document.getElementById("id_8021x");
var c8021X_value = document.getElementById("h_8021x");
if(c_wopmodev != "0" && c_wopmodev != "1" && c_wopmodev != "2" && c_wopmodev != "8"){		/** 非AP Router, AP Only Mode, WDS Hybrid Mode **/
c8021X_enable.checked = false;
c8021X_value.value = 0;
document.getElementById("div_8021X").style.display = "none";
}
else{											/** 802.1x enable when open or auto show **/
if(authv == 0 || authv == 2){
/***************************************************************************************
c8021X_enable.checked = (x1xv == "1");		//x1xv變數，定義於wpa.htm(wpa2.htm)，為了共用code而如此設計
***************************************************************************************/
if(c_wopmodev!=8){
document.getElementById("div_8021X").style.display = "";
}
}
else{
c8021X_enable.checked = false;
c8021X_value.value = 0;
document.getElementById("div_8021X").style.display = "none";
}
}
setencrysel();
document.getElementById('show_rkey').checked=false;
document.getElementById('show_prekey').checked=false;
document.getElementById('r_sharedkey').type="password";
document.getElementById('id_pskey').type="password";
}
function setencrysel()
{
var wopmode_value = document.getElementById("WOpMode").value;
var ra1x = document.getElementById("id_8021x").checked;
var auth = null;
var encry = null;
var encry_preselect = null;
var addary = null;
if(wopmode_value == "4"){
auth = document.getElementById("id_cliauth");
encry = document.getElementById("id_cliencry");
}
else{
auth = document.getElementById("id_auth");
encry = document.getElementById("id_encry");
}
encry_preselect = encry.value;
clearoptions(encry);
if(auth.value == "0" || auth.value == "2"){
addary = (ra1x)?encry02:encry01;
}
else if(auth.value == "1"){
addary =  encry02;
}
else{
if(wopmode_value == "2" || wopmode_value == "3"){
addary =  encry1_wds;
}
else{
if(auth.value == '5'||auth.value == '6'||auth.value == '7'||auth.value == '8'){
addary =  encry1_1;
}else{
addary =  encry1;
}
}
}
for(var aa = 0; aa < addary.length; aa++){
if(wopmode_value == "0"&&(auth.value == '5'||auth.value == '6')){
encry.options[encry.length] = addary[aa];
if(aa==addary.length-1){
encry.options[encry.length-1].disabled = true;
}
}else{
encry.options[encry.length] = addary[aa];    			/** 將auth對應的encry加到下拉式選單中(Encryption) **/
encry.options[encry.length-1].disabled = false;
}
}
/******************************************************************************************
*******************************************************************************************/
if(auth.value == '5'||auth.value == '6'){
encry.selectedIndex = 0;
}else{
encry.selectedIndex = findSelectIndex(encry, encry_preselect);	/** 顯示目前的encryption值，非csid值 **/
}
if(wopmode_value == "4"){
chgencrytype_ad(encry);
}
else{
chgencrytype(encry);
}
var broadcast_ssid = document.getElementById("id_bssid");
}
function chgencrytype(encrytype)
{
var ra1x_enable = document.getElementById("id_8021x").checked;
var encrytypev = encrytype.value;
if(encrytypev == "0"){
if(ra1x_enable){
DisplayWlanItems("w3");
}
else{
DisplayWlanItems("w0");
}
}
else if(encrytypev == "1"){
if(ra1x_enable){
DisplayWlanItems("w3");
}
else{
DisplayWlanItems("w1");
}
}
else{
var auth = document.getElementById("id_auth");
if(auth.value == "4" || auth.value == "6" || auth.value == "8"){
DisplayWlanItems("w3");
}
else{
DisplayWlanItems("w2");
}
}
saveResult(); 							/** 當引數為空時，僅建立div標籤(用來顯示save! no change!用的) **/
}
function DisplayWlanItems(id)
{
var encry_array = new Array("w0", "w1", "w2", "w3", "wcl1", "wcl2");
var encryitem = null;
for(var i = 0; i < encry_array.length; i++){
encryitem = document.getElementById(encry_array[i]);
encryitem.style.display = (id == encry_array[i]) ? "" : "none";
if(document.getElementById("id_wlenable").checked){
disablebyDiv(encry_array[i], !(id == encry_array[i]));
}
}
}
/************* begin: for adapter mode **************/
function chgencrytype_ad(encrytype)
{
var encval = encrytype.value;
if(encval == "0"){
DisplayWlanItems("w0");
}
else if(encval == "1"){
DisplayWlanItems("wcl1");
}
else{
DisplayWlanItems("wcl2");
}
}
/************* end: for adapter mode **************/
function createaplist(mode,xmlurl)
{
$.ajax({
url:""+xmlurl,
type: 'GET',
dataType: 'xml',
error: function(){
createaplist(xmlurl)
},
success: function(xml){
var xmlarys = [];					/** 用來存放每組 ap 的資料 **/
$(xml).find("ap").each(function(i){
xmlarys[i] = [];
xmlarys[i][0]=$(this).children("ssid").text();    //取得子節點中的ssid
xmlarys[i][1]=$(this).children("channel").text(); //取得子節點中的channel
xmlarys[i][2]=$(this).children("quality").text(); //取得子節點中的quality
xmlarys[i][3]=$(this).children("auth").text();    //取得子節點中的auth
xmlarys[i][4]=$(this).children("encryp").text();  //取得子節點中的encryp
xmlarys[i][5]=$(this).children("mac").text();     //取得子節點中的mac
xmlarys[i][6]=$(this).children("ssid_udec").text();
})
clkscanap(mode,2,xmlarys);
}})
}
var scan_time=["10","10"];
/*
fr=0,先下shellex,依scan_time等待秒數後進入fr=1
fr=1,讀取xml，將csid的值寫入陣列xmlarys
fr=2,依傳回來的陣列，寫入ap list的表格中
*/
function clkscanap(mode,fr,aplists)	//WDS、REPEATER、ADAPTER
{
var alt = document.getElementById('_sr_');				/** save 的提示 tag **/
var aptab = document.getElementById('aptab');
var aplist_table = document.getElementById('stab');		/** ap 列表的資料表格 id **/
var apcli_num = null;
var wopmode_value = document.getElementById("WOpMode").value;
aplist_ary.length=0;
var t=new Date();
ztv="&ZT="+t.getTime();
if(wopmode_value == "2" || wopmode_value == "3" || wopmode_value == "5"){
apcli_num = ((mode == "wpa") ? "3" : "4");
}
else if(wopmode_value == "4"){
apcli_num = ((mode == "wpa") ? "1" : "2");
}
else{
return;
}
var timer = ((mode == "wpa") ? scan_time[0] : scan_time[1]);
timer = ((timer == "") ? 5000 : parseInt(timer)*1000);
if(arguments.length < 2){
fr=0;
}
if (fr == 0){
$.ajax({
url:"aplist.xml?rc=&Ncmd="+apcli_num+ztv
})
setTimeout(function(){
clkscanap(mode,1)
}, timer);
alt.innerHTML = "<font color=blue>"+GetElmCont('wpa_0','Scanning AP... Please wait a moment...')+"</font>";
alt.style.display = '';	                 /** wait訊息 **/
aptab.style.display = "none";     /** ap表格 **/
showhint(false);  		                 /** 顯示copy mac提示訊息 **/
}
if (fr == 1){
createaplist(mode,"aplist.xml?Ncsid=" + apcli_num + ztv)
}
if (fr == 2){
if(aplists){
var startrow = 1;												/** 從第1 row 開始塞資料 **/
var xrowl = aplist_table.rows.length;							/** 取得目前 row 數目 **/
for(var k = 0; k < xrowl - startrow; k++){						/** 刪除表格的所有row **/
aplist_table.deleteRow(startrow);							/** 刪除第 startrow 個 row **/
}
for(var i = 0; i < aplists.length; i++){
var z = aplist_table.insertRow(i + startrow);				/** 從第 i+2 row 開始 insert row **/
var rad = ((aplists[i][3] == 4) || (aplists[i][3] == 6) || (aplists[i][3] == 8)) ? "disabled='disabled'" : ""; /** 當 auth 為 WPA, WPA2，則disable **/
if(aplists[i][6]=="32"){aplists[i][0]=" ";}
z.insertCell(0).innerHTML = aplists[i][0];					//SSID
z.insertCell(1).innerHTML = aplists[i][1];					//CHANNEL
z.insertCell(2).innerHTML = aplists[i][2] + "%";			//QUALITY
var auth = aplists[i][3];
var ency = aplists[i][4];
if(auth==7) {auth = 5;}
if(ency==4) {ency = 3;}
if(ency==0||ency==1) {auth = 9;}
z.insertCell(3).innerHTML = authmodestr[auth]                    //AUTHENTICATION
z.insertCell(4).innerHTML = encryptypestr[ency]                    //ENCRYPTION
z.insertCell(5).innerHTML = aplists[i][5];          //MAC
var aplist = null;
if(wopmode_value == "2" || wopmode_value == "3"){
apclist = "<input type='button' id='_afmap_2_" + i + "' name='rr' value='Copy to' ";
}
else{
apclist = "<input type='radio' id='r_select_"+ i +"' name='rr' ";
}
apclist += "onclick='copyCLIAP(\""
+ i + "\", " + wopmode_value + ")'" + rad + ">";
z.insertCell(6).innerHTML = apclist;
z.align = "center";											/** 設定欄位樣式 **/
z.style.lineHeight = "22px";
}
aplist_ary=aplists;
setTabStyle('stab');											/** 加入邊框 **/
setTimeout("document.getElementById('aptab').style.display=''", 1000);
setTimeout("document.getElementById('_sr_').style.display='none'", 1000);
if(wopmode_value == "2" || wopmode_value == "3"){
setTimeout("showhint(true);", 1000);
}
}
else{
document.getElementById('_sr_').style.display = 'none';
alert(GetElmCont("prim_0","Create AP List failed!"));
}
}
}
function showhint(isdisplay)	//WDS series mode，顯示copy mac提示訊息
{
for(var i = 0; i < 4; i++){
document.getElementById("span_copyhere" + i).style.display = (isdisplay) ? "" : "none";
}
}
function copyCLIAP(information, wopmode)
{
var ris =aplist_ary[information];
if(wopmode == "2" || wopmode == "3"){
for(var i = 0; i < 4; i++){
if(document.forms[0].copyhere[i].checked){
document.getElementById("id_apmac" + i).value = ris[5];
break;
}
}
}
else if(wopmode == "4"){
document.getElementById("id_clissid").value = ris[0];
if(ris[3]==7)	document.getElementById("id_cliauth").value = 5;	//WPA2-PSK
else document.getElementById("id_cliauth").value = ris[3];
chgauthmode(document.getElementById("id_auth"));
if(ris[4]==4) document.getElementById("id_cliencry").value = 3; //AES
else document.getElementById("id_cliencry").value = ris[4];
chgencrytype_ad(document.getElementById("id_cliencry"));
}
else{
document.getElementById("id_nssid").value = ris[0];
document.getElementById("id_wchannel").value = ris[1];
if(ris[3]==7)	document.getElementById("id_auth").value = 5;	//WPA2-PSK
else document.getElementById("id_auth").value = ris[3];
chgauthmode(document.getElementById("id_auth"));
if(ris[4]==4) document.getElementById("id_encry").value = 3; //AES
else document.getElementById("id_encry").value = ris[4];
chgencrytype(document.getElementById("id_encry"));
clientMAC = ris[5];
}
}
function disableRadios(rname)
{
var radio_object = eval("document.forms[0]." + rname);
if(radio_object){
for(var num = 0; num < radio_object.length; num++){
radio_object[num].disabled = true;
}
}
}
function saveWLANAPCLI()
{
var divRepeater = document.getElementById("div_REPEATER");
var wlanAPcliTag = "";
for(var setnum = 0; setnum < ap1_nameSet.length; setnum++){
var ap1_value = null;
if(setnum == 4){		/** 當為 radio時，暫時只能以這種方式處理 **/
var ap1_obj = eval("document.forms[0]." + ap1_nameSet[setnum]);
for(var index = 0; index < ap1_obj.length; index++){
if(ap1_obj[index].checked){
ap1_value = index + 1;
}
}
}
else{
ap1_value = eval("document.forms[0]." + ap1_nameSet[setnum] + ".value");
}
wlanAPcliTag += "<input type=\"hidden\" name=\"" + wlanapcli_nameSet[setnum]
+ "\" value=\"" + ap1_value +"\" > ";
}
wlanAPcliTag += "<input type=\"hidden\" name=\"" + wlanapcli_nameSet[setnum]
+ "\" value=\"" + ((clientMAC == null) ? "" : clientMAC) +"\" > ";
divRepeater.innerHTML = wlanAPcliTag;
disableRadios("rr");
}