function check(ad)
{
	var ch=ad.value;
	if(isNaN(ch))
	{
		var df=ch.substring(0,(ch.length-1))
		ad.value=df;
	}	
}

function bmr()
{
	var wt = document.first.wg.value;
	var ht = document.first.ht.value;
	var a = document.first.a.value;
	
	var op = document.first.opt1.value;
	
	//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(op=="pounds" && wt<=22)
	{
		alert("Weight should be greater than 22lbs");
	}
	else if(ht<33)
	{
		alert("Height should be taller than 33cms");
	}
	else{
		if(op=="kilograms")
		{
			wt=wt*2.2;
		}
		if(document.first.m.checked==true){
			var r1 = 66 + (13.7 * (wt/2.2)) + (5 * ht) - (6.8 * a);
			var r2 = 66 + (6.23 * wt) + (12.7 * ht/2.54) - (6.8 * a);
			document.first.r1.value = Math.round(r1*100)/100;
			document.first.r2.value = Math.round(r2*100)/100;
		}
		else if(document.first.fe.checked==true){
			
			var r1 = 655 + (9.6 * (wt/2.2)) + (1.8 * ht) - (4.7 * a);
			var r2 = 655 + (4.35 * wt) + (4.7 * ht/2.54) - (4.7 * a);
			document.first.r1.value = Math.round(r1*100)/100;
			document.first.r2.value = Math.round(r2*100)/100;
		}
		else{
			alert("Select the gender");
		}
		
	}
	
}
function conv(aa)//Height conversion
{
	var ft=0, inc=0, ht=0;
	if(aa==1 || aa==2)
	{
		ft = document.first.opt2.value;
		inc = document.first.opt3.value;
		var ss = ft*12;
		var tot = ss+parseInt(inc);
       	var val= tot*2.54;
		document.first.ht.value = Math.round(val);
	}

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

}

function unit()  //Weight conversion
{
	var pp = document.first.opt1.value;
	var ww = document.first.wg.value;
	
	//Kilogram to pounds
	if(pp=="pounds")	
	{
		document.first.wg.value = Math.round((ww*2.2)*100)/100;
	}

	//Pounds to kilograms
	else
	{
		document.first.wg.value=Math.round(ww/2.2);
	}
}
function chk(){
	var xx = document.first.m;
	if(xx.checked=true){
	document.first.fe.checked = false;
	}
}	
function chk1(){
	var xx = document.first.fe;
	if(xx.checked=true){
	document.first.m.checked = false;
	}
}	
		


function color(test)
{

	for(var j=2; j<10; j++)
	{
		var myI=document.getElementsByTagName("input").item(j);
		//myI.setAttribute("style",ch);
		myI.style.backgroundColor=test;
	}
}


function color1(test)
{
var myI=document.getElementsByTagName("table").item(0);
//myI.setAttribute("style",ch);
myI.style.backgroundColor=test;
}


