menuButton=new Array();
for(i=0;i<14;i++){
	menuButton[i]=new Image();
}
menuButton[0].src="image/menu_top.gif";
menuButton[1].src="image/menu_top_over.gif";
menuButton[2].src="image/menu_jirei.gif";
menuButton[3].src="image/menu_jirei_over.gif";
menuButton[4].src="image/menu_nagare.gif";
menuButton[5].src="image/menu_nagare_over.gif";
menuButton[6].src="image/menu_company.gif";
menuButton[7].src="image/menu_company_over.gif";
menuButton[8].src="image/menu_toiawase.gif";
menuButton[9].src="image/menu_toiawase_over.gif";
menuButton[10].src="image/menu_reform.gif";
menuButton[11].src="image/menu_reform_over.gif";
menuButton[12].src="image/menu_sickhouse.gif";
menuButton[13].src="image/menu_sickhouse_over.gif";

function swapMenuImage(imgName,num){
	document.images[imgName].src=menuButton[num].src;
}

// 住宅金融公庫ローン計算
function calcLoan(){
	// 借り入れ金額の入力形式チェック
	if (!checkNumber(document.LOAN_FORM.DEBT.value)) {
		alert("借り入れ金額は整数を入力して下さい");
		return;
	}
	else if (document.LOAN_FORM.DEBT.value == "") {
		alert("借り入れ金額を入力して下さい");
		return;
	}
	// 金利の入力形式チェック
	if (!checkNumber(document.LOAN_FORM.RATE.value)) {
		alert("金利は整数を入力して下さい");
		return;
	}
	else if (document.LOAN_FORM.RATE.value == "") {
		alert("金利を入力して下さい");
		return;
	}

	// 借り入れ金額
	debt  = eval(document.LOAN_FORM.DEBT.value) * 10000;
	// 返済年数
	year  = eval(document.LOAN_FORM.YEAR.value);
	// ボーナス返済の割合
	bonus = eval(document.LOAN_FORM.BONUS.value) / 100;
	// 金利
	rate  = eval(1 * document.LOAN_FORM.RATE.value) / 100;

	// 借り入れ金額の変換＆チェック
	if (debt < 1000000 || debt > 35000000) {
		alert('借り入れ金額は100万円〜3000万円の範囲で入力して下さい');
		return;
	}

	// 月々の返済金額(切捨て)
	result_month = debt * (1 - bonus) * (rate / 12) * Math.pow((1 + rate / 12),(year * 12)) / (Math.pow((1 + rate / 12),(year * 12)) - 1);
	document.LOAN_FORM.RESULT_MONTH.value = Math.floor(result_month);

	// 年間のボーナス回数
	b_count = Math.floor((year * 12) / 6);
	// ボーナス月の加算額
	result_bonus = debt * bonus * (rate / 2) * Math.pow((1 + rate / 2),(b_count - 1)) * (1 + rate / 2) / (Math.pow((1 + rate / 2),b_count) - 1);
	document.LOAN_FORM.RESULT_BONUS.value = Math.floor(result_bonus);

	// 年間返済金額
	result_year = Math.floor(result_month) * 12 + Math.floor(result_bonus) * 2;
	document.LOAN_FORM.RESULT_YEAR.value = Math.floor(result_year);

	// 合計返済金額
	result_total = Math.floor(result_month) * (year * 12) + Math.floor(result_bonus) * b_count;
	document.LOAN_FORM.RESULT_TOTAL.value = Math.floor(result_total);

	// 合計返済回数
	document.LOAN_FORM.RESULT_NUMBER.value = year * 12;
}

// 入力形式チェック
function checkNumber(value) {
	for(i = 0; i < value.length; i++) {
		str = value.substring(i, i +1) ;
		if (str == "0" || str == "1" || str == "2" || str == "3" || str == "4" || str == "5" || str == "6" || str == "7" || str == "8" || str == "9" || str == ".") {
			 continue;
		}
		else {
			return false;
		}
	}
	return true;
}

// END --->
