function RadioCheck0()
{
	if (bmi.Radio1[0].checked==true)
		{bmi.Radio1[1].checked=false;
		
		bmi.cms.value="XXXX";
		bmi.kgs.value="XXXX";
		
		bmi.feet.disabled=false;
		bmi.inches.disabled=false;
		bmi.lbs.disabled=false;

		bmi.feet.value="";
		bmi.inches.value="";
		bmi.lbs.value="";

		bmi.cms.visible=false;
		bmi.kgs.visible=false;

		bmi.cms.disabled=true;
		bmi.kgs.disabled=true;
		
		ShouldWeigh.innerHTML="";
		BodyMassIndex.innerHTML="";
		State.innerHTML="";
		uo.innerHTML="";
		Remarks.innerHTML="";
		
		bmi.feet.focus()}
}

function RadioCheck1()
{
	if	(bmi.Radio1[1].checked==true)
		{bmi.Radio1[0].checked=false;

		bmi.feet.value="XXXX";
		bmi.inches.value="XXXX";
		bmi.lbs.value="XXXX";

		bmi.feet.disabled=true;
		bmi.inches.disabled=true;
		bmi.lbs.disabled=true;

		bmi.cms.disabled=false;
		bmi.kgs.disabled=false;

		bmi.cms.value="";
		bmi.kgs.value="";
		
		ShouldWeigh.innerHTML="";
		BodyMassIndex.innerHTML="";
		State.innerHTML="";
		uo.innerHTML="";
		Remarks.innerHTML="";
		
		bmi.cms.focus()}
}

function Calculate_BodyMassIndex(){
ValidateInput();

ShouldWeigh.innerHTML="";
BodyMassIndex.innerHTML="";
State.innerHTML="";
uo.innerHTML="";
Remarks.innerHTML="";

if (bmi.Radio1[1].checked==true) 
{bmi.Radio1[0].checked=false;
Kilos=bmi.kgs.value;
Cms=bmi.cms.value;
Metres=Cms/100;
BMI=((Kilos/(Metres * Metres))).toFixed(1);
	Weight1=Math.round(18.5*Metres*Metres);
	Weight2=Math.round(25*Metres*Metres);

ShouldWeigh.innerHTML=" Desired weight =>=>=> "+Weight1+" kgs. - "+Weight2+" kgs.";
BodyMassIndex.innerHTML=" Body Mass Index =>=>=> "+BMI;

if (BMI<18.5){State.innerHTML=" You may be UNDERWEIGHT";
	UO=Math.round(100-(Kilos/Weight1*100));
	excess=Weight1-Kilos;
	uo.innerHTML=excess+" kgs. or "+UO+" % under Normal weight"}

if (BMI>=18.5 && BMI <=25){State.innerHTML=" Your weight may be NORMAL"}

if (BMI>25 && BMI <=30){State.innerHTML=" You may be OVERWEIGHT";
	UO=Math.round((Kilos/Weight2*100)-100);
	excess=Kilos-Weight2;
	uo.innerHTML=excess+" kgs. or "+UO+" % over Normal weight"}

if (BMI>30 && BMI <=40){State.innerHTML=" You may be OBESE";
	UO=Math.round((Kilos/Weight2*100)-100);
	excess=Kilos-Weight2;
	uo.innerHTML=excess+" kgs. or "+UO+" % over Normal weight"}

if (BMI>40){State.innerHTML=" You may be MORBIDLY OBESE";
	UO=Math.round((Kilos/Weight2*100)-100);
	excess=Kilos-Weight2;
	uo.innerHTML=excess+" kgs. or "+UO+" % over Normal weight"}
	if (BMI>25)
	{Remarks.innerHTML="<br>1. To lose &frac12; kilo per week to achieve normal weight, combine food reduction and increased exercise in the order of 455 calories per day over the next "+excess*2+" weeks<br><br>2. Faster weight loss may not be sustainable, and thus not desirable, over the long term.<br>=============================="}
	}
else	
	{bmi.Radio1[0].checked=true;
	bmi.Radio1[1].checked=false;
	Feet=bmi.feet.value*12;
	Inches=bmi.inches.value;
	if (Inches==""){Inches="0"}
	TotalInches=Feet+parseInt(Inches);
	Metres=TotalInches/39.36;
	Pounds=bmi.lbs.value;
	Kilos=Pounds/2.2;
	BMI=((Kilos/(Metres * Metres))).toFixed(1);
	
	Weight1=parseInt(18.5*Metres*Metres*2.2);
	Weight2=parseInt(25*Metres*Metres*2.2);

ShouldWeigh.innerHTML=" Desired weight =>=>=> "+Weight1+" lbs. - "+Weight2+" lbs.";
BodyMassIndex.innerHTML=" Body Mass Index =>=>=> "+BMI;

if (BMI<18.5){State.innerHTML=" You may be UNDERWEIGHT";
	UO=Math.round(100-(Pounds/Weight1*100));
	excess=Weight1-Pounds;
	uo.innerHTML=excess+" lbs. or "+UO+" % under Normal weight"}

if (BMI>=18.5 && BMI <=25){State.innerHTML=" Your weight may be NORMAL"}

if (BMI>25 && BMI <=30){State.innerHTML=" You may be OVERWEIGHT";
	UO=Math.round((Pounds/Weight2*100)-100);
	excess=Pounds-Weight2;
	uo.innerHTML=excess+" lbs. or "+UO+" % over Normal weight"}

if (BMI>30 && BMI <=40){State.innerHTML=" You may be OBESE";
	UO=Math.round((Pounds/Weight2*100)-100);
	excess=Pounds-Weight2;
	uo.innerHTML=excess+" lbs. or "+UO+" % over Normal weight"}

if (BMI>40){State.innerHTML=" You may be MORBIDLY OBESE";
	UO=Math.round((Pounds/Weight2*100)-100);
	excess=Pounds-Weight2;
	uo.innerHTML=excess+" lbs. or "+UO+" % over Normal weight"}
if (BMI>25)
	{Remarks.innerHTML="<br>1. To lose 1 lb. per week to achieve normal weight, combine food reduction and increased exercise in the order of 500 			calories per day over the next "+excess+" weeks<br><br>2. Faster weight loss may not be sustainable, and thus not desirable, over the long term.<br>=============================="}
	}
}


var clockID=0
function UpdateClock()
{
if (clockID)
{clearTimeout(clockID);
clockID = 0;}

var H,M,S,Mth,Day,AMPM,Yr
var tDate = new Date();
Day=tDate.getDate()
if (Day<10)
{Day="0"+Day;}

Mth=tDate.getMonth()+1
if (Mth==1){Mth="Jan"}
if (Mth==2){Mth="Feb"}
if (Mth==3){Mth="Mar"}
if (Mth==4){Mth="Apr"}
if (Mth==5){Mth="May"}
if (Mth==6){Mth="Jun"}
if (Mth==7){Mth="Jul"}
if (Mth==8){Mth="Aug"}
if (Mth==9){Mth="Sep"}
if (Mth==10){Mth="Oct"}
if (Mth==11){Mth="Nov"}
if (Mth==12){Mth="Dec"}

Yr=tDate.getFullYear()

H=tDate.getHours();
if (H>11)
{AMPM="pm";}
else
{AMPM="am";}

if (H>12)
{H=H-12;}

if (H<10)
{H="0"+H;}

M=tDate.getMinutes()
if (M<10)
{M="0"+M;}

S=tDate.getSeconds()
if (S<10)
{S="0"+S;}

theTime.value = Mth+" "+Day+" "+Yr + "::"
+ H + ":" + M + ":" + S +" "+ AMPM;
clockID = setTimeout("UpdateClock()",1000);
}

function StartClock() {
clockID = setTimeout("UpdateClock()",500);
}

function KillClock() {
if (clockID)
 {clearTimeout(clockID);
 clockID = 0;}
}

function round2(nbr,digits){
nbr=nbr.toString()
if (nbr.indexOf(".")==-1)
{int_part=nbr
decimal_part=""}
else
{int_part=nbr.substring(0,nbr.indexOf("."))
decimal_part=nbr.substring(1+nbr.indexOf("."),2+nbr.indexOf(".")+digits)}
while(decimal_part.length<digits+1)
decimal_part+="0"
if (Number(decimal_part.charAt(decimal_part.length-1)<5))
decimal_part=decimal_part.substring(0,digits)
else
{decimal_part=(Number(decimal_part)+10).toString()
if (decimal_part.length>digits+1){
int_part=(Number(int_part)+1).toString()
decimal_part=decimal_part.substring(1,digits+1)}
decimal_part=decimal_part.substring(0,digits)}
if (int_part=="")
int_part=0;
if (Number(digits)>0)
return int_part+"."+decimal_part
else
return int_part
}

function Validate_Num(obj)
	{
	if (! parseInt(obj.value,10))
		{alert("A number please!");
		focus(this);}
	return true;
	}

function ValidateInput()
{		
	if (bmi.Radio1[0].checked==true)
	{if (bmi.feet.value.length<1)
		{alert("Please enter your height in feet");
		bmi.feet.focus();
		return false;}

	if (bmi.inches.value>=12)
		{alert("Inches should be less than 12");
		bmi.inches.focus();
		return false;}

	if (bmi.lbs.value.length<1)
		{alert("Please enter your weight in lbs");
		bmi.lbs.focus();
		return false;}
		}

	else 
		{if (bmi.cms.value.length<1)
		{alert("Please enter your height in cms");
		bmi.cms.focus();
		return false;}

	if (bmi.kgs.value.length<1)
		{alert("Please enter your weight in Kgs");
		bmi.kgs.focus();
		return false;}
		}
	}


function addbookmark()
{
if (document.all)
{window.external.AddFavorite(document.location,document.title)}
}

