function changeUnits(unit)
{
	document.getElementById("lblAnswer").innerHTML = "0.00";
	
	if (unit == "standard")
	{
		// labels
		document.getElementById("lblCODUnit").innerHTML = "inches";
		document.getElementById("lblRollDiameterUnit").innerHTML = "inches";
		document.getElementById("lblWebCaliperUnit").innerHTML = "inches";
		document.getElementById("lblAnswerUnit").innerHTML = "feet";
		
		// values
		document.getElementById("txtCOD").value = convert('millimetersToInches', document.getElementById("txtCOD").value);
		document.getElementById("txtRollDiameter").value = convert('millimetersToInches', document.getElementById("txtRollDiameter").value, 3);
		document.getElementById("txtWebCaliper").value = convert('micronsToInches', document.getElementById("txtWebCaliper").value, 4);
		
	}
	else
	{
		// labels
		document.getElementById("lblCODUnit").innerHTML = "millimeters";
		document.getElementById("lblRollDiameterUnit").innerHTML = "millimeters";
		document.getElementById("lblWebCaliperUnit").innerHTML = "microns";
		document.getElementById("lblAnswerUnit").innerHTML = "meters";
		
		// values
		document.getElementById("txtCOD").value = convert('inchesToMillimeters', document.getElementById("txtCOD").value, 4);
		document.getElementById("txtRollDiameter").value = convert('inchesToMillimeters', document.getElementById("txtRollDiameter").value, 3);
		document.getElementById("txtWebCaliper").value = convert('inchesToMicrons', document.getElementById("txtWebCaliper").value, 4);
	}
}

function calculate()
{
	var diameter, core, caliper, answer, multiplier;
	var measure, precision;
	
	if (document.frmMain.rdoMeasurement[0].checked)
	{
		measure = document.frmMain.rdoMeasurement[0].value.toLowerCase();
	}
	else
	{
		measure = document.frmMain.rdoMeasurement[1].value.toLowerCase();
	}
	
	// formula inputs
	diameter = document.getElementById("txtRollDiameter").value;
	core = document.getElementById("txtCOD").value;
	caliper = document.getElementById("txtWebCaliper").value;
	
	if (measure == 'standard')
	{
		multiplier = 0.06545;
		precision = 2;
		answer = (multiplier * (diameter * diameter - core * core)) / caliper;
	}
	else
	{
		multiplier = 0.0007854;
		precision = 3;
		answer = ((diameter * diameter - core * core) * Math.PI / 4) / caliper;
	}
	
	answer = roundIt(answer, precision);
	
	document.getElementById("lblAnswer").innerHTML = answer;
}
