<!-- 

// Clears all text boxes, ready for fresh input
function ClearForm(Cform) {
    for (var i=0; i < document.frmPower.length-1; i++) document.frmPower.elements[i].value = "";
    return true;
}

// Obtain the index of the text box which was used as the principal value
function GetEnteredValue() {

	var arrBoxes = new Array(4);
	arrBoxes[0] = document.frmPower.nms.value;
	arrBoxes[1] = document.frmPower.watts.value;
	arrBoxes[2] = document.frmPower.hp.value;
	arrBoxes[3] = document.frmPower.kws.value;
	
	for (var i = 0; arrBoxes.length-1; i++) {
	
		if (arrBoxes[i].length > 0) {
		
			return i
			
			}

	}

}

function Convert() {

	// Obtain index
	var index = GetEnteredValue()

	if (index == 0) {
	
		// NM/S Entered
		document.frmPower.watts.value = (document.frmPower.nms.value * 1);
		document.frmPower.hp.value = (document.frmPower.nms.value * 0.00134);
		document.frmPower.kws.value = (document.frmPower.nms.value / 100);

	}
	
	if (index == 1) {
	
		// Watts entered
		document.frmPower.hp.value = (document.frmPower.watts.value * 0.00134);
		document.frmPower.kws.value = (document.frmPower.watts.value / 100);
		document.frmPower.nms.value = (document.frmPower.watts.value * 1);

	}
	
	if (index == 2) {
	
		// HP entered
		document.frmPower.kws.value = (document.frmPower.hp.value * 0.7462);
		document.frmPower.nms.value = (document.frmPower.hp.value * 746.2);
		document.frmPower.watts.value = (document.frmPower.hp.value * 746.2);
		
	}
	
	if (index == 3) {
	
		// Kws entered
		document.frmPower.nms.value = (document.frmPower.kws.value * 100);
		document.frmPower.watts.value = (document.frmPower.kws.value * 100);
		document.frmPower.hp.value = (document.frmPower.kws.value * 1.34);
		
	}
	
}

// end hiding -->
