//フォームの内容チェック
function FormCheck(num){
  //購入ページ
  if(num == 0){
    //「お名前」が入力されていない場合
    if(document.buy.namae.value == ""){
      alert("「お名前」を入力して下さい。");
      return;
    }
    //「郵便番号」が入力されていない場合
    if((document.buy.addr1.value == "") || (document.buy.addr2.value == "")){
      alert("「郵便番号」を入力して下さい。");
      return;
    }
    //「都道府県」が選択されていない場合
    if(document.buy.addr3.value == ""){
      alert("「都道府県」が選択されていません。");
      return;
    }
    //「ご住所」が入力されていない場合
    if(document.buy.addr4.value == ""){
      alert("「ご住所」を入力して下さい。");
      return;
    }
    //「電話番号」が入力されていない場合
    if(document.buy.tel.value == ""){
      alert("「電場番号」を入力して下さい。");
      return;
    }
    //「E-Mail」が入力されていない場合
    if(document.buy.email.value == ""){
      alert("「E-Mail」を入力して下さい。");
      return;
    }
    //「注文商品」の数量が入力されているか
    if((document.buy.kind1.value == 0) && (document.buy.kind2.value == 0) && (document.buy.kind3.value == 0) && (document.buy.kind4.value == 0) && (document.buy.kind5.value == 0) && (document.buy.comment.value == "")){
      alert("「注文商品」の個数を入力して下さい。");
      return;
    }

    document.buy.action = "cgi-bin/buy.cgi";
    document.buy.submit();
  }

  //ユーザー登録ページ
  if(num == 1){
    //「お名前」が入力されていない場合
    if(document.touroku.namae.value == ""){
      alert("「お名前」を入力して下さい。");
      return;
    }
    //「フリガナ」が入力されていない場合
    if(document.touroku.kana.value == ""){
      alert("「フリガナ」を入力して下さい。");
      return;
    }
    //「郵便番号」が入力されていない場合
    if((document.touroku.addr1.value == "") || (document.touroku.addr2.value == "")){
      alert("「郵便番号」を入力して下さい。");
      return;
    }
    //「ご住所」が入力されていない場合
    if(document.touroku.addr3.value == ""){
      alert("「ご住所」を入力して下さい。");
      return;
    }
    //「電話番号」が入力されていない場合
    if(document.touroku.tel.value == ""){
      alert("「電場番号」を入力して下さい。");
      return;
    }
    //「E-Mail」が入力されていない場合
    if(document.touroku.email.value == ""){
      alert("「E-Mail」を入力して下さい。");
      return;
    }
    //シリアル番号の桁数チェック
    if(document.touroku.serial1.value != ""){
      if(document.touroku.serial1.value.length != 12){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.touroku.serial2.value.length != 8){
        alert("「シリアル番号」が違います。");
        return;
      }
    }
    else{
      if(document.touroku.serial2_1.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.touroku.serial2_2.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.touroku.serial2_3.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.touroku.serial2_4.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
    }
    document.touroku.action = "cgi-bin/touroku.cgi";
    document.touroku.submit();
  }

  //問い合わせページ
  if(num == 2){
    //「お名前」が入力されていない場合
    if(document.contact.namae.value == ""){
      alert("「お名前」を入力して下さい。");
      return;
    }
    //「E-Mail」が入力されていない場合
    if(document.contact.email.value == ""){
      alert("「E-Mail」を入力して下さい。");
      return;
    }
    //シリアル番号の桁数チェック
    if(document.contact.serial1.value != ""){
      if(document.contact.serial1.value.length != 12){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.contact.serial2.value.length != 8){
        alert("「シリアル番号」が違います。");
        return;
      }
    }
    if(document.contact.serial2_1.value !=""){
      if(document.contact.serial2_1.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.contact.serial2_2.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.contact.serial2_3.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
      if(document.contact.serial2_4.value.length != 5){
        alert("「シリアル番号」が違います。");
        return;
      }
    }
    document.contact.action = "cgi-bin/contact.cgi";
    document.contact.submit();
  }

  //販売代理店募集ページ
  if(num == 3){
    //「社名」が入力されていない場合
    if(document.bosyu.company.value == ""){
      alert("「社名」を入力して下さい。");
      return;
    }
    //「担当者名（漢字）」が入力されていない場合
    if(document.bosyu.namae.value == ""){
      alert("「担当者名（漢字）」を入力して下さい。");
      return;
    }
    //「担当者名（フリガナ）」が入力されていない場合
    if(document.bosyu.kana.value == ""){
      alert("「担当者名（フリガナ）」を入力して下さい。");
      return;
    }
    //「郵便番号」が入力されていない場合
    if((document.bosyu.addr1.value == "") || (document.bosyu.addr2.value == "")){
      alert("「郵便番号」を入力して下さい。");
      return;
    }
    //「都道府県」が選択されていない場合
    if(document.bosyu.addr3.value == ""){
      alert("「都道府県」が選択されていません。");
      return;
    }
    //「ご住所」が入力されていない場合
    if(document.bosyu.addr4.value == ""){
      alert("「ご住所」を入力して下さい。");
      return;
    }
    //「電話番号」が入力されていない場合
    if(document.bosyu.tel.value == ""){
      alert("「電場番号」を入力して下さい。");
      return;
    }
    //「E-Mail」が入力されていない場合
    if(document.bosyu.email.value == ""){
      alert("「E-Mail」を入力して下さい。");
      return;
    }

    document.bosyu.action = "cgi-bin/dairiten.cgi";
    document.bosyu.submit();
  }
}