function sCalcPrice(){
  var howmany = eval(document.hanbaiform.howmany.value);
  var price = 0;
  var unit = eval(document.hanbaiform.sale_unit.value);

  if(document.hanbaiform.sale_kubun1.value != ""){
    if(howmany * unit >= eval(document.hanbaiform.sale_kubun1.value)){
      if(document.hanbaiform.sale_kubun2.value != ""){
        if(howmany * unit < eval(document.hanbaiform.sale_kubun2.value)){
          price = howmany * document.hanbaiform.kubun1.value;
        }else if(howmany * unit >= eval(document.hanbaiform.sale_kubun2.value)){
          if(document.hanbaiform.sale_kubun3.value != ""){
            if(howmany * unit < eval(document.hanbaiform.sale_kubun3.value)){
              price = howmany * document.hanbaiform.kubun2.value;
            }else{
              if(document.hanbaiform.sale_kubun4.value != ""){
                if(howmany * unit < eval(document.hanbaiform.sale_kubun4.value)){
                  price = howmany * document.hanbaiform.kubun3.value;
                }else{
                  if(document.hanbaiform.sale_kubun5.value != ""){
                    if(howmany * unit < eval(document.hanbaiform.sale_kubun5.value)){
                      price = howmany * document.hanbaiform.kubun4.value;
                    }else{
                      price = howmany * document.hanbaiform.kubun5.value;
                    }
                  }else{
                    price = howmany * document.hanbaiform.kubun4.value;
                  }
                }
              }else{
                if(document.hanbaiform.sale_kubun5.value == ""){
                  price = howmany * document.hanbaiform.kubun3.value;
                }
              }
            }
          }else{
            if(document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
              price = howmany * document.hanbaiform.kubun2.value;
            }
          }
        }
      }else{
        if(document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
          price = howmany * document.hanbaiform.kubun1.value;
        }
      }
    }else{
      price = howmany * document.hanbaiform.kubun1.value;
    }
  }else{
    if(document.hanbaiform.sale_kubun2.value == "" && document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
      price = howmany * document.hanbaiform.kubun1.value;
    }
  }

//  if(document.hanbaiform.pay[document.hanbaiform.pay.selectedIndex].text == "WebMoney"){
//    price = parseInt(price * 1.1);
//  }
//  document.hanbaiform.price.value = addFigure(price);
  document.hanbaiform.price.value = price;
}
function sCalcPriceMu(){
  var howmany1 = eval(document.hanbaiform.howmany1.value);
  var howmany2 = eval(document.hanbaiform.howmany2.value);
  var howmany3 = eval(document.hanbaiform.howmany3.value);
  var price = 0;
  var unit = eval(document.hanbaiform.sale_unit.value);

  if(document.hanbaiform.sale_kubun1.value != ""){
    if(howmany1 * unit >= eval(document.hanbaiform.sale_kubun1.value)){
      if(document.hanbaiform.sale_kubun2.value != ""){
        if(howmany1 * unit < eval(document.hanbaiform.sale_kubun2.value)){
          price1 = howmany1 * document.hanbaiform.kubun1_1.value;
        }else if(howmany1 * unit >= eval(document.hanbaiform.sale_kubun2.value)){
          if(document.hanbaiform.sale_kubun3.value != ""){
            if(howmany1 * unit < eval(document.hanbaiform.sale_kubun3.value)){
              price1 = howmany1 * document.hanbaiform.kubun1_2.value;
            }else{
              if(document.hanbaiform.sale_kubun4.value != ""){
                if(howmany1 * unit < eval(document.hanbaiform.sale_kubun4.value)){
                  price1 = howmany1 * document.hanbaiform.kubun1_3.value;
                }else{
                  if(document.hanbaiform.sale_kubun5.value != ""){
                    if(howmany1 * unit < eval(document.hanbaiform.sale_kubun5.value)){
                      price1 = howmany1 * document.hanbaiform.kubun1_4.value;
                    }else{
                      price1 = howmany1 * document.hanbaiform.kubun1_5.value;
                    }
                  }else{
                    price1 = howmany1 * document.hanbaiform.kubun1_4.value;
                  }
                }
              }else{
                if(document.hanbaiform.sale_kubun5.value == ""){
                  price1 = howmany1 * document.hanbaiform.kubun1_3.value;
                }
              }
            }
          }else{
            if(document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
              price1 = howmany1 * document.hanbaiform.kubun1_2.value;
            }
          }
        }
      }else{
        if(document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
          price1 = howmany1 * document.hanbaiform.kubun1_1.value;
        }
      }
    }else{
      price1 = howmany1 * document.hanbaiform.kubun1_1.value;
    }
  }else{
    if(document.hanbaiform.sale_kubun2.value == "" && document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
      price1 = howmany1 * document.hanbaiform.kubun1_1.value;
    }
  }



  if(document.hanbaiform.sale_kubun1.value != ""){
    if(howmany2 * unit >= eval(document.hanbaiform.sale_kubun1.value)){
      if(document.hanbaiform.sale_kubun2.value != ""){
        if(howmany2 * unit < eval(document.hanbaiform.sale_kubun2.value)){
          price2 = howmany2 * document.hanbaiform.kubun2_1.value;
        }else if(howmany2 * unit >= eval(document.hanbaiform.sale_kubun2.value)){
          if(document.hanbaiform.sale_kubun3.value != ""){
            if(howmany2 * unit < eval(document.hanbaiform.sale_kubun3.value)){
              price2 = howmany2 * document.hanbaiform.kubun2_2.value;
            }else{
              if(document.hanbaiform.sale_kubun4.value != ""){
                if(howmany2 * unit < eval(document.hanbaiform.sale_kubun4.value)){
                  price2 = howmany2 * document.hanbaiform.kubun2_3.value;
                }else{
                  if(document.hanbaiform.sale_kubun5.value != ""){
                    if(howmany2 * unit < eval(document.hanbaiform.sale_kubun5.value)){
                      price2 = howmany2 * document.hanbaiform.kubun2_4.value;
                    }else{
                      price2 = howmany2 * document.hanbaiform.kubun2_5.value;
                    }
                  }else{
                    price2 = howmany2 * document.hanbaiform.kubun2_4.value;
                  }
                }
              }else{
                if(document.hanbaiform.sale_kubun5.value == ""){
                  price2 = howmany2 * document.hanbaiform.kubun2_3.value;
                }
              }
            }
          }else{
            if(document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
              price2 = howmany2 * document.hanbaiform.kubun2_2.value;
            }
          }
        }
      }else{
        if(document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
          price2 = howmany2 * document.hanbaiform.kubun2_1.value;
        }
      }
    }else{
      price2 = howmany2 * document.hanbaiform.kubun2_1.value;
    }
  }else{
    if(document.hanbaiform.sale_kubun2.value == "" && document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
      price2 = howmany2 * document.hanbaiform.kubun2_1.value;
    }
  }



  if(document.hanbaiform.sale_kubun1.value != ""){
    if(howmany3 * unit >= eval(document.hanbaiform.sale_kubun1.value)){
      if(document.hanbaiform.sale_kubun2.value != ""){
        if(howmany3 * unit < eval(document.hanbaiform.sale_kubun2.value)){
          price3 = howmany3 * document.hanbaiform.kubun3_1.value;
        }else if(howmany3 * unit >= eval(document.hanbaiform.sale_kubun2.value)){
          if(document.hanbaiform.sale_kubun3.value != ""){
            if(howmany3 * unit < eval(document.hanbaiform.sale_kubun3.value)){
              price3 = howmany3 * document.hanbaiform.kubun3_2.value;
            }else{
              if(document.hanbaiform.sale_kubun4.value != ""){
                if(howmany3 * unit < eval(document.hanbaiform.sale_kubun4.value)){
                  price3 = howmany3 * document.hanbaiform.kubun3_3.value;
                }else{
                  if(document.hanbaiform.sale_kubun5.value != ""){
                    if(howmany3 * unit < eval(document.hanbaiform.sale_kubun5.value)){
                      price3 = howmany3 * document.hanbaiform.kubun3_4.value;
                    }else{
                      price3 = howmany3 * document.hanbaiform.kubun3_5.value;
                    }
                  }else{
                    price3 = howmany3 * document.hanbaiform.kubun3_4.value;
                  }
                }
              }else{
                if(document.hanbaiform.sale_kubun5.value == ""){
                  price3 = howmany3 * document.hanbaiform.kubun3_3.value;
                }
              }
            }
          }else{
            if(document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
              price3 = howmany3 * document.hanbaiform.kubun3_2.value;
            }
          }
        }
      }else{
        if(document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
          price3 = howmany3 * document.hanbaiform.kubun3_1.value;
        }
      }
    }else{
      price3 = howmany3 * document.hanbaiform.kubun3_1.value;
    }
  }else{
    if(document.hanbaiform.sale_kubun2.value == "" && document.hanbaiform.sale_kubun3.value == "" && document.hanbaiform.sale_kubun4.value == "" && document.hanbaiform.sale_kubun5.value == ""){
      price3 = howmany3 * document.hanbaiform.kubun3_1.value;
    }
  }



  price = price1 + price2 + price3;

//  if(document.hanbaiform.pay[document.hanbaiform.pay.selectedIndex].text == "WebMoney"){
//    price = parseInt(price * 1.1);
//  }
//  document.hanbaiform.price.value = addFigure(price);
  document.hanbaiform.price.value = price;
}
function sCalcKaitoriPrice(){
  var price = eval(document.hanbaiform.kaitori_price.value) * document.hanbaiform.howmany.value;

//  document.hanbaiform.price.value = addFigure(price);
  document.hanbaiform.price.value = price;
}
function sCalcKaitoriPrice2(){
  var price1 = document.hanbaiform.kaitori_price1.value * document.hanbaiform.howmany1.value;
  var price2 = document.hanbaiform.kaitori_price2.value * document.hanbaiform.howmany2.value;
  var price3 = document.hanbaiform.kaitori_price3.value * document.hanbaiform.howmany3.value;

  var price = price1*1 + price2*1 + price3*1;
//  document.hanbaiform.price.value = addFigure(price);
  document.hanbaiform.price.value = price;
}
function addFigure(str) {
  var num = new String(str).replace(/,/g, "");
  while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
  return num;
}


function zaikoAlert(cnt) {
  if(document.hanbaiform.howmany.value > cnt){
    if(confirm("現在在庫がございません。\n予約申し込みしますか？")){
      document.hanbaiform.submit();
    }
  }else{
    document.hanbaiform.submit();
  }
}

function zaikoAlertMu(cnt1,cnt2,cnt3) {
  var alert_fg = 0;

  if(document.hanbaiform.howmany1.value > cnt1){
    alert_fg = 1;
  }else if(document.hanbaiform.howmany2.value > cnt2){
    alert_fg = 1;
  }else if(document.hanbaiform.howmany3.value > cnt3){
    alert_fg = 1;
  }
  if(alert_fg == 1){
    if(confirm("現在在庫がございません。\n予約申し込みしますか？")){
      document.hanbaiform.submit();
    }
  }else{
    document.hanbaiform.submit();
  }
}
