function changetype(type){
  if(type=='ssid_ascii_32' || type=='wep_ascii_5' || type=='wep_ascii_13' || type=='wep_ascii_16' || type=='wep_ascii_29' || type=='wpa_ascii_63') enablecharset();
  if(type=='wep_hex_10' || type=='wep_hex_26' || type=='wep_hex_32' || type=='wep_hex_58' || type=='wpa_hex_64') disablecharset();
  if(type=='ssid_ascii_32' || type=='wpa_ascii_63') {
    document.forms[0].elements[4].disabled=false;
    if(type=='ssid_ascii_32')addfields(1,32);
    if(type=='wpa_ascii_63')addfields(8,63);
  }
  else document.forms[0].elements[4].disabled=true;
};
function disablecharset(){
  document.forms[0].elements[1].disabled=true;
  document.forms[0].elements[2].disabled=true;
  document.forms[0].elements[3].disabled=true;
}
function enablecharset(){
  document.forms[0].elements[1].disabled=false;
  document.forms[0].elements[2].disabled=false;
  document.forms[0].elements[3].disabled=false;
}
function addfields(istart, iend){
  do{
    if(document.forms[0].elements["charsetlength"].options.length>0) document.forms[0].elements["charsetlength"].options[document.forms[0].elements["charsetlength"].options.length-1]=null
  }while(document.forms[0].elements["charsetlength"].options.length>0);
  for(i=istart;i<=iend;i++){
    document.forms[0].elements["charsetlength"].options[document.forms[0].elements["charsetlength"].options.length] = new Option(i,i);
    if(i==iend)document.forms[0].elements["charsetlength"].options[document.forms[0].elements["charsetlength"].options.length-1].selected = true;  }
};

