// -----------------------------------------------
// zΜdͺθ
//-----------------------------------------------
function fnc_keisan(){
	var fm=document.keisan;
	var shin=fnc_han(fm.shintyou.value);
	var taij=fnc_han(fm.taijyuu.value);
	if (shin==''){
		alert('error');
	}else if (fnc_checkstr(shin,"0-9\.")==false){
		alert('error');
	}else if(taij==''){
		alert('error');
	}else if (fnc_checkstr(taij,"0-9\.")==false){
		alert('error');
	}else{
		shin=parseFloat(shin);
		taij=parseFloat(taij);
		kent=taij - ((shin*shin*22)/(100*100));
		biyt=taij - ((shin*shin*20)/(100*100));
		kent=Math.round(kent* -1);
		biyt=Math.round(biyt* -1);
		if (kent<=0){
			kent=''+kent;
		}else{
			kent='+'+kent;
		}
		if (biyt<=0){
			biyt=''+biyt;
		}else{
			biyt='+'+biyt;
		}
		document.getElementById("idSub1_2").innerHTML='<p><img src="../img/proportion/sub1_1_05_you.gif" alt="You are" width="72" height="15" /> '+kent+'kg <img src="../img/proportion/sub1_1_05.gif" alt="away from a healthy weight." /></p><p><img src="../img/proportion/sub1_1_05_you.gif" alt="You are" width="72" height="15" /> '+biyt+'kg <img src="../img/proportion/sub1_1_06.gif" alt="away from your ideal weight." /> </p>';
	}
}

// -----------------------------------------------
// ³K\»`FbN
// ψFstr     string
// ψFreg     gpΒ\ΘΆρp^[
// ίθlFTRUE....OK@FALSE......NG
// -----------------------------------------------
function fnc_checkstr(str,reg) {
	var ptn;
	ptn = new RegExp("^[" + reg + "]*$");
	if (str.match(ptn) == null) {
		return false;
	}
	return true;
}

// -----------------------------------------------
// ΜΌp»
// ψFstr     
// ίθlFΌp»Οέstring
//-----------------------------------------------
function fnc_han(str){
	var rtn=str;
	aryhan=new Array("0","1","2","3","4","5","6","7","8","9",".");
	aryzen=new Array("O","P","Q","R","S","T","U","V","W","X","D");
	if (rtn.length>0){
		for (i=0;i<=10;i++){
			for (ii=0;ii<=7;ii++){
				rtn=rtn.replace(aryzen[i], aryhan[i]);
			}
		}
	}
	return rtn;
}

// -----------------------------------------------
// Μ^`FbN
//-----------------------------------------------
function fnc_tcheck(){
	var fm=document.fm_ck;
	var point_1=0;
	var point_2=0;
	var point_3=0;
	if (fm.check1.checked==true){
		point_1++;
	}
	if (fm.check2.checked==true){
		point_1++;
	}
	if (fm.check3.checked==true){
		point_1++;
	}
	if (fm.check4.checked==true){
		point_1++;
	}
	if (fm.check5.checked==true){
		point_1++;
	}
	if (fm.check6.checked==true){
		point_1++;
	}
	if (fm.check7.checked==true){
		point_1++;
	}
	if (fm.check8.checked==true){
		point_2++;
	}
	if (fm.check9.checked==true){
		point_2++;
	}
	if (fm.check10.checked==true){
		point_2++;
	}
	if (fm.check11.checked==true){
		point_2++;
	}
	if (fm.check12.checked==true){
		point_2++;
	}
	if (fm.check13.checked==true){
		point_2++;
	}
	if (fm.check14.checked==true){
		point_2++;
	}
	if (fm.check15.checked==true){
		point_3++;
	}
	if (fm.check16.checked==true){
		point_3++;
	}
	if (fm.check17.checked==true){
		point_3++;
	}
	if (fm.check18.checked==true){
		point_3++;
	}
	if (fm.check19.checked==true){
		point_3++;
	}
	if (fm.check20.checked==true){
		point_3++;
	}
	if (fm.check21.checked==true){
		point_3++;
	}
	if (fm.check22.checked==true){
		point_3++;
	}
	if (fm.check23.checked==true){
		point_3++;
	}
	if (fm.check24.checked==true){
		point_3++;
	}
	if (point_3>point_1 && point_3>point_2){
		document.getElementById("idProportionCheck1").style.display="none";
		document.getElementById("idProportionCheck2").style.display="none";
		document.getElementById("idProportionCheck3").style.display="block";
	}else if(point_2>point_1){
		document.getElementById("idProportionCheck1").style.display="none";
		document.getElementById("idProportionCheck2").style.display="block";
		document.getElementById("idProportionCheck3").style.display="none";
	}else{
		document.getElementById("idProportionCheck1").style.display="block";
		document.getElementById("idProportionCheck2").style.display="none";
		document.getElementById("idProportionCheck3").style.display="none";
	}
}
