/*-----------------------------------------------------
  by Mamiko.M(http://www.nmt.ne.jp/~mamiko/) 2005/8/1 →thanks!
 -----------------------------------------------------*/


function test(theForm){
	var radio_btn = 120;				//ラジオボタンの数をセット。

	var z_marks = 0;
	var e_marks = 0;
	var s_marks = 0;
	var h_marks = 0;
	var n_marks = 0;
	var m_marks = 0;

	var cnt = 10;
	var z = new Array("Q1","Q2","Q3","Q4","Q5","Q6","Q7","Q8","Q9","Q10");
	var e = new Array("Q11","Q12","Q13","Q14","Q15","Q16","Q17","Q18","Q19","Q20");
	var s = new Array("Q21","Q22","Q23","Q24","Q25","Q26","Q27","Q28","Q29","Q30");
	var h = new Array("Q31","Q32","Q33","Q34","Q35","Q36","Q37","Q38","Q39","Q40");
	var n = new Array("Q41","Q42","Q43","Q44","Q45","Q46","Q47","Q48","Q49","Q50");
	var m = new Array("Q51","Q52","Q53","Q54","Q55","Q56","Q57","Q58","Q59","Q60");
	
	var q_item = 60;				//問題の数をセット。
	var k = 0;
	
	for(var i=0; i<radio_btn; i++){		 //ラジオボタンの数だけ回す。
		if(theForm.elements[i].checked == true){
			k++;	//kにはチェック数が入る
			var radio_name = theForm.elements[i].name;
			var radio_mark = parseInt(theForm.elements[i].value);
			for(var j=0; j<cnt; j++){
				//z_marks,e_marks,s_marks,には点数が入る。
				if(z[j] == radio_name){
					z_marks = z_marks + radio_mark;
					break;
				}else if(e[j] == radio_name){
					e_marks = e_marks + radio_mark;
					break;
				}else if(s[j] == radio_name){
					s_marks = s_marks + radio_mark;
					break;
				}else if(h[j] == radio_name){
					h_marks = h_marks + radio_mark;
					break;
				}else if(n[j] == radio_name){
					n_marks = n_marks + radio_mark;
					break;
				}else if(m[j] == radio_name){
					m_marks = m_marks + radio_mark;
					break;
				}
			}
		}
	}
	if(k<q_item){
		msg = "すべての質問に回答してください。";
		alert(msg);
	}else{
		//各点数を判定。
		newwindow(z_marks,e_marks,s_marks,h_marks,n_marks,m_marks);
		return;
	}
}

function newwindow(z_marks,e_marks,s_marks,h_marks,n_marks,m_marks){
	//結果を表示するウインドウ。
	normal = "<font color=blue> [ふつう]</font>";
	heavy = "<font color=red> [強い]</font>";
	
	newWindow = open("","New_window","scrollbars=2,toolbars=0,width=400,height=400");
	newWindow.document.clear();

	newWindow.document.write("<html><body bgcolor=\"#f5f5dc\">");
	newWindow.document.write("あなたの体質診断結果<br>\n");
	newWindow.document.write("高得点なものがあなたのタイプです。<br>\n");
	newWindow.document.write("20〜29点があなたの該当するタイプ、<br>\n");
	newWindow.document.write("30点以上は既に身体に不調が出ていると思います。<br>\n");
	newWindow.document.write("高得点が複数ある場合は複合タイプです。<br>\n");
	newWindow.document.write("<blockquote>\n")
	if(z_marks > 0){
		newWindow.document.write("<font color=#4169e1>●気虚タイプ</font>：" + z_marks + "点");
		(z_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「気」が不足気味です。");
		newWindow.document.write("エネルギー不足で免疫力も低下しています。");
		newWindow.document.write("牛肉、かぼちゃ、納豆、山芋など身体を温める食事を！");
		newWindow.document.write("冷たいものや脂っぽい食物は避けましょう。");
		newWindow.document.write("</small><br>\n");
	}
	if(e_marks > 0){
		newWindow.document.write("<font color=#4169e1>●気滞タイプ</font>：" + e_marks + "点");
		(e_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「気」の流れがよくありません。");
		newWindow.document.write("自立神経のバランスが崩れていて、精神不安定です。");
		newWindow.document.write("朝、外に出て深呼吸を10回行ったり");
		newWindow.document.write("レバー、あさり、セロリなど、理気作用のある食事を！");
		newWindow.document.write("肝のはたらきをよくしたいので飲酒は控えましょう。");
		newWindow.document.write("</small><br>\n");
	}
	if(s_marks > 0){
		newWindow.document.write("<font color=#4169e1>●血虚タイプ</font>：" + s_marks + "点");
		(s_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「血」が不足気味です。");
		newWindow.document.write("肌や髪のトラブル、不妊症、心臓疾患も現れやすいです。");
		newWindow.document.write("うずら卵、プルーン、かきなどの捕血食材を取ってください。");
		newWindow.document.write("朝食をしっかり取って激しい運動は控えてください。");
		newWindow.document.write("</small><br>\n");
	}
	if(h_marks > 0){

		newWindow.document.write("<font color=#4169e1>●お血タイプ</font>：" + h_marks + "点");
		(h_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「血」の流れがよくありません。");
		newWindow.document.write("新陳代謝が悪く、関節症、頭痛を伴います。");
		newWindow.document.write("血行をよくする為にストレッチを習慣づけてください。");
		newWindow.document.write("いわし、さんま、桃、玄米などを取ってください。");
		newWindow.document.write("</small><br>\n");
	}
	if(n_marks > 0){
		newWindow.document.write("<font color=#4169e1>●陰虚タイプ</font>：" + n_marks + "点");
		(n_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「津液（潤い）」が不足気味です。");
		newWindow.document.write("のぼせ、眩暈、乾燥などの更年期症状が現れます。");
		newWindow.document.write("すっぽん、あわび、きゅうり、梨などを食してください。");
		newWindow.document.write("昼型生活を心掛け、タバコお酒を控えてください。");
		newWindow.document.write("</small><br>\n");
	}
	if(m_marks > 0){

		newWindow.document.write("<font color=#4169e1>●痰湿タイプ</font>：" + m_marks + "点");
		(m_marks > 20)?newWindow.document.write(heavy):newWindow.document.write(normal);
		newWindow.document.write("<br><small>\n");
		newWindow.document.write("「津液（潤い）」の流れがよくありません。");
		newWindow.document.write("新陳代謝が悪く、体内に余分な水分脂肪が溜まりやすいです。");
		newWindow.document.write("代謝をよくするはと麦、根菜、緑豆春雨などを取りましょう。");
		newWindow.document.write("暴飲暴食をしない、運動をして水分を取り過ぎないように。");
		newWindow.document.write("</small><br>\n");
	}
	newWindow.document.write("</blockquote>\n");
	newWindow.document.write("</body></html>");
	newWindow.document.close();
	newWindow.focus();
	return;
}

