function cmdSend(acmd) {
  var f = document.form1;
  if (!checkInput()) {
    alert("Please input recipient address.");
    return;
  }
  cmdAdr('SEND_CONFIRM',acmd);
}

function addSign(no) {
  switch(no) {
    case 0 :
      sign = "##sign0##";
      break;
    case 1 :
      sign = "##sign1##"
      break;
    case 2 :
      sign = "##sign2##";
  }
  if (sign.length == 0) {
    no++;
    alert("no signature ("+no+")");
    return;
  }
  var f = document.form1;
  value = f.text.value;
  value += "\n"+sign;
  f.text.value = value;
}

function checkInput() {
  var f = document.form1;
  len = f.length;
  for (i=0; i<len; i++) {
    if (f.elements[i].name == "to" && f.elements[i].value.length != 0) {
      return true;
    }
  }
  return false;
}

function removeFile(name) {
  var f = document.form1;
  f.attach_file.value = name;
  f.cmd.value = "REMOVE_ATTACH_FILE";
  f.submit();
}

function attachFile() {
  var f = document.form2;
  if (f.attach_file.value.length == 0) {
    alert("Please select file.");
    return;
  }
  f.cmd.value = "UPLOAD";
  f.submit();
}

