<!-- 
function calc (form) {
var W, T
W=form.Weight.value*form.WeightUnit.options[form.WeightUnit.selectedIndex].value
T=form.Time.value/form.TimeUnit.options[form.TimeUnit.selectedIndex].value
form.Calories.value = Math.round(form.Activity.options[form.Activity.selectedIndex].value*W*T)
}
//-->

<!-- 
function calcBMI(form) { 
   // BMI = 10000 * kg / cm / cm 

   cm = form.cm.value.replace(",", "."); 
   kg = form.kg.value.replace(",", "."); 
   
   if(cm < 130 ) cm = 130.0; if( cm > 210 ) cm = 210.0; 
   if( kg < 40 ) kg =  40.0; if( kg > 120 ) kg = 120.0; 
    
   bmi = Math.round( 100000 * kg / cm / cm ) / 10; 
    
   message = "Opasna gojaznost"; 
   if( bmi < 35 ) msg = "Teška gojaznost";
   if( bmi < 30 ) msg = "Gojaznost"; 
   if( bmi < 25 ) msg = "Normalna težina"; 
   if( bmi < 23 ) msg = "Idealna težina"; 
   if( bmi < 21 ) msg = "Normalna težina"; 
   if( bmi < 18 ) msg = "Neuhranjenost";
   if( bmi < 14 ) msg = "Teška neuhranjenost!";   

    
   form.cm.value  =  cm;
   form.kg.value  =  kg;
   form.BMI.value = bmi;
   form.adv.value = msg;
   
   min = Math.round( 18.5 * cm * cm / 1000 ) / 10 ; 
   max = Math.round( 25.0 * cm * cm / 1000 ) / 10 ; 
   ikg = Math.round( 10 * ( min + max ) / 2 ) / 10; 
   dst = Math.round( 100 * ( kg - ikg ) / ikg ) + " %";
   
   form.min.value = min;
   form.max.value = max;
   form.ikg.value = ikg + " kg";
   form.dst.value = dst;
   document.images('spacer').width = bmi * 10 - 6;
} 
//-->

<!--
		function calcalc(form) {
			//--fat loss
			var cal = parseInt(form.weight.value*22.04);
			form.cal.value=cal;
			var prot = Math.round(cal * .4);
			form.prot.value=prot;
			var carb = Math.round(cal * .4);
			form.carb.value=carb;
			var fat = Math.round(cal * .2);
			form.fat.value=fat;
			var protg = Math.round(prot / 4.2);
			form.protg.value = protg;
			var carbg = Math.round(carb / 4.2);
			form.carbg.value = carbg;
			var fatg = Math.round(fat / 9.45);
			form.fatg.value = Math.round(fatg);
			//fat loss muscle gain
			var cal2 = parseInt(form.weight.value*26.448);
			form.cal2.value=cal2;
			var prot2 = Math.round(cal2 * .4);
			form.prot2.value=prot2;
			var carb2 = Math.round(cal2 * .4);
			form.carb2.value=carb2;
			var fat2 = Math.round(cal2 * .2);
			form.fat2.value=fat2;
			var protg2 = Math.round(prot2 / 4.2);
			form.protg2.value = protg2;
			var carbg2 = Math.round(carb2 / 4.2);
			form.carbg2.value = carbg2;
			var fatg2 = Math.round(fat2 / 9.45);
			form.fatg2.value = fatg2 ;
			//size and strength
			var cal3 = parseInt(form.weight.value*33.06);
			form.cal3.value=cal3;
			var prot3 = Math.round(cal3 * .3);
			form.prot3.value=prot3;
			var carb3 = Math.round(cal3 * .5);
			form.carb3.value=carb3;
			var fat3 = Math.round(cal3 * .2);
			form.fat3.value=fat3;
			var protg3 = Math.round(prot3 / 4.2);
			form.protg3.value = protg3;
			var carbg3 = Math.round(carb3 / 4.2);
			form.carbg3.value = Math.round(carbg3);
			var fatg3 = Math.round(fat3 / 9.45);
			form.fatg3.value = Math.round(fatg3);
		}
//-->


<!--

function calcBMR() {
	
	var doc = document.bmr
	
	if ( doc.height1.value == "" || isNaN(doc.height1.value) || doc.height1.value <= 0)
	{
		alert("Unešena visina nije u redu.  Unesite broj veći od 0!"); 
		doc.height1.value = "";
		doc.height1.focus();
		return;
	}
	if (doc.height2.value == "" || isNaN(doc.height2.value) || doc.height2.value < 0)
	{
		alert("Unešena visina nije u redu.  Unesite broj veći od 0!"); 
		doc.height2.value = "";
		doc.height2.focus();
		return;
		
	}

	if (doc.weight.value == "" || isNaN(doc.weight.value) || doc.weight.value <= 0)
	{
		alert("Unešena težina nije u redu.  Unesite broj veći od 0!"); 
		doc.weight.value = "";
		doc.weight.focus();
		return;
	}
	
	weight = doc.weight.value
	var uom = doc.weightuom.selectedIndex
	if ((uom == 0 && weight < 44)){
	  alert("Težina je premala i ne možemo izračunati BMR.  Minimalna težina mora biti barem 45kg."); 
		doc.weight.value = "";
		doc.weight.focus();
		return;
	}
	
	if (doc.age.value == "" || isNaN(doc.age.value) || doc.age.value <= 0 )
	{
		alert("Unešene godine nisu u redu  Unesite broj veći od 0!"); 
		doc.age.value = "";
		doc.age.focus();
		return;
		
	}

	//weight = doc.weight.value
	
	//var uom = doc.weightuom.selectedIndex
	if (uom == 1) 
		{
			weight = convertlbstokg(weight)
		}
	
	height1uom = doc.height1uom.selectedIndex
	height2uom = doc.height2uom.selectedIndex
	
	if (height1uom == 1 && height2uom == 1)
	{
		feet = parseInt(doc.height1.value);
		inches = parseInt(doc.height2.value);
		htInCm = calculateHeight(feet, inches);
	}
	else if (height1uom == 0 && height2uom == 0)
	{
		metres = parseInt(doc.height1.value);
		cm = parseInt(doc.height2.value);
		convertedCm = convertMetresToCm(metres);
		htInCm = convertedCm + cm;
	}
	else {
		alert("Mjere za visinu moraju biti pravilne!");
		return;
	}

	age = doc.age.value;
	if (doc.gender[0].checked == true)
		{
			bmrate = calculateBMRF(weight, htInCm, age);
		}
	else if (doc.gender[1].checked == true)
	{
		bmrate = calculateBMRM(weight, htInCm, age);
		
	}
		
		doc.result.value=Math.round(bmrate);

}

function calculateBMRF(weight, htInCm, age) {
	return (9.5634 * weight) + (1.8496 * htInCm) - (4.6756 * age) + 655.0955	
}

function calculateBMRM(weight, htInCm, age) {
	return (13.7516 * weight) + (5.0033 * htInCm) - (6.7550 * age) + 66.4730
}

function convertlbstokg(pounds) {
	weight = pounds * .45359237
	return weight
}
function convertMetresToCm (metres) {
	return metres * 100
}

function convertFeetToInches(feet) {
	inches = feet * 12;
	return inches
}

function convertInchesToCm (totalInches) {
	totalInches = totalInches * 2.54
	return totalInches
	}

function calculateHeight(feet, inches) {
	
		convertedInches = convertFeetToInches(feet);
		totalInches = convertedInches + inches;
		return convertInchesToCm(totalInches);
}
	
function clearForm() {
	document.forms['bmr'].reset();
}

//-->

<!--

function CalculateServing1()
{
f=document.caloriechart
f.total1.value=parseInt(f.calories1.value)*parseInt(f.qty1.value);
}

function CalculateServing2()
{
f=document.caloriechart
f.total2.value=parseInt(f.calories2.value)*parseInt(f.qty2.value);
}

function CalculateServing3()
{
f=document.caloriechart
f.total3.value=parseInt(f.calories3.value)*parseInt(f.qty3.value);
}

function CalculateServing4()
{
f=document.caloriechart
f.total4.value=parseInt(f.calories4.value)*parseInt(f.qty4.value);
}

function CalculateServing5()
{
f=document.caloriechart
f.total5.value=parseInt(f.calories5.value)*parseInt(f.qty5.value);
}

function CalculateServing6()
{
f=document.caloriechart
f.total6.value=parseInt(f.calories6.value)*parseInt(f.qty6.value);
}

function CalculateServing7()
{
f=document.caloriechart
f.total7.value=parseInt(f.calories7.value)*parseInt(f.qty7.value);
}

function CalculateServing8()
{
f=document.caloriechart
f.total8.value=parseInt(f.calories8.value)*parseInt(f.qty8.value);
}

function CalculateServing9()
{
f=document.caloriechart
f.total9.value=parseInt(f.calories9.value)*parseInt(f.qty9.value);
}

function CalculateServing10()
{
f=document.caloriechart
f.total10.value=parseInt(f.calories10.value)*parseInt(f.qty10.value);
}

function CalculateServing11()
{
f=document.caloriechart
f.total11.value=parseInt(f.calories11.value)*parseInt(f.qty11.value);
}

function CalculateServing12()
{
f=document.caloriechart
f.total12.value=parseInt(f.calories12.value)*parseInt(f.qty12.value);
}

function CalculateServing13()
{
f=document.caloriechart
f.total13.value=parseInt(f.calories13.value)*parseInt(f.qty13.value);
}

function CalculateServing14()
{
f=document.caloriechart
f.total14.value=parseInt(f.calories14.value)*parseInt(f.qty14.value);
}

function CalculateServing15()
{
f=document.caloriechart
f.total15.value=parseInt(f.calories15.value)*parseInt(f.qty15.value);
}

function CalculateServing16()
{
f=document.caloriechart
f.total16.value=parseInt(f.calories16.value)*parseInt(f.qty16.value);
}

function CalculateServing17()
{
f=document.caloriechart
f.total17.value=parseInt(f.calories17.value)*parseInt(f.qty17.value);
}

function CalculateServing18()
{
f=document.caloriechart
f.total18.value=parseInt(f.calories18.value)*parseInt(f.qty18.value);
}

function CalculateServing19()
{
f=document.caloriechart
f.total19.value=parseInt(f.calories19.value)*parseInt(f.qty19.value);
}

function CalculateServing20()
{
f=document.caloriechart
f.total20.value=parseInt(f.calories20.value)*parseInt(f.qty20.value);
}

function CalculateServing21()
{
f=document.caloriechart
f.total21.value=parseInt(f.calories21.value)*parseInt(f.qty21.value);
}

function CalculateServing22()
{
f=document.caloriechart
f.total22.value=parseInt(f.calories22.value)*parseInt(f.qty22.value);
}

function CalculateServing23()
{
f=document.caloriechart
f.total23.value=parseInt(f.calories23.value)*parseInt(f.qty23.value);
}

function CalculateServing24()
{
f=document.caloriechart
f.total24.value=parseInt(f.calories24.value)*parseInt(f.qty24.value);
}

function CalculateServing25()
{
f=document.caloriechart
f.total25.value=parseInt(f.calories25.value)*parseInt(f.qty25.value);
}

function CalculateServing26()
{
f=document.caloriechart
f.total26.value=parseInt(f.calories26.value)*parseInt(f.qty26.value);
}

function CalculateServing27()
{
f=document.caloriechart
f.total27.value=parseInt(f.calories27.value)*parseInt(f.qty27.value);
}

function FoodCalories1()
{
document.caloriechart.calories1.value=parseInt(document.caloriechart.food1.value)
}

function FoodCalories2()
{
document.caloriechart.calories2.value=parseInt(document.caloriechart.food2.value)
}

function FoodCalories3()
{
document.caloriechart.calories3.value=parseInt(document.caloriechart.food3.value)
}

function FoodCalories4()
{
document.caloriechart.calories4.value=parseInt(document.caloriechart.food4.value)
}

function FoodCalories5()
{
document.caloriechart.calories5.value=parseInt(document.caloriechart.food5.value)
}

function FoodCalories6()
{
document.caloriechart.calories6.value=parseInt(document.caloriechart.food6.value)
}

function FoodCalories7()
{
document.caloriechart.calories7.value=parseInt(document.caloriechart.food7.value)
}

function FoodCalories8()
{
document.caloriechart.calories8.value=parseInt(document.caloriechart.food8.value)
}

function FoodCalories9()
{
document.caloriechart.calories9.value=parseInt(document.caloriechart.food9.value)
}

function FoodCalories10()
{
document.caloriechart.calories10.value=parseInt(document.caloriechart.food10.value)
}

function FoodCalories11()
{
document.caloriechart.calories11.value=parseInt(document.caloriechart.food11.value)
}

function FoodCalories12()
{
document.caloriechart.calories12.value=parseInt(document.caloriechart.food12.value)
}

function FoodCalories13()
{
document.caloriechart.calories13.value=parseInt(document.caloriechart.food13.value)
}

function FoodCalories14()
{
document.caloriechart.calories14.value=parseInt(document.caloriechart.food14.value)
}

function FoodCalories15()
{
document.caloriechart.calories15.value=parseInt(document.caloriechart.food15.value)
}

function FoodCalories16()
{
document.caloriechart.calories16.value=parseInt(document.caloriechart.food16.value)
}

function FoodCalories17()
{
document.caloriechart.calories17.value=parseInt(document.caloriechart.food17.value)
}

function FoodCalories18()
{
document.caloriechart.calories18.value=parseInt(document.caloriechart.food18.value)
}

function FoodCalories19()
{
document.caloriechart.calories19.value=parseInt(document.caloriechart.food19.value)
}

function FoodCalories20()
{
document.caloriechart.calories20.value=parseInt(document.caloriechart.food20.value)
}

function FoodCalories21()
{
document.caloriechart.calories21.value=parseInt(document.caloriechart.food21.value)
}

function FoodCalories22()
{
document.caloriechart.calories22.value=parseInt(document.caloriechart.food22.value)
}

function FoodCalories23()
{
document.caloriechart.calories23.value=parseInt(document.caloriechart.food23.value)
}

function FoodCalories24()
{
document.caloriechart.calories24.value=parseInt(document.caloriechart.food24.value)
}

function FoodCalories25()
{
document.caloriechart.calories25.value=parseInt(document.caloriechart.food25.value)
}

function FoodCalories26()
{
document.caloriechart.calories26.value=parseInt(document.caloriechart.food26.value)
}

function FoodCalories27()
{
document.caloriechart.calories27.value=parseInt(document.caloriechart.food27.value)
}


function CalculateMeal()
{
f=document.caloriechart
f.grandtotal.value=parseInt(f.total1.value)
                                  +parseInt(f.total2.value)
                                  +parseInt(f.total3.value)
                                  +parseInt(f.total4.value)
                                  +parseInt(f.total5.value)
                                  +parseInt(f.total6.value)
                                  +parseInt(f.total7.value)
                                  +parseInt(f.total8.value)
                                  +parseInt(f.total9.value)
                                  +parseInt(f.total10.value)
                                  +parseInt(f.total11.value)
                                  +parseInt(f.total12.value)
                                  +parseInt(f.total13.value)
                                  +parseInt(f.total14.value)
                                  +parseInt(f.total15.value)
                                  +parseInt(f.total16.value)
                                  +parseInt(f.total17.value)
                                  +parseInt(f.total18.value)
                                  +parseInt(f.total19.value)
                                  +parseInt(f.total20.value)
                                  +parseInt(f.total21.value)
                                  +parseInt(f.total22.value)
                                  +parseInt(f.total23.value)
                                  +parseInt(f.total24.value)
                                  +parseInt(f.total25.value)
                                  +parseInt(f.total26.value)
                                  +parseInt(f.total27.value);
}
//-->
