/* $Header: convert.js,v 1.7 2002/09/27 13:33:37 samirh Exp $             

Alexander Helbing JavaScript Conversion Calcualtor 
Created: 21 August 2003
***Revised 21 August 2003 (Alexander Helbing) ***

Description:
	Convert Values which are being parsed from the HTML/ASP page for tihs JavaScript 
	and converts them to the representative values.


*/
function setValues(typeValue) {
	if (typeValue == 'Length') {
		inputValue = LengthConverter.LengthInput.value;
		conversionValue = LengthConverter.LengthSelection.options[LengthConverter.LengthSelection.selectedIndex].value;
		calcLength(typeValue,inputValue,conversionValue);
	}
	if (typeValue == 'Area') {
		inputValue = AreaConverter.AreaInput.value;
		conversionValue = AreaConverter.AreaSelection.options[AreaConverter.AreaSelection.selectedIndex].value;
		calcLength(typeValue,inputValue,conversionValue);
	}
	if (typeValue == 'Volume') {
		inputValue = VolumeConverter.VolumeInput.value;
		conversionValue = VolumeConverter.VolumeSelection.options[VolumeConverter.VolumeSelection.selectedIndex].value;
		calcLength(typeValue,inputValue,conversionValue);
	}
	if (typeValue == 'Weight') {
		inputValue = WeightConverter.WeightInput.value;
		conversionValue = WeightConverter.WeightSelection.options[WeightConverter.WeightSelection.selectedIndex].value;
		calcLength(typeValue,inputValue,conversionValue);
	}
}
function calcLength(typeValue,inputValue,conversionValue) { 
	var conResult = inputValue * conversionValue
	if( isNaN( conResult ) ) { 
		alert('Please enter a number in the '+typeValue+' field.'); 
		conResult = 'Result';
	}
	if (typeValue == 'Length') {
		LengthConverter.LengthResult.value = conResult;
	}
	if (typeValue == 'Area') {
		AreaConverter.AreaResult.value = conResult;
	}
	if (typeValue == 'Volume') {
		VolumeConverter.VolumeResult.value = conResult;
	}
	if (typeValue == 'Weight') {
		WeightConverter.WeightResult.value = conResult;
	}
}

function fnSetTabArea(typeValue) {
	if (typeValue = 'Length') { document.LengthConverter.LengthInput.focus(); }
	if (typeValue = 'Area') { document.LengthConverter.AreaInput.focus(); }
	if (typeValue = 'Volume') { document.LengthConverter.VolumeInput.focus(); }
	if (typeValue = 'Weight') { document.LengthConverter.WeightInput.focus(); }
}