var kg = 1;
var oz = 35.274;
var lbs = 2.2046;
var tlbs = 2.6793;
var stone = 0.1378;
var ston = 0.0011;
var lton = 0.001;
theform = document.weight;

function calibrate_Weight(theform)
{
	theform.kg.value=parseFloat(kg);
	theform.oz.value=parseFloat(oz);
	theform.lbs.value=parseFloat(lbs);
	theform.tlbs.value=parseFloat(tlbs);
	theform.stone.value=parseFloat(stone);
	theform.ston.value=parseFloat(ston);
	theform.lton.value=parseFloat(lton);
	
}

function clear_Weight(theform)
{
	theform.kg.value="";
	theform.oz.value="";
	theform.lbs.value="";
	theform.tlbs.value="";
	theform.stone.value="";
	theform.ston.value="";
	theform.lton.value="";

}

function check_Weight(theform)
{
	if(theform.kg.value == "" && theform.oz.value == "" && theform.lbs.value == "" && theform.tlbs.value == "" && theform.stone.value == "" && theform.ston.value == "" && theform.lton.value == "")
	{
		alert("No value entered!");
	}
	else if (theform.kg.value != "" && theform.oz.value != "" && theform.lbs.value != "" && theform.tlbs.value != "" && theform.stone.value != "" && theform.ston.value != "" && theform.lton.value != "")
	{
		//alert("heller");
	}
	else
	{
		compute_Weight(theform);
	}
}

function compute_Weight(theform)
{
	
	var kg_txt = document.weight.kg.value
	var oz_txt = document.weight.oz.value
	var lbs_txt = document.weight.lbs.value
	var tlbs_txt = document.weight.tlbs.value
	var stone_txt = document.weight.stone.value
	var ston_txt = document.weight.ston.value
	var lton_txt = document.weight.lton.value

	if (theform.kg.value != "")
	{
		kg_w = parseFloat(kg_txt);
		oz_w = kg_txt * oz;
		lbs_w = kg_txt * lbs;
		tlbs_w = kg_txt * tlbs;
		stone_w = kg_txt * stone;
		ston_w = kg_txt * ston;
		lton_w = kg_txt * lton;
	}

	else if (theform.oz.value != "")
	{
		kg_w =  oz_txt / oz;
		oz_w = parseFloat(oz_txt);
		lbs_w = kg_w * lbs;
		tlbs_w = kg_w * tlbs;
		stone_w = kg_w * stone;
		ston_w = kg_w * ston;
		lton_w = kg_w * lton;
	}

	else if (theform.lbs.value != "")
	{
		kg_w =  lbs_txt / lbs;
		oz_w = kg_w * oz;
		lbs_w = parseFloat(lbs_txt);
		tlbs_w = kg_w * tlbs;
		stone_w = kg_w * stone;
		ston_w = kg_w * ston;
		lton_w = kg_w * lton;
	}

	else if (theform.tlbs.value != "")
	{
		kg_w =  tlbs_txt / tlbs;
		oz_w = kg_w * oz;
		lbs_w = kg_w * oz;;
		tlbs_w = parseFloat(tlbs_txt);
		stone_w = kg_w * stone;
		ston_w = kg_w * ston;
		lton_w = kg_w * lton;
	}


	else if (theform.stone.value != "")
	{
		kg_w =  stone_txt / stone;
		oz_w = kg_w * oz;
		lbs_w = kg_w * oz;;
		tlbs_w = kg_w * tlbs;
		stone_w = parseFloat(stone_txt);
		ston_w = kg_w * ston;
		lton_w = kg_w * lton;
	}


	else if (theform.ston.value != "")
	{
		kg_w =  ston_txt / ston;
		oz_w = kg_w * oz;
		lbs_w = kg_w * oz;;
		tlbs_w = kg_w * tlbs;
		stone_w = kg_w * stone;
		ston_w = parseFloat(ston_txt);
		lton_w = kg_w * lton;
	}


	else if (theform.lton.value != "")
	{
		kg_w =  lton_txt / lton;
		oz_w = kg_w * oz;
		lbs_w = kg_w * oz;;
		tlbs_w = kg_w * tlbs;
		stone_w = kg_w * stone;
		ston_w = kg_w * ston;
		lton_w = parseFloat(lton_txt);
	}

	else
	{
		alert("no result");
	}


		kg_w = Math.round(kg_w * 10000)/10000;
		oz_w = Math.round(oz_w * 10000)/10000;
		lbs_w = Math.round(lbs_w * 10000)/10000;
		tlbs_w = Math.round(tlbs_w * 10000)/10000;
		stone_w = Math.round(stone_w * 10000)/10000;
		ston_w = Math.round(ston_w * 10000)/10000;
		lton_w = Math.round(lton_w * 10000)/10000;

		theform.kg.value = parseFloat(kg_w);
		theform.oz.value = parseFloat(oz_w);
		theform.lbs.value = parseFloat(lbs_w);
		theform.tlbs.value = parseFloat(tlbs_w);
		theform.stone.value = parseFloat(stone_w);
		theform.ston.value = parseFloat(ston_w);
		theform.lton.value = parseFloat(lton_w);



}