function cal_bmi(lbs, ins)
{
   h2 = ins * ins;
   bmi = lbs/h2 * 705
   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];

   w = f.ctl00_ContentPlaceHolder1_weight.value;
   v = f.ctl00_ContentPlaceHolder1_feet.value;
   u = f.ctl00_ContentPlaceHolder1_inches.value;

   // Format values for the BMI calculation

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

   var fi = parseInt(f.ctl00_ContentPlaceHolder1_feet.value * 12);
   var i =  parseInt(f.ctl00_ContentPlaceHolder1_feet.value * 12) + f.ctl00_ContentPlaceHolder1_inches.value*1.0;  // var i = fi + ii; aeisenberg@air.org: now the height in inches is correctly summed

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

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

   // Perform the calculation

   f.bmi.value = cal_bmi(w, i);
   f.bmi.focus();
}

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




/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
// texts:
// Your messages wich may contain regular html tags but
// must at least contain: [ <font color='{COLOR}'> ]
// Use single quotes [ ' ] in your html only. If you need
// a double quote in the message itself use an escape
// sign like this: [ \" ] (not including the brackets)
 var texts = new Array("<a href=\" http://www.endtheweight.com/seminar/\" class=\"link1b\"><font color='(COLOR)'><b>Norwalk Hospital, Perkin Auditorium, Norwalk 2/2/2010<\/b><\/font><\/a>"
,"<a href=\" http://www.endtheweight.com/seminar/\" class=\"link1b\"><font color='(COLOR)'><b>Fairfield County Bariatrics Office, Fairfield, Fairfield 2/5/2010<\/b><\/font><\/a>"
,"<a href=\" http://www.endtheweight.com/seminar/\" class=\"link1b\"><font color='(COLOR)'><b>New London Holiday Inn, New London 2/6/2010<\/b><\/font><\/a>"
,"<a href=\" http://www.endtheweight.com/seminar/\" class=\"link1b\"><font color='(COLOR)'><b>Stamford Italian Center, Stamford 2/10/2010<\/b><\/font><\/a>"
,"<a href=\" http://www.endtheweight.com/seminar/\" class=\"link1b\"><font color='(COLOR)'><b>St. Vincent's Medical Center Seton Room, Bridgeport 2/11/2010<\/b><\/font><\/a>"
);
if (texts.length == 0)
    texts = new Array("");
var bgcolor = "#ffffff"; // background color, must be valid browser hex color (not color names)
var fcolor = "#808080"; // foreground or font color
var steps = 20; // number of steps to fade
var show = 4000; // milliseconds to display message
var sleep = 30; // milliseconds to pause inbetween messages
var loop = true; // true = continue to display messages, false = stop at last message

// Do Not Edit Below This Line
var colors = new Array(steps);
getFadeColors(bgcolor,fcolor,colors);
var color = 0;
var text = 0;
var step = 1;

// fade: magic fader function
function fade() {

// insert fader color into message
var text_out = texts[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>howdy<\/font>");

// actually write message to document
document.getElementById("fader").innerHTML = text_out;

// select next fader color
color += step;

// completely faded in?
if (color >= colors.length-1) {
step = -1; // traverse colors array backward to fade out

// stop at last message if loop=false
if (!loop && text >= texts.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
}

// completely faded out?
if (color == 0) {
step = 1; // traverse colors array forward to fade in again

// select next message
text += 1;
if (text == texts.length) text = 0; // loop back to first message
}

// subtle timing logic...
setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
}
// getFadeColors: fills Colors (predefined Array)
// with color hex strings fading from ColorA to ColorB

// note: Colors.length equals the number of steps to fade
function getFadeColors(ColorA, ColorB, Colors) {
len = Colors.length;

// strip '#' signs if present
if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);

// substract rgb compents from hex string
var r = HexToInt(ColorA.substring(0,2));
var g = HexToInt(ColorA.substring(2,4));
var b = HexToInt(ColorA.substring(4,6));
var r2 = HexToInt(ColorB.substring(0,2));
var g2 = HexToInt(ColorB.substring(2,4));
var b2 = HexToInt(ColorB.substring(4,6));

// calculate size of step for each color component
var rStep = Math.round((r2 - r) / len);
var gStep = Math.round((g2 - g) / len);
var bStep = Math.round((b2 - b) / len);

// fill Colors array with fader colors
for (i = 0; i < len-1; i++) {
Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
r += rStep;
g += gStep;
b += bStep;
}
Colors[len-1] = ColorB; // make sure we finish exactly at ColorB
}

// IntToHex: converts integers between 0-255 into a two digit hex string.
function IntToHex(n) {
var result = n.toString(16);
if (result.length==1) result = "0"+result;
return result;
}

// HexToInt: converts two digit hex strings into integer.
function HexToInt(hex) {
return parseInt(hex, 16);
}
// body tag must include: onload="fade()" bgcolor="#00B359" where bgcolor equals bgcolor in javascript above
//window.onload=fade;
// End -->




/**
 *
 * @access public
 * @return void
 **/

function calculateBmi(){
	compute();
}