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 ac = document.first.ac.value;
	var aq = document.first.aq.value;
	var h = document.first.h.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;
		}
		var r = (ac * aq * 0.075 / wt) - (h * 0.015);
		document.first.r.value = Math.round(r*100)/100;
	}
	if(r<0)
	{
		document.first.desc.value= "No Problem.";
	}
	else if(r>0 && r<=0.02)
	{
		document.first.desc.value= "Slight Body Warmth and Mellow feeling.";
	}
	else if(r>0.02 && r<=0.05)
	{
		document.first.desc.value= "Beginning of Coordination impairment and less attention.";
	}
	else if(r>0.05 && r<=0.08)
	{
		document.first.desc.value= "Drunk driving limit. Impairment in coordination.";
	}
	else if(r>0.08 && r<=0.10)
	{
		document.first.desc.value= "Noisy, Humiliating behavior.";
	}
	else if(r>0.10 && r<=0.15)
	{
		document.first.desc.value= "Clearly Drunk. Impaired balance and movement.";
	}
	else if(r>0.15 && r<=0.30)
	{
		document.first.desc.value= "Many lose consciousness.";
	}
	else if(r>0.30 && r<=0.40)
	{
		document.first.desc.value= "Most lose consciousness. Some DIE.";
	}
	else{
		document.first.desc.value= "Breathing Stops. Many DIE.";
	}
}
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;
}


