	function cleartext(inputname)
	{
		if (inputname.value == "DISTANCE")
		{
			inputname.value = "";
		}
	};
	function blurDistance()
	{
		if (document.getElementById("distance").value == "")
		{
			document.getElementById("distance").value = "DISTANCE";
		}
	};
	function writeText(strName, strValue, intWidth)
	{
		if (document.layers)
		{
			document.write("<input id=\"" + strName + "\" name=\"" + strName + "\" value=\"" + strValue + "\" type=\"text\" onblur=\"blurDistance()\" onkeyup=\"convertIt()\" onFocus=\"cleartext(" + strName + ")\" size=\"" + Math.round(parseInt(intWidth / 11)) + "\">");
		}
		else
		{
			document.write("<input id=\"" + strName + "\" name=\"" + strName + "\" value=\"" + strValue + "\" type=\"text\" onblur=\"blurDistance()\" onkeyup=\"convertIt()\" onFocus=\"cleartext(" + strName + ")\" class=\"textarea\" style=\"width:" + intWidth + "px;\">");
		}
	};
	function convertIt()
	{
		var intFrom, intTo, intDistance, intTotal, strDistance;
		intDistance = document.convert.distance.value;
		intFrom = document.convert.elements[1].options[document.convert.elements[1].selectedIndex].value;
		intTo = document.convert.elements[2].options[document.convert.elements[2].selectedIndex].value;
		if (intDistance != "" && intDistance != "DISTANCE" && intFrom != "" && document.getElementById("from").selectedIndex != 0 && intTo != "" && document.getElementById("to").selectedIndex != 0)
		{
			//figure out which value to use ie kg, ton etc
			switch (parseFloat(intTo))
			{
				case 0.001:
					strDistance = "Kilometres";
					break;
				case 1:
					strDistance = "Metres";
					break;
				case 100:
					strDistance = "Centimetres";
					break;
				case 1000:
					strDistance = "Millimetres";
					break;
				case 0.000621371192237334:
					strDistance = "Miles";
					break;
				case 1.09361329833771:
					strDistance = "Yard";
					break;
				case 3.28083989501312:
					strDistance = "Feet";
					break;
				case 39.3700787401575:
					strDistance = "Inch";
					break;
			}
			//get total
			intTotal = parseFloat(intDistance / intFrom * intTo);
			//round off to 2 significant figures
			if (intTotal < 1)
			{
				temp = intTotal
				exp = 3
				while (temp < 1)
				{
					intExp = Math.pow(10, exp);
					temp = intTotal * intExp;
					exp++;
				}
				intExp = intExp * 10;
			}
			else
			{
				intExp = 100;
			}
			intTotal = (Math.round(intTotal * intExp)) / intExp;
			if (document.all)
			{
				document.all.answer.innerHTML = intTotal + " " + strDistance;
			}
			else if (document.layers)
			{
				document.answer.document.write(intTotal + " " + strDistance);
				document.answer.document.close();
			}
			else if (document.getElementById)
			{
				document.getElementById("answer").innerHTML = intTotal + " " + strDistance;
			}
		}
		else
		{
			document.getElementById("answer").innerHTML = "";
		}
	}
	function aolFrig()
	{
		if(blnAOL)
		{
			if(document.all)
			{
				document.all.answer.style.top = 534;
			}
			else if(document.getElementById)
			{
				document.getElementById("answer").style.top = 534;
			}
		}
	}
