

function Lightcol(obj, new_style) {
    obj.className = new_style;
} 

function mod(div,base) {
	return round((div - ((div/base)*base)));
}

function round (x) {
	return Math.round(x*10)/10;
}

function calcBMIwomen() {
	var w = document.bmi.weight.value * 1;
	var HeightFeetInt = document.bmi.htf.value * 1;
	var HeightInchesInt = document.bmi.hti.value * 1;
	HeightFeetConvert = HeightFeetInt * 12;
	h = HeightFeetConvert + HeightInchesInt;
	displaybmi = round(((w * 703) / (h * h)));
	var rvalue = true;
	if ( (w <= 35) || (w >= 1500)  || (h <= 48) || (h >= 120) ) {
		alert ("Invalid data.  Please check and re-enter!");
		rvalue = false;
	}
	if (rvalue) {
		if (HeightInchesInt > 11) {
			reminderinches = mod(HeightInchesInt,12);
			document.bmi.hti.value = reminderinches;
			document.bmi.htf.value = HeightFeetInt + ((HeightInchesInt - reminderinches)/12);
			document.bmi.answer.value = displaybmi;
		}
		if (displaybmi <19.1) 
			document.bmi.comment.value = "Underweight. The lower BMI the greater the risk.";
		if (displaybmi >=19.1 && displaybmi <=25.8) 
			document.bmi.comment.value = "Normal. Very low risk.";
		if (displaybmi >=25.9 && displaybmi <=27.3) 
			document.bmi.comment.value = "Marginally overweight. Some risk.";
		if (displaybmi >=27.4 && displaybmi <=30) 
			document.bmi.comment.value = "Overweight. Moderate risk.";
		if (displaybmi >=30.1 && displaybmi <=34.9) 
			document.bmi.comment.value = "Severely overweight. High risk.";
		if (displaybmi >=35 && displaybmi <=39.9) 
			document.bmi.comment.value = "Candidate for surgery with comorbities";
		if (displaybmi >40) 
			document.bmi.comment.value = "Morbid obesity. Very high risk. Canditate for surgery";
			document.bmi.answer.value = displaybmi; 
	}
	return rvalue;
}

function calcBMImen() {
	var w = document.bmi.weight.value * 1;
	var HeightFeetInt = document.bmi.htf.value * 1;
	var HeightInchesInt = document.bmi.hti.value * 1;
	HeightFeetConvert = HeightFeetInt * 12;
	h = HeightFeetConvert + HeightInchesInt;
	displaybmi = round(((w * 703) / (h * h)));
	var rvalue = true;
	if ( (w <= 35) || (w >= 1500)  || (h <= 48) || (h >= 120) ) {
		alert ("Invalid data.  Please check and re-enter!");
		rvalue = false;
	}
	if (rvalue) {
		if (HeightInchesInt > 11) {
			reminderinches = mod(HeightInchesInt,12);
			document.bmi.hti.value = reminderinches;
			document.bmi.htf.value = HeightFeetInt + ((HeightInchesInt - reminderinches)/12);
			document.bmi.answer.value = displaybmi;
		}
		if (displaybmi <20.7) 
			document.bmi.comment.value = "Underweight. The lower BMI the greater the risk";
		if (displaybmi >=20.7 && displaybmi <=26.4) 
			document.bmi.comment.value = "Normal. Very low risk";
		if (displaybmi >=26.5 && displaybmi <=27.8) 
			document.bmi.comment.value = "Marginally overweight. Some risk";
		if (displaybmi >=27.9 && displaybmi <=30) 
			document.bmi.comment.value = "Overweight. Moderate risk";
		if (displaybmi >=30.1 && displaybmi <=34.9) 
			document.bmi.comment.value = "Severely overweight. High risk";
		if (displaybmi >=35 && displaybmi <=39.9) 
			document.bmi.comment.value = "Candidate for surgery with comorbities";
		if (displaybmi >40) 
			document.bmi.comment.value = "Morbid obesity. Very high risk. Canditate for surgery";
			document.bmi.answer.value = displaybmi; 
		}
	return rvalue;
}

function gallery1(image, myText) {
	parent.document['my_photo'].src = image;
	parent.document.getElementById('text_div').innerHTML = myText;
}

