<!--



function calc_calories(){

//get values

Arate = document.calorie_form.activity.options[document.calorie_form.activity.selectedIndex].value;
Arate = parseFloat(Arate);
Arate = Math.abs(Arate);
weight = document.calorie_form.weight.value ;
weight = parseFloat(weight); 
weight = Math.abs(weight);
if(!isNaN(weight)){
 document.calorie_form.weight.value = weight 
}
duration = document.calorie_form.minutes.value
duration = parseFloat(duration);	
duration = Math.abs(duration);
if(!isNaN(duration)){
document.calorie_form.minutes.value = duration 
}
if(isNaN(weight) || weight == 0){

// make sure values are valid numbers greater than zero

alert("Please enter a valid weight greater than zero");
document.calorie_form.weight.focus();
return;
}
if(isNaN(duration) || duration == 0 ){
alert("Please enter a valid duration greater than zero in the Minutes of Activity field");
document.calorie_form.minutes.focus();
return;
} 

// if weight is in pounds, convert to kgs

if (document.calorie_form.measure[0].checked){
kgWeight = weight * 0.45 ;
}
else{
kgWeight = weight;
}

// calculate calories used

cal_spent = Math.round((Arate * kgWeight * duration))
document.calorie_form.cals.value = cal_spent;
}
// -->
