// JavaScript Document
function switchDetails(display){
		if(display == 1)
		{
			document.getElementById("bmiImerial").style.display = '';
			document.getElementById("bmiMetric").style.display = 'none';
			document.getElementById("imperialBtn").style.background = '#FFFFFF';
			document.getElementById("metricBtn").style.background = '#9edbee';
			document.getElementById("imperialBtn").style.color = '#000000';
			document.getElementById("metricBtn").style.color = '#FFFFFF';
	
		}
		else if(display == 2)
		{
			document.getElementById("bmiImerial").style.display = 'none';
			document.getElementById("bmiMetric").style.display = '';
			document.getElementById("metricBtn").style.background = '#FFFFFF';
			document.getElementById("imperialBtn").style.background = '#9edbee';
			document.getElementById("imperialBtn").style.color = '#FFFFFF';
			document.getElementById("metricBtn").style.color = '#000000';
		}		
}
function BMI(){
		index = 0;
		inches = document.bmi.inches.value;
		if (!(inches > 0)) alert ("You must fill in the \"height\" box with a number.");
		pounds = document.bmi.weight.value;
		if (!(pounds > 0)) alert ("You must fill in the \"weight\" box with a number.");  
		index = (Math.round(inches))*.0254 //height in meters
		index = index * index;
		index = (Math.round(pounds)/2.2)/index; 
		index = Math.round (index);
		if (index >= 40){
			strComment = "\nVery Obese";
			}else if(index >= 30){
			strComment = "\nObese";
			}else if(index >= 25){
			strComment = "\nOverweight";
			}else if(index >= 18.5){
			strComment = "\nIdeal";
			}else if(index <= 18.4){
			strComment = "\nUnderweight";
			}else{
			strComment = " ";
			
		};
		if (!index) index = " ";
		if (!index) strComment = " ";
		document.bmi.result.value = index + strComment;
}
function BMI2(){
		meters = document.bmi2.meters.value;
		if (!(meters > 0)) alert ("You must fill in the \"height\" box with a number.");
		kilos = document.bmi2.weight2.value;
		if (!(kilos > 0)) alert ("You must fill in the \"weight\" box with a number.");  
		index = meters
		index = index * index;
		index = kilos/index; 
		index = Math.round (index);
		if (index >= 40){
			strComment = "\nVery Obese";
			}else if(index >= 30){
			strComment = "\nObese";
			}else if(index >= 25){
			strComment = "\nOverweight";
			}else if(index >= 18.5){
			strComment = "\nIdeal";
			}else if(index <= 18.4){
			strComment = "\nUnderweight";
			}else{
			strComment = " ";
			
		};
		if (!index) index = " ";
		if (!index) strComment = " ";
		document.bmi2.result.value = index + strComment;
}