function calc(form)
{
	//get weight and height
	var wt = form.wg.value;
	var ht = form.ht.value;
	
	//US value
	var lb = wt*2.20462262;
	var ic = ht*0.39;
	var us = Math.round((703*(lb/(ic * ic)))*100)/100;
	//document.bmi.us.value = us;
		
	//If value is not given for weight
	if(wt=="")
	{
		alert("Enter the value for weight");
	}

	//If weight is less than 10
	else if(wt<=10)
	{
		alert("Weight should be greater than 10kgs");
	}
	
	//If weight is pounds and less than 22lbs
	else if(wt<=22)
	{
		alert("Weight should be greater than 22lbs");
	}
	
	//If given height is less than 33cms
	else if(ht<33)
	{
		alert("Height should be taller than 33cms");
	}
	else
	{
		//document.bmi.us.value=Math.round((us/2.20462262)*100)/100;
		us = Math.round((us/2.20462262)*100)/100;
		document.getElementById("bmiresult").style.visibility= 'visible';
	}
	
	/* 
	*  Underweight = <18.5
    * Normal weight = 18.5-24.9
    * Overweight = 25-29.9
    * Obesity = BMI of 30 or greater

	*/
	
	
	if(us<=18.5)
	{
		document.getElementById("catresult").innerHTML="Underweight";
	}
	else if(us>18.5 && us<=25)
	{	
		document.getElementById("catresult").innerHTML="Normal Weight";
	}
	else if(us>25 && us<=30)
	{
		document.getElementById("catresult").innerHTML="Overweight";
	}
	else if(us>30)
	{
		document.getElementById("catresult").innerHTML="Obesity";
	}
	
	//return us; 
	document.getElementById("theresult").innerHTML=" "+us; 
	
}


function conv(aa)//Height conversion
{
	var ft=0, inc=0, ht=0;
	if(aa==1 || aa==2)
	{
		ft = document.bmi.opt2.value;
		inc = document.bmi.opt3.value;
		var ss = ft*12;
		var tot = ss+parseInt(inc);
       	var val= tot*2.54;
		document.bmi.ht.value = Math.round(val);
	}

	else{
		ht = document.bmi.ht.value;
		if(ht!="")
		{
			var cm=Math.round(ht/2.54);
			var div=parseInt(cm/12);
			var md=cm%12;
			document.bmi.opt2.value=div;
			document.bmi.opt3.value=md;
		}
         }

}



