<!-- Begin
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
//  End -->


function hgh1month(){
  mySelect = document.myForm.hgh1.selectedIndex;
  document.myForm.hgh1total.value = formatCurrency(mySelect * 70.00);
  getnytax();
}
function hgh3month(){
  mySelect = document.myForm.hgh3.selectedIndex;
  document.myForm.hgh3total.value = formatCurrency(mySelect * 190.00);
  getnytax();
}
function hgh6month(){
  mySelect = document.myForm.hgh6.selectedIndex;
  document.myForm.hgh6total.value = formatCurrency(mySelect * 310.00);
  getnytax();
}
function hgh9month(){
  mySelect = document.myForm.hgh9.selectedIndex;
  document.myForm.hgh9total.value = formatCurrency(mySelect * 450.00);
  getnytax();
}
function hgh12month(){
  mySelect = document.myForm.hgh12.selectedIndex;
  document.myForm.hgh12total.value = formatCurrency(mySelect * 560.00);
  getnytax();
}
function hairA(){
  mySelect = document.myForm.hair.selectedIndex;
  document.myForm.hairtotal.value = formatCurrency(mySelect * 60.00);
  getnytax();
}
function bloodA(){
  mySelect = document.myForm.blood.selectedIndex;
  document.myForm.bloodtotal.value = formatCurrency(mySelect * 60.00);
  getnytax();
}
function vclinic(){
  mySelect = document.myForm.clinic.selectedIndex;
  document.myForm.clinictotal.value = formatCurrency(mySelect * 0.00);
  getnytax();
}

function subtotal1(){
  var myHgh1 = 0;
  var myHgh3 = 0;
  var myHgh6 = 0;
  var myHgh9 = 0;
  var myHgh12 = 0;
  var myHair = 0;
  var myBlood = 0;
  var myClinic = 0;
  if(document.myForm.hgh1total.value){ myHgh1 = parseInt(document.myForm.hgh1total.value.replace("$", "")); }
  if(document.myForm.hgh3total.value){ myHgh3 = parseInt(document.myForm.hgh3total.value.replace("$", "")); }
  if(document.myForm.hgh6total.value){ myHgh6 = parseInt(document.myForm.hgh6total.value.replace("$", "")); }
  if(document.myForm.hgh9total.value){ myHgh9 = parseInt(document.myForm.hgh9total.value.replace("$", "")); }
  if(document.myForm.hgh12total.value){ myHgh12 = parseInt(document.myForm.hgh12total.value.replace("$", "")); }
  if(document.myForm.hairtotal.value){ myHair = parseInt(document.myForm.hairtotal.value.replace("$", "")); }
  if(document.myForm.bloodtotal.value){ myBlood = parseInt(document.myForm.bloodtotal.value.replace("$", "")); }
  if(document.myForm.clinictotal.value){ myClinic = parseInt(document.myForm.clinictotal.value.replace("$", "")); }

  var tmp1 = myHgh1 + myHgh3 + myHgh6 + myHgh9 + myHgh12 + myHair + myBlood + myClinic;

  return tmp1;
}

function gettax(){
  return formatCurrency(Math.round(subtotal1() * 0.08375 * 100) / 100);
}

function subtotal(){
   if(document.myForm.nytax.checked == true){ mytax = parseFloat(gettax().replace("$", "")); }else{ mytax = 0; }
   mySubtotal = subtotal1() + mytax;
   document.myForm.subtotal.value = formatCurrency(mySubtotal);
   return mySubtotal;
}

function getnytax(){
  mySelect = document.myForm.nytax.checked;
  if(mySelect == true){
	document.myForm.nytaxtotal.value = formatCurrency(gettax());
  }else{
	document.myForm.nytaxtotal.value = "";
  }
  subtotal();
}

function GrandTotal(){
   myNum = document.myForm.shippingcost.selectedIndex;
   mySelect = document.myForm.shippingcost[myNum].value;

   var total = subtotal() + parseInt(mySelect);   
   document.myForm.grandtotal.value = formatCurrency(total);

   return total;
}


function sameAddress(){
   document.myForm.shipping_jname.value = document.myForm.jname.value;
   document.myForm.shipping_title.value = document.myForm.title.value;
   document.myForm.shipping_efirstname.value = document.myForm.efirstname.value;
   document.myForm.shipping_elastname.value = document.myForm.elastname.value;
   document.myForm.shipping_emidname.value = document.myForm.emidname.value;
   document.myForm.shipping_street1.value = document.myForm.street1.value;
   document.myForm.shipping_street2.value = document.myForm.street2.value;
   document.myForm.shipping_city.value = document.myForm.city.value;
   document.myForm.shipping_state_jp.value = document.myForm.state_jp.value;
   document.myForm.shipping_state.value = document.myForm.state.value;
   document.myForm.shipping_other_state.value = document.myForm.other_state.value;
   document.myForm.shipping_country.value = document.myForm.country.value;
   document.myForm.shipping_zip_firsthalf.value = document.myForm.zip_firsthalf.value;
   document.myForm.shipping_zip_lasthalf.value = document.myForm.zip_lasthalf.value;
   document.myForm.shipping_tel_areacode.value = document.myForm.tel_areacode.value;
   document.myForm.shipping_tel_number.value = document.myForm.tel_number.value;
   document.myForm.shipping_fax_areacode.value = document.myForm.fax_areacode.value;
   document.myForm.shipping_fax_number.value = document.myForm.fax_number.value;
   document.myForm.shipping_zip_lasthalf.value = document.myForm.zip_lasthalf.value;

}


/********************************************************************/
/* [機能]半角英数字チェック                                               */
/* [説明]文字列に半角英数字以外の文字が存在するかチェックする。         */
/********************************************************************/
function Numcheck(st_val, message){
	var iCount;
	var iCode;
	for (iCount=0 ; iCount<st_val.length ; iCount++){
    	iCode = st_val.charCodeAt(iCount);
      	if ((48 > iCode || iCode > 57)){
			return message + "に数字以外が含まれています。\n";
		}
    }
	return "";
}

/********************************************************************/
/* [機能]必須入力チェック                                           */
/* [説明]文字列が入力されているかチェックする。                 */
/********************************************************************/
function Inputcheck(st_val, message){
	var iCount;
	var sTemp;

	if (st_val.length == 0){ 
		return message + "は必要項目です。記入してください。\n";
	}
	return "";
}

/********************************************************************/
/* [機能]半角英数字チェック                                               */
/* [説明]文字列に半角英数字以外の文字が存在するかチェックする。         */
/********************************************************************/
function Hankakucheck(st_val, message){
	var iCount;
	var iCode;
	for (iCount=0 ; iCount<st_val.length ; iCount++){
    	iCode = st_val.charCodeAt(iCount);
      	if((44<=iCode && iCode <=57) || (65<= iCode && iCode <=90) || (95 <= iCode && iCode <= 122) || 64 == iCode || 46 == iCode){
		}else{
			return message + "に半角英数字以外が含まれています。\n";
		}
    }
	return "";
}
/********************************************************************/
/* [機能]パスワード入力チェック                                           */
/* [説明]パスワードが正しく入力されているかチェックする。                 */
/********************************************************************/
function Pwdcheck(st_val1, st_val2){

	if (st_val1 != st_val2){ 
		return "メールアドレスがが正しくありません。\n";
		return false;
	}
	return "";
}
 
function ShippingMethod()
{
   var select1 = document.myForm.shippingcountry; //変数select1を宣言
   var select2 = document.myForm.shippingcost;
   select2.options.length = 0; // 選択肢の数がそれぞれに異なる場合、これが重要
   
   if (select1.options[select1.selectedIndex].value == "アメリカ全土＆領地" || select1.options[select1.selectedIndex].value == "")
   {
	select2.options[0] = new Option("Priority（2-3 Days)　$0.00", "0");
	select2.options[1] = new Option("EMS(1-2 Days) $15.00", "15");
   }
   if (select1.options[select1.selectedIndex].value == "日本"){
	select2.options[0] = new Option("MP (6-10 Days) $10.00", "10");
	select2.options[1] = new Option("EMS(4-6 Days)　$20.00", "20");
   }
   if (select1.options[select1.selectedIndex].value == "カナダ"){
	select2.options[0] = new Option("EMS (3-5 Days)　$15.00", "15");
   }
   if (select1.options[select1.selectedIndex].value == "その他海外"){
	select2.options[0] = new Option("EMS(3-7 Days)　$30.00", "30");
   }

} 

function getMethodName()
{
   var select1 = document.myForm.shippingcountry; //変数select1を宣言
   var select2 = document.myForm.shippingcost;
   
   if (select1.options[select1.selectedIndex].value == "アメリカ全土＆領地")
   {
        var usa = new Array("Priority（2-3 Days)　$0.00","EMS(1-2 Days) $15.00");
	document.myForm.shippingmethodname.value = usa[select2.selectedIndex];
   }
   if (select1.options[select1.selectedIndex].value == "日本"){
	var japan = new Array("MP (6-10 Days) $10.00", "EMS(4-6 Days)　$20.00");
        document.myForm.shippingmethodname.value = japan[select2.selectedIndex];
   }
   if (select1.options[select1.selectedIndex].value == "カナダ"){
	var canada = new Array("EMS (3-5 Days)　$15.00");
	document.myForm.shippingmethodname.value = canada[select2.selectedIndex];
   }
   if (select1.options[select1.selectedIndex].value == "その他海外"){
	var others = new Array("EMS(3-7 Days)　$30.00");
	document.myForm.shippingmethodname.value = others[select2.selectedIndex];
   }
} 

 
function chkForm()
{
   err_message = "";

   err_message += Inputcheck(document.myForm.efirstname.value, "請求先アドレス:お名前(FirstName)");
   err_message += Inputcheck(document.myForm.elastname.value,  "請求先アドレス:お名前(LastName)");
   err_message += Inputcheck(document.myForm.email.value,  "請求先アドレス:電子メール");
   err_message += Hankakucheck(document.myForm.email.value,  "請求先アドレス:電子メール");
   err_message += Inputcheck(document.myForm.verifyEmail.value,  "請求先アドレス:電子メール");
   err_message += Hankakucheck(document.myForm.verifyEmail.value,  "請求先アドレス:確認用電子メール");
   err_message += Pwdcheck(document.myForm.email.value, document.myForm.verifyEmail.value);
   err_message += Inputcheck(document.myForm.street1.value,  "請求先アドレス:番地");
   err_message += Inputcheck(document.myForm.city.value,  "請求先アドレス:市町村区");
   if((document.myForm.state.value.length == 0) && (document.myForm.state_jp.value.length == 0) && (document.myForm.other_state.value.length == 0)) { err_message += "請求先アドレス:州または都道府県情報は必要項目です。選択してください。\n";}
   err_message += Inputcheck(document.myForm.zip_firsthalf.value,  "請求先アドレス:郵便番号");
   //err_message += Numcheck(document.myForm.zip_firsthalf.value,  "請求先アドレス:郵便番号");
   err_message += Inputcheck(document.myForm.country.value,  "請求先アドレス:国");
   err_message += Inputcheck(document.myForm.tel_areacode.value,  "請求先アドレス:電話番号");
   //err_message += Numcheck(document.myForm.tel_areacode.value,  "請求先アドレス:電話番号");
   if(document.myForm.tel_areacode.value.length != 0){
       err_message += Inputcheck(document.myForm.tel_number.value,  "請求先アドレス:電話番号");
       //err_message += Numcheck(document.myForm.tel_number.value,  "請求先アドレス:電話番号");
   }

   err_message += Inputcheck(document.myForm.shipping_efirstname.value,  "発送先アドレス:お名前(FirstName)");
   err_message += Inputcheck(document.myForm.shipping_elastname.value,  "発送先アドレス:お名前(LastName)");
   err_message += Inputcheck(document.myForm.shipping_street1.value,  "発送先アドレス:番地");
   err_message += Inputcheck(document.myForm.shipping_city.value,  "発送先アドレス:市町村区");
   if((document.myForm.shipping_state.value.length == 0) && (document.myForm.shipping_state_jp.value.length == 0) && (document.myForm.shipping_other_state.value.length == 0)) { err_message += "発送先アドレス:州または都道府県情報は必要項目です。選択してください。\n";}
   err_message += Inputcheck(document.myForm.shipping_zip_firsthalf.value,  "発送先アドレス:郵便番号");
   //err_message += Numcheck(document.myForm.shipping_zip_firsthalf.value,  "発送先アドレス:郵便番号");
   err_message += Inputcheck(document.myForm.shipping_country.value,  "発送先アドレス:国");
   err_message += Inputcheck(document.myForm.shipping_tel_areacode.value,  "発送先アドレス:電話番号");
   //err_message += Numcheck(document.myForm.shipping_tel_areacode.value,  "発送先アドレス:電話番号");
   if(document.myForm.shipping_tel_areacode.value.length != 0){
        err_message += Inputcheck(document.myForm.shipping_tel_number.value,  "発送先アドレス:電話番号");
        //err_message += Numcheck(document.myForm.shipping_tel_number.value,  "発送先アドレス:電話番号");
   }
   err_message += Inputcheck(document.myForm.credit_number.value,  "クレジットカード番号");
   //err_message += Numcheck(document.myForm.credit_number.value,  "クレジットカード番号");
   err_message += Inputcheck(document.myForm.cardholder.value,  "クレジットカード名義人");
   //err_message += Hankakucheck(document.myForm.promotioncode.value,  "クレジットカード名義人");

   getMethodName();
   
   if(err_message == ""){
       return true;
   }else{
       alert(err_message);
       return false;
   }
}
