var band_type=new Array('2g','3g','3g','4g','4g');
var band_typeid=new Array('2g','3gf','3gt','4gf','4gt');
var work_blist_arr_2g=new Array();
var work_blist_arr_3gf=new Array();
var work_blist_arr_3gt=new Array();
var work_blist_arr_4gf=new Array();
var work_blist_arr_4gt=new Array();
/*
sim_arr�M�w�n��sima�٬Osima,simb����
�]��3g,4g�O�����G�ӡAŪ��234g�ʧ@�O�@�˪� �ҥH��band_type�A���רM�w���X��
band_type�O���n����div
band_typeid�O���n����csid
Ū���覡
(1)��234g�����ܪ�band��csid���ର�G�i��
(2)�s���}�C���A�����A���K����band�X
���K���}�C�s��work_blist_arr_2g �̡A���K�̫��s�ɮɪ��D�O���X��band�ζ���
�s�ɮɬO�q�̫��@�Ӷ}�l�O�A�����A�Ϧ^�ӡA���K�ন�Q�i���A�A�s��������csid
*/
function swBandList(){
var type = (document.getElementById('h_singlA') != null)?'a':'b';
/*CTA H21 remove
var set_bandchk=(document.getElementById('band_single').value==1)?"onclick=\"set_bandchk(this,'"+type+"');\"":"";
for(j=0;j< band_type.length;j++){
var sw_div="";
var band=band_typeid[j];
var band_arr=eval("band_arr_"+band);
bandv=parseInt(document.getElementById("band_"+band).value);
bandv=bandv.toString(2);
bandv_arr=bandv.split("");
bandv_arr=bandv_arr.reverse();
if(band=='2g') work_blist_arr_2g=bandv_arr.slice();
if(band=='3gf') work_blist_arr_3gf=bandv_arr.slice();
if(band=='3gt') work_blist_arr_3gt=bandv_arr.slice();
if(band=='4gf') work_blist_arr_4gf=bandv_arr.slice();
if(band=='4gt') work_blist_arr_4gt=bandv_arr.slice();
sbandv=parseInt(document.getElementById("band_"+band+"_"+type).value);
sbandv=sbandv.toString(2);
sbandv_arr=sbandv.split("");
sbandv_arr=sbandv_arr.reverse();
for(k=0;k< bandv_arr.length;k++){
if(bandv_arr[k]==1){
var bandchk=(sbandv_arr[k]==1)?"checked":"";
sw_div+="<br><input type='checkbox' id='c_b"+band+"_"+type+"_"+k+"' name=blist_"+type+" "+set_bandchk+" "+bandchk+">"+band_arr[k];
}
}
document.getElementById("sw_blist_"+band_type[j]+"_"+type).innerHTML+=sw_div;
}
*/
chgband(type,1);  //set Network Type options
}
function chgband(type,num){
/*
for 3G Network Type chagne
0:Auto-2G,3G,4G
1:2G Only-2G
2:2G Prefer-2G,3G,4G
3:3G Only-3G
4:3G Prefer-2G,3G,4G
5:LTE Only-4G
Network Type��CSID����(2G Only,2G Prefer...��)����1�ɤ����ܡA�w�]��0
num �s�b�N���O�Ĥ@���i�J����
*/
var objSelect=document.getElementById('s_network_type');
var inter = document.getElementById("s_interface");
var swLTE=0;
var sw3G=0;
var sw2G=0;
var pmode_ary0 = new Array(
"", //options[0]
"", //options[1]
"", //options[2]
"", //options[3]
"", //options[4]
"" //options[5]
)
var pmode_ary1 = new Array(
"", //options[0]
"", //options[1]
"", //options[2]
"", //options[3]
"", //options[4]
"" //options[5]
)
var Pmode_ary = (inter.value == 0)?pmode_ary0:pmode_ary1;
if((num!=null)&&(Pmode_ary[5] == '1')) objSelect.options[5] = null;
if((num!=null)&&(Pmode_ary[4] == '1')) objSelect.options[4] = null;
if((num!=null)&&(Pmode_ary[3] == '1')) objSelect.options[3] = null;
if((num!=null)&&(Pmode_ary[2] == '1')) objSelect.options[2] = null;
if((num!=null)&&(Pmode_ary[1] == '1')) objSelect.options[1] = null;
if((num!=null)&&(Pmode_ary[0] == '1')) objSelect.options[0] = null;
/*CTA H21 remove
var ntype=document.getElementById('s_ntype_'+type).value;
var bselect=document.getElementById('s_bselect_'+type).value;
if(objSelect.length == 0){  //Network Type is empty
document.getElementById('sw_blist_2g_'+type).style.display="none";
document.getElementById('sw_blist_3g_'+type).style.display="none";
document.getElementById('sw_blist_4g_'+type).style.display="none";
}else{
document.getElementById('sw_blist_2g_'+type).style.display=(ntype!=2&&ntype!=5&&sw2G!=2)?"":"none";
document.getElementById('sw_blist_3g_'+type).style.display=(ntype!=1&&ntype!=5&&sw3G!=2)?"":"none";
document.getElementById('sw_blist_4g_'+type).style.display=(ntype!=1&&ntype!=2&&swLTE!=1)?"":"none";
}
chkobj_disaled('blist_'+type,(bselect==0));
*/
}
function chkobj_disaled(obj,chk)
{
var tmp_disabled = document.getElementsByName(obj);
var bsingle = document.getElementById('band_single').value;
for(var t=0;t<tmp_disabled.length;t++)
{
tmp_disabled[t].disabled=chk;
if(chk) tmp_disabled[t].checked=true;
else if(bsingle==1) {tmp_disabled[t].checked=chk;}
}
}
function set_bandchk(obj,type){
if(obj.checked){
chkobj_disaled('blist_'+type,false)
obj.checked=true;
}
}
function saveBandList(opx){
var type = (document.getElementById('h_singlA') != null)?'a':'b';
var ntype=document.getElementById('s_network_type').value;
var bselect=document.getElementById('s_bselect_'+type).value;
var use_band_type=new Array();
var use_band_type=[];
var use_band_name=[];
var chk_use_2g=0;
var chk_use_3g=0;
var chk_use_4g=0;
var chk_list_2g=0;
var chk_list_3g=0;
var chk_list_4g=0;
var int0 = "";
var int00 = false;
var message = "Please choose Band Lists.";
if(ntype!=2&&ntype!=5){
use_band_type.push('2g');
use_band_name.push('2g');
}
if(ntype!=1&&ntype!=5){
use_band_type.push('3gf');
use_band_type.push('3gt');
use_band_name.push('3g');
use_band_name.push('3g');
}
if(ntype!=1&&ntype!=2){
use_band_type.push('4gf');
use_band_type.push('4gt');
use_band_name.push('4g');
use_band_name.push('4g');
}
for(j=0;j< use_band_type.length;j++){
var sband_arr=eval('work_blist_arr_'+use_band_type[j])
var use_band="";
var chk_use=0;
var chk_list=0;
var save_band=document.getElementById("band_"+use_band_type[j]+"_"+type);
var bandv=document.getElementById("band_"+use_band_type[j]).value;
if(bandv!=""&&bandv!="0"){  //band list�Ȥ����ťեB����0��  chk_list+1
for(k=sband_arr.length-1;k>=0 ;k--){
if(sband_arr[k]==1){
band_enable=document.getElementById("c_b"+use_band_type[j]+"_"+type+"_"+k);
use_band+=(band_enable.checked)?"1":"0";
if(band_enable.checked) chk_use+=1;
}else{
use_band+="0";
}
}
chk_list+=1;
}
if(use_band!=""){
use_band=parseInt(use_band,2)
save_band.value=use_band;
}
int0 += "&"+save_band.name+"="+save_band.value
if(use_band_name[j]=='2g') {
chk_list_2g+=chk_list;
chk_use_2g+=chk_use;
}
if(use_band_name[j]=='3g') {
chk_list_3g+=chk_list;
chk_use_3g+=chk_use;
}
if(use_band_name[j]=='4g') {
chk_list_4g+=chk_list;
chk_use_4g+=chk_use;
}
}
int1 = document.getElementById('s_bselect_'+type).name+"="+bselect
for(l=0;l<use_band_name.length;l++){
chk_list=eval('chk_list_'+use_band_name[l]);
chk_use=eval('chk_use_'+use_band_name[l]);
if(chk_list!=0&&chk_use==0){
int00 = true;
break ;
}
}
int0 = int1+int0
if(int00){  alert(message);  return false;   }
else if(opx == null){  return true;  }
else{  return int0;   }
}