 function putFocus(formInst, elementInst)
{document.forms[0].elements[2].focus();}

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 addbookmark()
{
if (document.all)
{window.external.AddFavorite(document.location,document.title)}
}

function Walking_Calories()
{
if (walking.wtlbkl[0].checked){
if (walking.weight.value<100 || walking.weight.value>220)
{alert("weight must be between 100 and 220 lbs");walking.weight.focus();walking.weight.select();return false;}
}
if (walking.wtlbkl[1].checked){
if (walking.weight.value<46 || walking.weight.value>100)
{alert("weight must be between 46 and 100 kilos");walking.weight.focus();walking.weight.select();return false;}
}
if (walking.distanceTime.value=="")
{alert("How many minutes did you walk?");walking.distanceTime.focus();return false;}

paceindex=walking.walkpace.selectedIndex;
if (walking.pace[0].checked){
if (paceindex=="0"){entered_pace=2;}
if (paceindex=="1"){entered_pace=2.5;}
if (paceindex=="2"){entered_pace=3;}
if (paceindex=="3"){entered_pace=3.5;}
if (paceindex=="4"){entered_pace=4;}
if (paceindex=="5"){entered_pace=4.5;}
if (paceindex=="6"){entered_pace=5;}
if (paceindex=="7"){entered_pace=6;}
if (paceindex=="8"){entered_pace=7;}
}
if (walking.pace[1].checked){
if (paceindex=="0"){entered_pace=3.2;}
if (paceindex=="1"){entered_pace=4.0;}
if (paceindex=="2"){entered_pace=4.8;}
if (paceindex=="3"){entered_pace=5.6;}
if (paceindex=="4"){entered_pace=6.4;}
if (paceindex=="5"){entered_pace=7.2;}
if (paceindex=="6"){entered_pace=8.0;}
if (paceindex=="7"){entered_pace=9.6;}
if (paceindex=="8"){entered_pace=11.2;}
}

var distance=walking.distanceTime.value;
weigh=walking.weight.value;


if(paceindex == 0) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}	
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}

	if (sw==0) {f=2.4}
	if (sw==1) {f=2.7}
  	if (sw==2) {f=2.9} 	
	if (sw==3) {f=3.1}  	
	if (sw==4) {f=3.3}  	
	if (sw==5) {f=3.6}
  	if (sw==6) {f=3.8}  	
	if (sw==7) {f=4.0}  	
	if (sw==8) {f=4.3}
calories_burned=Math.round(distance*f);
}
if(paceindex == 1) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=2.8}
	if (sw==1) {f=3.1}
  	if (sw==2) {f=3.4} 	
	if (sw==3) {f=3.7}  	
	if (sw==4) {f=3.9}  	
	if (sw==5) {f=4.2}
  	if (sw==6) {f=4.5}  	
	if (sw==7) {f=4.8}  	
	if (sw==8) {f=5.0}
calories_burned=Math.round(distance*f);
}
if(paceindex == 2) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}	
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}
	if (sw==0) {f=3.0}
	if (sw==1) {f=3.3}
  	if (sw==2) {f=3.6} 	
	if (sw==3) {f=3.8}  	
	if (sw==4) {f=4.1}  	
	if (sw==5) {f=4.4}
  	if (sw==6) {f=4.7}  	
	if (sw==7) {f=5.0}  	
	if (sw==8) {f=5.3}
calories_burned=Math.round(distance*f);
}
if(paceindex == 3) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}	
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}
	if (sw==0) {f=3.3}
	if (sw==1) {f=3.6}
  	if (sw==2) {f=3.9} 	
	if (sw==3) {f=4.3}  	
	if (sw==4) {f=4.5}  	
	if (sw==5) {f=4.8}
  	if (sw==6) {f=5.2}  	
	if (sw==7) {f=5.5}  	
	if (sw==8) {f=5.8}
calories_burned=Math.round(distance*f);
}
if(paceindex == 4) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=4.3}
	if (sw==1) {f=4.7}
  	if (sw==2) {f=5.1} 	
	if (sw==3) {f=5.5}  	
	if (sw==4) {f=5.9}  	
	if (sw==5) {f=6.3}
  	if (sw==6) {f=6.7}  	
	if (sw==7) {f=7.1}  	
	if (sw==8) {f=7.5}
calories_burned=Math.round(distance*f);
}
if(paceindex == 5) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=5.3}
	if (sw==1) {f=5.8}
  	if (sw==2) {f=6.3} 	
	if (sw==3) {f=6.8}  	
	if (sw==4) {f=7.3}  	
	if (sw==5) {f=7.8}
  	if (sw==6) {f=8.3}  	
	if (sw==7) {f=8.8}  	
	if (sw==8) {f=9.3}
calories_burned=Math.round(distance*f);
}
if(paceindex == 6) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=6.2}
	if (sw==1) {f=6.8}
  	if (sw==2) {f=7.4} 	
	if (sw==3) {f=8.0}  	
	if (sw==4) {f=8.6}  	
	if (sw==5) {f=9.2}
  	if (sw==6) {f=9.8}  	
	if (sw==7) {f=10.3}  	
	if (sw==8) {f=10.9}
calories_burned=Math.round(distance*f);
}
if(paceindex == 7) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=7.1}
	if (sw==1) {f=7.8}
  	if (sw==2) {f=8.5} 	
	if (sw==3) {f=9.2}  	
	if (sw==4) {f=9.9}  	
	if (sw==5) {f=10.6}
  	if (sw==6) {f=11.3}  	
	if (sw==7) {f=11.9}  	
	if (sw==8) {f=12.6}
calories_burned=Math.round(distance*f);
}
if(paceindex == 8) {
if (walking.wtlbkl[1].checked){weigh=weigh*2.2}
var sw=Math.round((weigh-61)/18);
if (sw>8){sw=8}	
	if (sw==0) {f=9.4}
	if (sw==1) {f=10.3}
  	if (sw==2) {f=11.3} 	
	if (sw==3) {f=12.2}  	
	if (sw==4) {f=12.7}  	
	if (sw==5) {f=13.9}
  	if (sw==6) {f=14.8}  	
	if (sw==7) {f=15.8}  	
	if (sw==8) {f=16.7}
calories_burned=Math.round(distance*f);
}
					
var length=walking.distanceTime.value/60*entered_pace;

if (walking.pace[0].checked){mkm=" miles";}
else
{mkm=" kms";}

calories.innerHTML="You burned "+calories_burned+" calories walking a distance of "+length.toFixed(2)+mkm;
}
