function CheckEmail(strTarget){
  if(strTarget.match(/[^a-zA-Z0-9_\.\-@]/)){ return false; }
  p=strTarget.indexOf("@",1);
  if(strTarget.length==p+1){ return false; }
  else{
    for(i=p+1;i<strTarget.length;i++){
    Charactor=strTarget.charAt(i);
      if(Charactor=="."){
        if(i==p+1 || i==strTarget.length-1){ return false; }
      }
      else if(Charactor=="@"){ return false; }
    }
  }

  atPos = strTarget.indexOf("@",1)
  if(atPos == -1) { return false; }

  if(strTarget.indexOf("@", atPos+1) != -1) { return false; }

  periodPos = strTarget.indexOf(".",atPos)
  if(periodPos == -1) { return false; }
}

function Check() {
  var error_string = "";
  var loop = "";

  if (document.formmail.event.value=="") {
    error_string += "「イベント名」\n";
  }

  if (document.formmail.sponsor.value=="") {
    error_string += "「主催」\n";
  }

  if ((document.formmail.address1.value=="") || (document.formmail.address2.value=="")) {
    error_string += "「開催場所」\n";
  }

  if ((document.formmail.open_m.value=="") || (document.formmail.open_d.value=="")) {
    error_string += "「開催日」\n";
  }

  if(window.document.formmail.publish.length > 0) {
    var publish_chk = "100";
    for (var loop = 0; loop < window.document.formmail.publish.length; loop++) {
      if (window.document.formmail.publish[loop].checked == true) {
       publish_chk = 1;
      }
    }
    if(publish_chk != 1) {
      error_string += "「掲載希望日」\n";
    }
  }
  else {  
    if (document.formmail.publish.checked == false) {
      error_string += "「掲載希望日」\n";
    }
  }

  if (document.formmail.mail.value=="") {
    error_string += "「メールアドレス」\n";
  }
  else {
    if(CheckEmail(document.formmail.mail.value)==false){
      error_string += "「メールアドレス」を正しく入力して下さい\n";
    }
  }

  if (document.formmail.com.value=="") {
    error_string += "「記事内容」\n";
  }

  if (error_string == "") {
    return true;
  } else {
    error_string = "以下の項目を入力してください。\n" + error_string;
    alert (error_string);
    return false;
  }
}
