var bmi;
var weight;
var height;

var calsburned;
var weightCal;
var dur;
var activity;

var carb;
var carbC;
var activitylevel;
var age;
var gender;

var btnColor="#eed99a"




//*************BMI FUNCTIONS*****************************
		function CompBMI()
		{	
			bmi.value =Math.round (((weight.value)/Math.pow((height.value),2 )*703 )*1000)/1000;
		}
		
		function ResetBMI()//reset all parameters
		{
			bmi.value="";
			weight.value="";
			height.value="";
		}
		
		function CreateBMI(Left,Top)
		{
			document.writeln("<table border='0' width='528' height='267' background='http://www.savvy-fat-burning-food.com/images/bmi_calculator_graphic.jpg'  style='position:absolute; left:" + Left + "; top:" + Top +";'>");
			document.writeln("<tr>");
			document.writeln("<td width='365'>");
			
				document.writeln("<center><table border='0' name='thing' id='thing'>");
				document.writeln("<tr>");
				document.writeln("<td><center style='font-size:12px;'>Weight<br>(lbs)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Height<br>(in)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>BMI</center></td>");
				document.writeln("<td><center><INPUT type='button' id=calc name=calc value='Calculate' style='width:80; background-color:" + btnColor + ";' onclick='javascript:CompBMI();'></center></td>");
			
			
				document.writeln("</tr><tr>");
			
				document.writeln("<td><INPUT id=weight  style='width:45;'></td>");
				document.writeln("<td><INPUT id=height  style='width:45;'></td>");
				document.writeln("<td><INPUT id=bmi  style='width:60;' disabled></td>");
				document.writeln("<td><center><INPUT type='button'  id=calc name=calc value='Reset' style='width:80; background-color:" + btnColor + ";' onclick='javascript:ResetBMI();' ></center></td>");

				document.writeln("</table></center>");
			document.writeln("</td>");
			document.writeln("<td width='202'> </td>");
			document.writeln("</tr><tr height='20'></tr><tr><td width='365'>");
			
			

				//**********Chart table******************
				document.writeln("<center><table border='0' align='top'>");
			
				document.writeln("<th>")
				document.writeln("<center style='font-size:12px;'>BMI</center></th>");
				document.writeln ("<th><center style='font-size:12px;'>Weight Status</center></th>");
			
				document.writeln("</tr><tr>");
	
				document.writeln("<td border='5'><center style='font-size:12px;'>Below 18.5</center></td>");
				document.writeln ("<td><center style='font-size:12px;'>Underweight</center></td>");
			
				document.writeln("</tr><tr>");

				document.writeln("<td border='5'><center style='font-size:12px;'>18.5 - 24.9</center></td>");
				document.writeln ("<td><center style='font-size:12px;'>Normal</center></td>");
			
				document.writeln("</tr><tr>");

				document.writeln("<td border='5'><center style='font-size:12px;'>25 - 29.9</center></td>");
				document.writeln ("<td><center style='font-size:12px;'>Overweight</center></td>");
			
				document.writeln("</tr><tr>");

				document.writeln("<td border='5'><center style='font-size:12px;'>30.0 and Above</center></td>");
				document.writeln ("<td><center style='font-size:12px;'>Obese</center></td>");
			
				document.writeln("</tr></table></center>");
			
				
			document.writeln("</td></tr></table>")
			
			bmi=document.getElementById('bmi');
			weight=document.getElementById('weight');
			height=document.getElementById('height');

			
			//******************************************

		}
		
//*******************************************************
//*************Calorie FUNCTIONS*************************
		function CompCalBurn()
		{
			var cals=0;
			
			cals=parseFloat(activity.options[activity.selectedIndex].id);
			calsburned.value=Math.round(cals * ((weightCal.value) / 2.205) * (dur.value)*60 );
		
		}
		
		function ResetCalBurn()
		{
			calsburned.value="";
			weightCal.value="";
			dur.value="";
			activity.selectedIndex=0;
		}
	
		function CreateCalBurn(Left,Top)
		{					
		
		
			document.writeln("<table border='0' width ='490' height='326' background='image-files/yoga_woman2.jpg' style='position:absolute; left:" + Left + "; top:" + Top +"; background-repeat:no-repeat;'>");
			document.writeln("<tr><td width='490'>");
			
				document.writeln("<center><table border='0' >");
			
				document.writeln("<tr>")
				document.writeln("<td><center style='font-size:12px;'>Weight<br>(lbs)</center></td>");
				document.writeln ("<td><center style='color:White; background-color:transparent; font-weight:bold; font-size:12px;'>Activity</center></td>");

				document.writeln("<td><center style='font-size:12px;'>Duration<br>(hrs)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Calories<br>Burned</center></td>");

				document.writeln("<td><INPUT type='button' id=calc name=calc value='Calculate' style='width:70;' onclick='CompCalBurn();'></td>");
			
				document.writeln("</tr><tr>");
			
				document.writeln("<td><INPUT id=weightCal style='width:45;'></td>");
				document.writeln("<td>");
			
					document.writeln("<select id=activity>");//****exercise dropdown****//id is the calories factor
						document.writeln("<option id=0.065>Archery</option>");
						document.writeln("<option id=0.097>Badmington</option>");
						document.writeln("<option id=0.035>Bakery</option>");
						document.writeln("<option id=0.138>Basketball</option>");
						document.writeln("<option id=0.042>Billiards</option>");
						document.writeln("<option id=0.038>Bookbinding</option>");
						document.writeln("<option id=0.222>Boxing in ring</option>");
						document.writeln("<option id=0.138>Boxing - sparring</option>");
						document.writeln("<option id=0.044>Leisure canoeing</option>");
						document.writeln("<option id=0.103>Competitive canoeing</option>");
						document.writeln("<option id=0.025>Card Playing</option>");
						document.writeln("<option id=0.052>Carpentry</option>");
						document.writeln("<option id=0.121>climbing hills no load</option>");
						document.writeln("<option id=0.129>climbing hills carrying 5 kg</option>");
						document.writeln("<option id=0.14>climbing hills carrying 10 kg</option>");
						document.writeln("<option id=0.147>climbing hills carrying 20 kg</option>");
						document.writeln("<option id=0.045>cooking woman</option>");
						document.writeln("<option id=0.048>cooking man</option>");
						document.writeln("<option id=0.083>cricket batting</option>");
						document.writeln("<option id=0.09>cricket bowling</option>");
						document.writeln("<option id=0.059>croquet</option>");
						document.writeln("<option id=0.064>cycling leisure 5.5 mph</option>");
						document.writeln("<option id=0.1>cycling leisure 9.4 mph</option>");
						document.writeln("<option id=0.169>cycling racing</option>");
						document.writeln("<option id=0.103>dancing female moderate aerobic</option>");
						document.writeln("<option id=0.135>dancing female intense aerobic</option>");
						document.writeln("<option id=0.051>ballroom dancing</option>");
						document.writeln("<option id=0.168>choreographed dancing</option>");
						document.writeln("<option id=0.036>drawing</option>");
						document.writeln("<option id=0.023>eating while sitting</option>");
						document.writeln("<option id=0.134>field hockey</option>");
						document.writeln("<option id=0.062>fishing</option>");
						document.writeln("<option id=0.062>grocery shopping female</option>");
						document.writeln("<option id=0.058>grocery shopping male</option>");
						document.writeln("<option id=0.132>football</option>");
						document.writeln("<option id=0.126>gardening digging</option>");
						document.writeln("<option id=0.077>gardening hedging</option>");
						document.writeln("<option id=0.112>gardening mowing</option>");
						document.writeln("<option id=0.054>gardening raking</option>");
						document.writeln("<option id=0.085>golf</option>");
						document.writeln("<option id=0.066>gymnastics</option>");
						document.writeln("<option id=0.128>horse grooming</option>");
						document.writeln("<option id=0.137>horse racing gallop</option>");
						document.writeln("<option id=0.11>horse racing trotting</option>");
						document.writeln("<option id=0.041>horse riding - walk</option>");
						document.writeln("<option id=0.195>judo</option>");
						document.writeln("<option id=0.162>jumping rope 70 per minute</option>");
						document.writeln("<option id=0.164>jumping rope 80 per minute</option>");
						document.writeln("<option id=0.177>jumping rope 125 per minute</option>");
						document.writeln("<option id=0.197>jumping rope 145 per minute</option>");
						document.writeln("<option id=0.062>Mopping the floor female</option>");
						document.writeln("<option id=0.058>Mopping the floor male</option>");
						document.writeln("<option id=0.178>Racquetball</option>");
						document.writeln("<option id=0.163>cross country running</option>");
						document.writeln("<option id=0.135>running 11 minutes 30 seconds per mile</option>");
						document.writeln("<option id=0.193>running 9 minutes per mile</option>");
						document.writeln("<option id=0.208>running 8 minutes per mile</option>");
						document.writeln("<option id=0.228>running 7 minutes per mile</option>");
						document.writeln("<option id=0.252>running 6 minutes per mile</option>");
						document.writeln("<option id=0.289>running 5 minutes per mile</option>");
						document.writeln("<option id=0.119>skiing moderate speed hard snow</option>");
						document.writeln("<option id=0.143>skiing walking hard snow</option>");
						document.writeln("<option id=0.274>skiing maximum speed hard snow</option>");
						document.writeln("<option id=0.111>skiing leisure female</option>");
						document.writeln("<option id=0.098>skiing leisure males</option>");
						document.writeln("<option id=0.276>skindiving considerable motion</option>");
						document.writeln("<option id=0.206>skindiving moderate motion</option>");
						document.writeln("<option id=0.166>snowshoeing soft snow</option>");
						document.writeln("<option id=0.212>squash</option>");
						document.writeln("<option id=0.025>standing quietly female</option>");
						document.writeln("<option id=0.027>standing quietly male</option>");
						document.writeln("<option id=0.169>swimming back stroke</option>");
						document.writeln("<option id=0.162>swimming breast stroke</option>");
						document.writeln("<option id=0.156>swimming fast crawl</option>");
						document.writeln("<option id=0.128>swimming slow crawl</option>");
						document.writeln("<option id=0.122>swimming side stroke</option>");
						document.writeln("<option id=0.17>swimming treading water fast</option>");
						document.writeln("<option id=0.062>swimming treading water normal rate</option>");
						document.writeln("<option id=0.068>table tennis</option>");
						document.writeln("<option id=0.109>tennis</option>");
						document.writeln("<option id=0.05>volleyball</option>");
						document.writeln("<option id=0.08>walking normal pace, asphalt road</option>");
						document.writeln("<option id=0.082>walking normal pace, fields and hillsides</option>");
						document.writeln("<option id=0.081>walking normal pace, grass track</option>");
						
				document.writeln("</td>");
				document.writeln("<td><INPUT id=dur style='width:60;'></td>");
				document.writeln("<td><INPUT id=calsburned style='width:60;' disabled></td>");

				document.writeln("<td><center><INPUT type='button' id=calc name=calc value='Reset' style='width:70;' onclick='ResetCalBurn();' ></center></td>");
			
				document.writeln("</table></center></td>");
				
				document.writeln("<td width='76'></td>");
				
			document.writeln("</tr></table>");
			
			weightCal=document.getElementById('weightCal');
			dur=document.getElementById('dur');
			calsburned=document.getElementById('calsburned');
			activity=document.getElementById('activity');



		}
//*******************************************************
//*************Carb FUNCTIONS****************************

		function CompCarbs()
		{
			var cals=0;
			
			
			//************MALE*********************
			if (gender.selectedIndex==0)
			{
				//*********SEDENTARY***************
				if (activitylevel.selectedIndex==0)
				{
					switch(age.selectedIndex+1)//ages
					{
						case 1:
							cals=1600; break;
						case 2:
							cals=1600; break;
						case 3:
							cals=1800; break;
						case 4:
							cals=1800; break;
						case 5:
							cals=2000; break;
						case 6:
							cals=2000; break;
						case 7:
							cals=2200; break;
						case 8:
							cals=2400; break;
						case 9:
							cals=2400; break;
						case 10:
							cals=2400; break;
						case 11:
							cals=2600; break;
						case 12:
							cals=2400; break;
						case 13:
							cals=2400; break;
						case 14:
							cals=2400; break;
						case 15:
							cals=2400; break;
						case 16:
							cals=2200; break;
						case 17:
							cals=2200; break;
						case 18:
							cals=2200; break;
						case 19:
							cals=2200; break;
						case 20:
							cals=2000; break;
						case 21:
							cals=2000; break;
					}
				}
				//***********************************
				
				//********MOD. ACTIVE****************
				else if(activitylevel.selectedIndex==1)
				{
					switch(age.selectedIndex+1)
					{
						case 1:
							cals=1800; break;
						case 2:
							cals=1800; break;
						case 3:
							cals=2000; break;
						case 4:
							cals=2200; break;
						case 5:
							cals=2200; break;
						case 6:
							cals=2400; break;
						case 7:
							cals=2600; break;
						case 8:
							cals=2800; break;
						case 9:
							cals=2800; break;
						case 10:
							cals=2800; break;
						case 11:
							cals=2800; break;
						case 12:
							cals=2800; break;
						case 13:
							cals=2600; break;
						case 14:
							cals=2600; break;
						case 15:
							cals=2600; break;
						case 16:
							cals=2600; break;
						case 17:
							cals=2400; break;
						case 18:
							cals=2400; break;
						case 19:
							cals=2400; break;
						case 20:
							cals=2400; break;
						case 21:
							cals=2200; break;
					}
				}
				//***********************************
				
				//***********ACTIVE******************
				else if(activitylevel.selectedIndex==2)
				{
					switch(age.selectedIndex+1)
					{
						case 1:
							cals=2000; break;
						case 2:
							cals=2200; break;
						case 3:
							cals=2200; break;
						case 4:
							cals=2400; break;
						case 5:
							cals=2600; break;
						case 6:
							cals=2800; break;
						case 7:
							cals=3000; break;
						case 8:
							cals=3200; break;
						case 9:
							cals=3200; break;
						case 10:
							cals=3200; break;
						case 11:
							cals=3000; break;
						case 12:
							cals=3000; break;
						case 13:
							cals=3000; break;
						case 14:
							cals=3000; break;
						case 15:
							cals=2800; break;
						case 16:
							cals=2800; break;
						case 17:
							cals=2800; break;
						case 18:
							cals=2800; break;
						case 19:
							cals=2600; break;
						case 20:
							cals=2600; break;
						case 21:
							cals=2600; break;
					}
				}
			}
			//*************************************
			
			//************FEMALE*******************
			else if(gender.selectedIndex==1)
			{
				if (activitylevel.selectedIndex==0)
				{
					//*********SEDENTARY***************
					switch(age.selectedIndex+1)//ages
					{
						case 1:
							cals=1400; break;
						case 2:
							cals=1400; break;
						case 3:
							cals=1600; break;
						case 4:
							cals=1600; break;
						case 5:
							cals=1600; break;
						case 6:
							cals=1800; break;
						case 7:
							cals=1800; break;
						case 8:
							cals=1800; break;
						case 9:
							cals=1800; break;
						case 10:
							cals=1800; break;
						case 11:
							cals=2000; break;
						case 12:
							cals=2000; break;
						case 13:
							cals=1800; break;
						case 14:
							cals=1800; break;
						case 15:
							cals=1800; break;
						case 16:
							cals=1800; break;
						case 17:
							cals=1800; break;
						case 18:
							cals=1600; break;
						case 19:
							cals=1600; break;
						case 20:
							cals=1600; break;
						case 21:
							cals=1600; break;

					}
				}
				//***********************************
				
				
				//*********MOD. ACTIVE***************
				else if(activitylevel.selectedIndex==1)
				{
					switch(age.selectedIndex+1)//ages
					{
						case 1:
							cals=1600; break;
						case 2:
							cals=1800; break;
						case 3:
							cals=1800; break;
						case 4:
							cals=2000; break;
						case 5:
							cals=2000; break;
						case 6:
							cals=2000; break;
						case 7:
							cals=2000; break;
						case 8:
							cals=2000; break;
						case 9:
							cals=2000; break;
						case 10:
							cals=2000; break;
						case 11:
							cals=2200; break;
						case 12:
							cals=2200; break;
						case 13:
							cals=2000; break;
						case 14:
							cals=2000; break;
						case 15:
							cals=2000; break;
						case 16:
							cals=2000; break;
						case 17:
							cals=2000; break;
						case 18:
							cals=1800; break;
						case 19:
							cals=1800; break;
						case 20:
							cals=1800; break;
						case 21:
							cals=1800; break;
					}
				}
				//***********************************
				
				
				//************ACTIVE*****************
				else if(activitylevel.selectedIndex==2)
				{
					switch(age.selectedIndex+1)//ages
					{
						case 1:
							cals=1800; break;
						case 2:
							cals=2000; break;
						case 3:
							cals=2000; break;
						case 4:
							cals=2200; break;
						case 5:
							cals=2200; break;
						case 6:
							cals=2400; break;
						case 7:
							cals=2400; break;
						case 8:
							cals=2400; break;
						case 9:
							cals=2400; break;
						case 10:
							cals=2400; break;
						case 11:
							cals=2400; break;
						case 12:
							cals=2400; break;
						case 13:
							cals=2400; break;
						case 14:
							cals=2200; break;
						case 15:
							cals=2200; break;
						case 16:
							cals=2200; break;
						case 17:
							cals=2200; break;
						case 18:
							cals=2200; break;
						case 19:
							cals=2200; break;
						case 20:
							cals=2000; break;
						case 21:
							cals=2000; break;


					}
				}
			}
			//***********************************
			
			var min=0;
			var max=0;
			
			min=cals* 45/100 ;//minimum reccomendation in Calories
			max=cals*50/100 ;//maximum reccomendation in Calories
			
			carbC.value=min + " - " + max;//in Calories
			carb.value=(min/4) + " - " + (max/4);//in grams

			
		
		}
		
		function ResetCarbs()//reset all parameters
		{
			carb.value="";
			carbC.value="";
			age.selectedIndex=0;
			activitylevel.selectedIndex=0;
			gender.selectedIndex=0;
		}
		
		function CreateCarbs(Left,Top)
		{
			document.writeln("<table border='0' width='495' height='109' background='http://www.savvy-fat-burning-food.com/images/woman_with_apple_graphic.jpg'  style='position:absolute; left:" + Left + "; top:" + Top +";background-repeat: no-repeat;'>");
			document.writeln("<tr><td width='361'>");
				document.writeln("<center><table border='0'>");

				document.writeln("<tr>")
				document.writeln("<td><center style='font-size:12px;'>Gender<br>(M/F)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Age<br>(yrs)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Activity<br>Level</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Carb Range<br>(g)</center></td>");
				document.writeln("<td><center style='font-size:12px;'>Carb Range<br>(Cal)</center></td>");

				document.writeln("<td><INPUT type='button' id=calc name=calc value='Calculate' style='width:75; background-color:" + btnColor + ";' onclick='CompCarbs();'></td>");
			
				document.writeln("</tr><tr>");
			
				document.writeln("<td><select id=gender name=gender>");//gender options
					document.writeln("<option>Male</option>");
					document.writeln("<option>Female</option>");
					
			
				document.writeln("</td><td><select id=age>");//age options
					document.writeln("<option>9</option>");
					document.writeln("<option>10</option>");
					document.writeln("<option>11</option>");
					document.writeln("<option>12</option>");
					document.writeln("<option>13</option>");
					document.writeln("<option>14</option>");
					document.writeln("<option>15</option>");
					document.writeln("<option>16</option>");
					document.writeln("<option>17</option>");
					document.writeln("<option>18</option>");
					document.writeln("<option>19-20</option>");
					document.writeln("<option>21-25</option>");
					document.writeln("<option>26-30</option>");
					document.writeln("<option>31-35</option>");
					document.writeln("<option>36-40</option>");
					document.writeln("<option>41-45</option>");
					document.writeln("<option>46-50</option>");
					document.writeln("<option>51-55</option>");
					document.writeln("<option>56-60</option>");
					document.writeln("<option>61-65</option>");
					document.writeln("<option>66-70</option>");			
			
				document.writeln("</td><td><select id=activitylevel>");// activity level options
					document.writeln("<option>Sedentary</option>");
					document.writeln("<option>Mod. Active</option>");
					document.writeln("<option>Active</option>");
					
				document.writeln("<td><center><INPUT id=carb style='width:75;' disabled></center></td>");
				document.writeln("<td><center><INPUT id=carbC style='width:75;' disabled></center></td>");

				document.writeln("<td><center><INPUT type='button' id=calc name=calc value='Reset' style='width:75; background-color:" + btnColor + ";' onclick='ResetCarbs();' ></center></td>");
			
				document.writeln("</table></center></td>");
				document.writeln("<td width='134'></td>");
			document.writeln("</tr></table>");
			
			carb=document.getElementById('carb');
			carbC=document.getElementById('carbC');
			activitylevel=document.getElementById('activitylevel');
			age=document.getElementById('age');
			gender=document.getElementById('gender');

			

		
		}
