<!--
var Feet,Result,Inches,Lbs,Cms,Kgs,Pinch,Peet,Metres,Height,Weight,x,active,gender,input,tot,carbs,A3,A4,frac

function FeetConvert()
{
Result=TGrams.ft.value*30.48;
Result+=TGrams.ins.value*2.54;
decimal();
TGrams.cms.value=Result.toFixed(frac);
}

function InchConvert()
{
Peet=TGrams.ft.value;
Pinch=TGrams.ins.value;

if (Pinch >= 12)
	{FtInsConvert(Pinch);}
else
	{Feet=Peet*30.48;
	Inches=Pinch*2.54;
	Result=+Inches+Feet;
	decimal();
	TGrams.cms.value=Result.toFixed(frac);}
}

function FtInsConvert()
{
Inches=Pinch%12;
Feet=+Peet+parseInt(Pinch/12);
TGrams.ft.value=Feet;
decimal();
TGrams.ins.value=Inches.toFixed(frac);
Result=(Feet*30.48)+(Inches*2.54);
decimal();
TGrams.cms.value=Result.toFixed(frac);
}

function CmsConvert()
{
Cms=TGrams.cms.value;
Feet=parseInt(Cms/30.48);
Inches=(Cms % 30.48)/2.54;
TGrams.ft.value=Feet;
decimal();
TGrams.ins.value=Inches.toFixed(frac);
}

function LbsConvert()
{
Kgs=TGrams.lbs.value*0.45359;
decimal();
TGrams.kgs.value=Kgs.toFixed(frac);
}

function KgsConvert()
{
Lbs=TGrams.kgs.value*2.2;
decimal();
TGrams.lbs.value=Lbs.toFixed(frac);
}

function GramsCalculate()
{
frac=TGrams.Decimal.value;
decimal();InchConvert();LbsConvert();
carbs=TGrams.carbs.value;

if (TGrams.radio3[1].checked)
	{Weight=TGrams.kgs.value*4.36*2.2046;
	Height=TGrams.cms.value*4.32/2.54;
	Age=TGrams.age.value*4.7;
	Result=(655+Weight+Height-Age);}
else
	{Feet=TGrams.ft.value;
	Inches=TGrams.ins.value;
	Weight=TGrams.kgs.value*6.22*2.2046;
	Height=TGrams.cms.value*12.7/2.54;
	Age=TGrams.age.value*6.8;
	Result=(66+Weight+Height-Age);}

if (TGrams.Activity[0].checked){
A3=(Result*carbs/410).toFixed(frac);
A4=Result.toFixed(frac);
active=TGrams.Activity[0].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[1].checked){
A3=(Result*1.25*carbs/410).toFixed(frac);
A4=(Result*1.25).toFixed(frac);
active=TGrams.Activity[1].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[2].checked){
A3=(Result*1.3*carbs/410).toFixed(frac);
A4=(Result*1.3).toFixed(frac);
active=TGrams.Activity[2].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[3].checked){
A3=(Result*1.5*carbs/410).toFixed(frac);
A4=(Result*1.5).toFixed(frac);
active=TGrams.Activity[3].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[4].checked){
A3=(Result*1.7*carbs/410).toFixed(frac);
A4=(Result*1.7).toFixed(frac);
active=TGrams.Activity[4].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[5].checked){
A3=(Result*2*carbs/410).toFixed(frac);
A4=(Result*2).toFixed(frac);
active=TGrams.Activity[5].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}
TGrams.actgender.value=active+" for "+gender+"  : "+Comma(Math.round(A4))+" Calories";
TGrams.carbos.value="Carbs (" + carbs +" % of diet)                          : "+A3+" grams  ("+(A3/28.35).toFixed(frac)+" ozs.)";
}

function validateInput()
	{
	input=TGrams.cms.value
	if (input<1)
		{alert("Your height, please!");
		TGrams.ft.focus();
		return false;}

	input=TGrams.kgs.value;
	if (input<1)
		{alert("Your weight, please!");
		TGrams.lbs.focus();
		return false;}

	input=TGrams.age.value;
	if (input<1)
		{alert("Your age, please!");
		TGrams.age.focus();
		return false;}
	else
		{return true;}
	}	


function decimal()
{
for (x=0;x<=TGrams.Decimal.length;x=x+1){
if (TGrams.Decimal[x].selected)
{frac=x;
return true;}
}
}


function addbookmark()
{
if (document.all)
{window.external.AddFavorite(document.location,document.title)}
}

var clockID=0
function UpdateClock()
{
if (clockID)
{clearTimeout(clockID);
clockID = 0;}

var tDate = new Date();
var dayofweek = tDate.getDay();
if (dayofweek==0){dayofweek="Sunday"}
if (dayofweek==1){dayofweek="Monday"}
if (dayofweek==2){dayofweek="Tuesday"}
if (dayofweek==3){dayofweek="Wednesday"}
if (dayofweek==4){dayofweek="Thursday"}
if (dayofweek==5){dayofweek="Friday"}
if (dayofweek==6){dayofweek="Saturday"}

var Day=tDate.getDate()

var Mth=tDate.getMonth()+1
if (Mth==1){Mth="January"}
if (Mth==2){Mth="February"}
if (Mth==3){Mth="March"}
if (Mth==4){Mth="April"}
if (Mth==5){Mth="May"}
if (Mth==6){Mth="June"}
if (Mth==7){Mth="July"}
if (Mth==8){Mth="August"}
if (Mth==9){Mth="September"}
if (Mth==10){Mth="October"}
if (Mth==11){Mth="November"}
if (Mth==12){Mth="December"}

var Yr=tDate.getFullYear()

var H=tDate.getHours();
if (H>11)
{var AMPM="PM";}
else
{var AMPM="AM";}

if (H>12)
{H=H-12;}

if (H<10)
{H="0"+H;}

var M=tDate.getMinutes()
if (M<10)
{M="0"+M;}

var S=tDate.getSeconds()
if (S<10)
{S="0"+S;}

theDate.innerHTML=dayofweek+", "+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 putFocus(formInst, elementInst)
{document.forms[0].elements[2].focus();}

function Comma(number) {
number = '' + number;
if (number.length > 3) {
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++) {
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
}


