function cleartext(inputname)
{
	if (inputname.value == "CLOTHES SIZE")
	{
		inputname.value = "";
	}
};
function writeText(strName,strValue,intWidth)
{
	if (document.layers)
	{
		document.write("<input id=\"" + strName + "\" name=\"" + strName + "\" value=\"" + strValue + "\" type=\"text\" onkeyup=\"convertIt()\" onblur=\"blurClothes()\" onkeydown=\"convertIt()\" onFocus=\"cleartext(" + strName + ")\" size=\"" + Math.round(parseInt(intWidth / 11)) + "\">");
	}
	else
	{
		document.write("<input id=\"" + strName + "\" name=\"" + strName + "\" value=\"" + strValue + "\" type=\"text\" onkeyup=\"convertIt()\" onblur=\"blurClothes()\" onkeydown=\"convertIt()\" onFocus=\"cleartext(" + strName + ")\" class=\"textarea\" style=\"width:" + intWidth + "px;\">");
	}
};
function blurClothes()
{
	if (document.getElementById("clothes").value == "")
	{
		document.getElementById("clothes").value = "CLOTHES SIZE";
	}
};
var intClothes, intFrom, intTo, intTotal, strTo, strFrom, strTotal;
function convertIt()
{
	intClothes = document.convert.clothes.value;
	intFrom = document.convert.elements[1].selectedIndex;
	intTo = document.convert.elements[2].selectedIndex;
	if (intClothes != "" && intClothes != "CLOTHES SIZE" && isNaN(intClothes) == false && document.getElementById("from").selectedIndex != 0 && document.getElementById("to").selectedIndex != 0)
	{
		switch(intFrom)
	  	{
			case 1:
				intTotal = fromUK(intClothes, intTo);
				strFrom = "UK";
				break;
			case 2:
				intTotal = fromCont(intClothes, intTo);
				strFrom = "Continental";
				break;
			case 3:
				intTotal = fromUS(intClothes, intTo);
				strFrom = "US";
				break;
			default:
				return true;
	  	}	
		if (intTotal < 0)
		{
			strTotal = "Incorrect size entered";
		}
		else
		{
			strTotal = intClothes + " " + strFrom + " = " + intTotal + " " + strTo;
		}
		if (document.all)
		{
			document.all.answer.innerHTML = strTotal;
		}
		else if(document.layers)
		{
			document.answer.document.write(strTotal);
			document.answer.document.close();
		}
		else if(document.getElementById)
		{
			document.getElementById("answer").innerHTML = strTotal;
		}
	}
	else
	{
		document.getElementById("answer").innerHTML = "";
	}
};
function fromUK(intClothes, selectTo)
{
	switch(selectTo)
	{
		case 1:
			finalNumber = intClothes;
			strTo = "UK";
			break;
		case 2:
			finalNumber = 28 + parseInt(intClothes);
			strTo = "Continental";
			break;
		case 3:
			finalNumber = parseInt(intClothes) - 4;
			strTo = "US";
			break;
	}
	return finalNumber;
};
function fromCont(intClothes, selectTo)
{
	switch(selectTo)
	{
		case 1:
			finalNumber = parseInt(intClothes) - 28;
			strTo = "UK";
			break;
		case 2:
			finalNumber = intClothes;
			strTo = "Continental";
			break;
		case 3:
			finalNumber = parseInt(intClothes) - 28 - 4;
			strTo = "US";
			break;
	}	
	return finalNumber;
};
function fromUS(intClothes, selectTo)
{
	switch(selectTo)
	{
		case 1:
			finalNumber = parseInt(intClothes) + 4;
			strTo = "UK";
			break;
		case 2:
			finalNumber = parseInt(intClothes) + 28 + 4;
			strTo = "Continental"
			break;
		case 3:
			finalNumber = intClothes;
			strTo = "US";
			break;
	}	
	return finalNumber;
};
function aolFrig()
{
	if (blnAOL)
	{
		if (document.all)
		{
			document.all.answer.style.top = 534;
		}
		else if(document.getElementById)
		{
			document.getElementById("answer").style.top = 534;
		}
	}
};
