// Please upgrade to a newer browser.<br>
<!-- // hide javascript.


function checkEmail(field) {
// Note: The next expression must be all on one line...
//       allow no spaces, linefeeds, or carriage returns!
return field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
}

function validateEmail(theForm) {
   if (theForm.fEmail.value != '' && !checkEmail(theForm.fEmail)) {
       alert('Please enter a valid email if you wish to receive a copy of the result.\nOtherwise leave it blank');
       theForm.fEmail.focus();
       theForm.fEmail.select();       
       return false;
   } 
   return true;
}

function validate(theForm) {
   if (theForm.fName.value.length < 2) {
      alert('Please enter your name.');
   	   theForm.fName.focus();
	   theForm.fName.select();
      return false;
   } else if (!checkEmail(theForm.fEmail)) {
	   alert('Please enter a valid email address.');
   	   theForm.fEmail.focus();
	   theForm.fEmail.select();
   	   return false;
   } else if (theForm.fEmail.value != theForm.fEmail2.value) {
	   alert('Please confirm your email is correct.');
   	   theForm.fEmail2.focus();
	   theForm.fEmail2.select();   
   	   return false;	   
   } else if (theForm.fMessage.value.length < 2) {
	   alert('Do not forget to write a message.');
   	   theForm.fMessage.focus();
	   theForm.fMessage.select();
   	   return false;   
   } else {
      return true;
   }
}



function checkBMIFields(theForm) {
   wgt = Number(theForm.fWeight.value);
   
   if (isNaN(wgt) || (wgt == "") || (wgt < 0) || (wgt == null)) {
 	alert('Please enter a valid weight.');
        theForm.fWeight.focus();
        theForm.fWeight.select();
 	return false;
   } else {    
     hgt =  Number(theForm.fHeight.value);
     if (isNaN(hgt) || (hgt == null)  || (hgt == "") || (hgt < 0)) {
 	alert('Please enter your height.');
        theForm.fWeight.focus();
        theForm.fWeight.select();
 	return false;
     }
   }
   return true;
}



// 1in = 2.54cm
// 1cm = 0.3937in
function height2Metric(theForm) {
   var totalInches = 0;
   totalInches = ((theForm.fFeetSel.selectedIndex + 1) * 12) + theForm.fInchSel.selectedIndex;

   if (theForm.fHeightSel.selectedIndex == 0)
      theForm.fHeight.value = round2n(totalInches * 2.54, 0);

   if (theForm.fHeightSel.selectedIndex == 1) 
      theForm.fHeight.value = totalInches;
      
   return true;
}


// 1lb = 0.4536kgs
// 1kg = 2.2046lbs
function weightConverter(theForm) {
   var weight = Number(theForm.fWeight.value);
   if (weight > 0) {
      if (theForm.fWeightSel.selectedIndex == 0) {	// 0 = kg, 1 = lbs
          theForm.fWeight.value = round2n(weight * 0.4536, 2);
      } else {				
          theForm.fWeight.value = round2n(weight * 2.2046, 2);
      }
      theForm.fWeight.focus();
      theForm.fWeight.select();
   }
   return true;
}


function setHeightSelections(theForm, totalInches) {
   var feet = Math.min( Math.max( Math.floor(totalInches / 12), 1 ), 7 );
   theForm.fFeetSel.selectedIndex = feet - 1;

   inches = round2n(totalInches - (feet * 12), 0);
   theForm.fInchSel.selectedIndex = Math.min( Math.max(inches, 0), 11 );
   return true;
}

// 1in = 2.54cm
function heightConverter(theForm) {
   var height = Number(theForm.fHeight.value);
   if (height > 0) {
      if (theForm.fHeightSel.selectedIndex == 0) { // 0 = cm, 1 = inches
          setHeightSelections(theForm, height);
          theForm.fHeight.value = round2n(height * 2.54, 1);  
      } else {				   
          setHeightSelections(theForm, height * 0.3937); 
          theForm.fHeight.value = round2n(height * 0.3937, 1) ; 
      }  
      theForm.fHeight.focus();
      theForm.fHeight.select();
   }
   return true;
}


function round2n(number, n) {
  var dcp = Math.pow(10, n);
  number = Math.round(number * dcp) / dcp;
  return number;
}



function popup(url, name, width, height)
{
settings= "toolbar=no,location=no,directories=no,"+
          "status=no,menubar=no,scrollbars=no,"+
           "resizable=no,width="+width+",height="+height;

MyNewWindow=window.open(url,name,settings);
}


function popUp(URL) {

window.open(URL, 'a', 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=yes,width=733,height=501');
}

// -->