
function calcEyepieceValues(clientID)
{
	pupil = document.getElementById(clientID + '_ResExitPupil');
	pupil.className = 'results';
	elt = document.getElementById(clientID + '_ResultMsg');
	elt.innerHTML = '&nbsp;';
	elt.className = '';
	
	eyeAFoV			= document.getElementById(clientID + '_EyeAFoV').value;
	eyeFocalLen		= document.getElementById(clientID + '_EyeFocalLen').value;
	telFocalLen		= document.getElementById(clientID + '_TelFocalLen').value;
	telAperture		= document.getElementById(clientID + '_TelAperture').value;
	telFocalRatio	= document.getElementById(clientID + '_TelFocalRatio').value;
	
	if (telFocalLen == '') {
		if (telAperture != '' && telFocalRatio != '') telFocalLen = telAperture * telFocalRation;
	} else if (telAperture == '') {
		if (telFocalLen != '' && telFocalRatio != '') telAperture = telFocalLen / telFocalRatio;
	} else {
		telFocalRatio = telFocalLen / telAperture;
	}
	if (telFocalLen > 0 && telAperture > 0 && telFocalRatio > 0 && eyeAFoV > 0 && eyeFocalLen > 0) {
		mag = telFocalLen / eyeFocalLen;
		exitPupil = eyeFocalLen / telFocalRatio;
		trueField = eyeAFoV / mag;
		document.getElementById(clientID + '_ResMag').innerHTML = mag.toFixed(0).toString() + '&times;';
		document.getElementById(clientID + '_ResTrueField').innerHTML = trueField.toFixed(2).toString() + '&deg;';
		pupil.innerHTML = exitPupil.toFixed(1).toString() + ' mm';
		elt = document.getElementById(clientID + '_ResultMsg');
		if (exitPupil < 0.5) {
			elt.innerHTML = 'Error: exit pupils below 0.5mm are not recommended for most observers';
			elt.className = 'error';
			pupil.className = 'results resultError';
		} else if (exitPupil < 1.0) {
			elt.innerHTML = 'Warning: image brightness of deep space objects is noticably diminished with exit pupils below 1mm';
			elt.className = 'warning';
			pupil.className = 'results resultWarning';
		} else if (exitPupil > 7.0) {
			elt.innerHTML = 'Error: this result exceeds the maximum 7mm pupil dialation of the human eye';
			elt.className = 'error';
			pupil.className = 'results resultError';
		} else if (exitPupil > 6.0) {
			elt.innerHTML = 'Warning: this result falls within the 6-7mm range of maximum pupil dialation of the human eye';
			elt.className = 'warning';
			pupil.className = 'results resultWarning';
		}

	}
}
