<!--
function cal_bmi(lbs, ins){   h2 = ins * ins;
   bmi = lbs/h2 * 703   
   f_bmi = Math.floor(bmi);
   diff  = bmi - f_bmi;
   diff = diff * 10;
   diff = Math.round(diff);
   if (diff == 10){
      // Need to bump up the whole thing instead
      f_bmi += 1;
      diff = 0;
   }
   bmi = f_bmi + "." + diff;
   return bmi;
}
function compute(){
  // var f = self.document.forms[0];
	var f = document.bmiform;

   w = f.txtWeight.value;
   v = f.txtFeet.value;
   u = f.txtInch.value;

   // Format values for the BMI calculation

   if (!chkw(u)){
     var ii = 0;
     f.txtInch.value = 0;
   } else {
     var it = f.txtInch.value*1;
     var ii = parseInt(it);
       }

   var fi = parseInt(f.txtFeet.value * 12);
   var i = fi + ii;

  // Do validation of remaining fields to check for existence of values

   if (!chkw(v)){
     alert("Please enter a number for your height.");
     f.txtFeet.focus();
     return;
   }
   if (!chkw(w)){
     alert("Please enter a number for your weight.");
     f.txtWeight.focus();
     return;
   }

   // Perform the calculation
	// initial: Compute your BMI and find out the classificaiton of your weight here.
	var iVal=0;
	var sVal="";
	iVal=cal_bmi(w, i);
	if (iVal<18.5)
		highlightRow("under_18.5"); //sVal="You are Under Weight";
	if (iVal>=18.5 && iVal<24.9)
		highlightRow("under_25"); //sVal="You are of Normal Weight";
	if (iVal>=25 && iVal<29.9)
		highlightRow("under_30"); //sVal="You are Over Weight";
	if (iVal>=30 && iVal <34.9)
		highlightRow("under_35"); //sVal="You are Obese";
	if (iVal>=35 && iVal<39.9)
		highlightRow("under_40"); //sVal="You are Severely Obese";
	if (iVal>=40)
		highlightRow("under_therest"); //sVal="You are Morbidly Obese";

/*				under_25
				under_30
				under_35
				under_40
				under_therest*/


//alert(sVal);
//	writeBMI(sVal, iVal);
	f.txtBMI.value = iVal;
	
   
   /* *************************Code for Overweight/UnderWeight **************************/


   f.txtBMI.focus();
}

function chkw(w){
   if (isNaN(parseInt(w))){
      return false;
   } else if (w < 0){
  return false;
  }
  else{
  return true;
  }
}

var ie4 = false; 
document.write = ""
if(document.all) { ie4 = true; }

function getObject(id) { 
	if (ie4) { 
		return document.all[id]; 
	} 
	else { 
		return document.getElementById(id); 
	} 
}		 

function highlightRow(rowName){
	// first remove all highlighting
	clearRows();

	// then highlight row
	document.getElementById(rowName).style.backgroundColor='#d9eaf1';

//	var d = getObject('txtBMI');
//	var graphtxt =sTxt;
	//	myLayer = document.getElementById("BMI");
	//    myLayer.innerHTML=graphtxt;
//	alert(sTxt);
//	d.value=graphtxt;
}         

function clearRows() {
	var bmirows = document.getElementsByTagName("tr");
	//alert(divs);
	for (i=0;i<bmirows.length;i++) {
		if (bmirows[i].id.substr(0,6) == 'under_') {
			bmirows[i].style.backgroundColor='';
		}
//		alert(bmirows[i].id);
	}
}

// -->

