function round(number,X) {
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


function UpdateDistance(input) {
	var Dist=input.value*1;
	var Type=input.name;
	
	if (Type == "km")	   { A = Dist * 10000000000000; }
	else if (Type == "m")  { A = Dist * 10000000000; }
	else if (Type == "cm") { A = Dist * 100000000; }
	else if (Type == "mia") { A = Dist * 16093440000000; }
	else if (Type == "roa") { A = Dist * 50292000000; }
	else if (Type == "yda") { A = Dist * 9144000000; }
	else if (Type == "pia") { A = Dist * 3048000000; }
	else if (Type == "poa") { A = Dist * 254000000; }
	else if (Type == "ena") { A = Dist * 2194560000000; }
	else if (Type == "bra") { A = Dist * 18288000000; }
	else if (Type == "mn") { A = Dist * 18520000000000; }
	else if (Type == "brn") { A = Dist * 18520000000; }
	else if (Type == "enn") { A = Dist * 1852000000000; }
	else if (Type == "br") { A = Dist * 16242000000; }
	else if (Type == "en") { A = Dist * 1949040000000; }
	else if (Type == "ln") { A = Dist * 55560000000000; }
	else if (Type == "mr") { A = Dist * 14842650000000; }
	else if (Type == "par") { A = Dist * 14842650000; }
	else if (Type == "dr") { A = Dist * 185533125; }
	else if (Type == "pr") { A = Dist * 2968530000; }  
	else if (Type == "gr") { A = Dist * 7421325000; }
	else if (Type == "mif") { A = Dist * 19490400000000; }
	else if (Type == "pef") { A = Dist * 58471200000; }
	else if (Type == "tof") { A = Dist * 19490400000; }
	else if (Type == "vef") { A = Dist * 9745200000; }
	else if (Type == "pif") { A = Dist * 3248400000; }
	else if (Type == "pof") { A = Dist * 270700000; }

	km = round(A*0.0000000000001);
	m = round(A*0.0000000001);
	cm = round(A*0.00000001);
	mia = round(A*0.00000000000006213711);
	roa = round(A*0.000000000019883878151594686);
	yda = round(A*0.0000000001093613);
	pia = round(A*0.000000000328084);
	poa = round(A*0.000000003937008);
	ena = round(A*0.0000000000004556722076407116);
	bra = round(A*0.00000000005468066491688539);
	mn = round(A*0.00000000000005399568034557236);
	brn = round(A*0.00000000005399568034557236);
	enn = round(A*0.0000000000005399568034557236);
	br = round(A*0.00000000006156877231867997);
	en = round(A*0.0000000000005130731026556664);
	ln = round(A*0.000000000000017998560115190785);
	mr = round(A*0.00000000000006737341377718938);
	par = round(A*0.00000000006737341377718938);
	dr = round(A*0.00000000538987310217515);
	pr = round(A*0.0000000003368670688859469);
	gr = round(A*0.00000000013474682755437876);
	mif = round(A*0.00000000000005130731026556664);
	pef = round(A*0.00000000001710243675518888);
	tof = round(A*0.00000000005130731026556664);
	vef = round(A*0.00000000010261462053113328);
	pif = round(A*0.000000000307843861593399);
	pof = round(A*0.0000000036941263391207978);

	if (Type != "km") { document.Distances.km.value=km; }
	if (Type != "m")  { document.Distances.m.value=m; }
	if (Type != "cm")  { document.Distances.cm.value=cm; }
	if (Type != "mia") { document.Distances.mia.value=mia; }
	if (Type != "roa") { document.Distances.roa.value=roa; }
	if (Type != "yda") { document.Distances.yda.value=yda; }
	if (Type != "pia") { document.Distances.pia.value=pia; }
	if (Type != "poa") { document.Distances.poa.value=poa; }
	if (Type != "ena") { document.Distances.ena.value=ena; }
	if (Type != "bra") { document.Distances.bra.value=bra; }
	if (Type != "mn") { document.Distances.mn.value=mn; }
	if (Type != "brn") { document.Distances.brn.value=brn; }
	if (Type != "enn") { document.Distances.enn.value=enn; }
	if (Type != "br") { document.Distances.br.value=br; }
	if (Type != "en") { document.Distances.en.value=en; }
	if (Type != "ln") { document.Distances.ln.value=ln; }
	if (Type != "mr") { document.Distances.mr.value=mr; }
	if (Type != "par") { document.Distances.par.value=par; }
	if (Type != "dr") { document.Distances.dr.value=dr; }
	if (Type != "pr") { document.Distances.pr.value=pr; }
	if (Type != "gr") { document.Distances.gr.value=gr; }
	if (Type != "mif") { document.Distances.mif.value=mif; }
	if (Type != "tof") { document.Distances.tof.value=tof; }
	if (Type != "pef") { document.Distances.pef.value=pef; }
	if (Type != "vef") { document.Distances.vef.value=vef; }
	if (Type != "pif") { document.Distances.pif.value=pif; }
	if (Type != "pof") { document.Distances.pof.value=pof; }
}


