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

function bal()
{
	var wt = document.first.wg.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(op=="kilograms")
		{
			wt=wt*2.2;
		}
		document.first.r1.value = Math.round((wt/2)*100)/100;
		document.first.r2.value = Math.round((wt*15)*100)/100;
		document.first.r3.value = Math.round((wt/16)*100)/100;
	}
	
}
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 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;
}


