/*
Toggle Layer Visibility
© Eddie Traversa (nirvana.media3.net)
To add more shock to your site, visit www.DHTML Shock.com
*/

function toggleVisibility(id, NNtype, IEtype, WC3type) {
    if (document.getElementById) {
        eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
    } else {
        if (document.layers) {
            document.layers[id].visibility = NNtype;
        } else {
            if (document.all) {
                eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
				
            }
        }
    }
}

function compute(){

   var f = top.document.forms[0];
   var fi = parseInt(f.htf.options[f.htf.selectedIndex].value * 12);
   var ii = parseInt(f.hti.options[f.hti.selectedIndex].value);
   var i = fi + ii;

   w = f.wt.value;

   if (chkw(w)){

      f.bmi.value = cal_bmi(w, i);

   } else { alert("Please enter a number for your weight.");}
   return false;

}

function chkw(w){

   if (isNaN(parseInt(w))){

      return false;

   } else if (w < 0){

      return false;

   }

   else{

      return true;

   }

}


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){
       f_bmi += 1;
	   diff = 0;
 }


bmi = f_bmi + "." + diff;
toggleVisibility('contacts','show','visible','visible');
return bmi;
  
}

