function calcwingloading() {
	with ( document.inputform ) {
		wingarea.value = wingspan.value * wingchord.value;
		metric_wingarea.value = metric_wingspan.value * metric_wingchord.value / 10000;

		wingloading.value = Math.round(  weight.value / ( wingarea.value / 144 ) * 1000 ) / 1000;
		metric_wingloading.value = Math.round(  metric_weight.value / metric_wingarea.value);		
	}

    return false;
	
}

function mph2meterspersecord( mph ) {
	return ( mph * 1609.344 / 3600 );
}

function meterspersecord2mph( mps ) {
	return ( mps / 1609.344 * 3600 );
}

function inoz2ncm( inoz ) {
	return (  inoz / 1.39 );
}

function ncm2inoz( ncm ) {
	return (  ncm * 1.39 );
}

function inch2cm( inch ) {
	return ( inch * 2.54);
}

function cm2inch( cm ) {
	return ( cm / 2.54);
}

function imp_name( metric_name ){
var Position = metric_name.indexOf("_");
var LastChar = metric_name.length;
	return metric_name.substring( Position + 1, LastChar );
}

// length

function entered_inches( theinput ) {
var entered_mm = 0;
	entered_mm = Math.round( theinput.value * 2.54 * 10 );
	eval("document.inputform.metric_"+theinput.name).value = entered_mm;
	return true;
}

function entered_mm( theinput ) {
var entered_inches = 0;
var impname = imp_name( theinput.name );

	entered_inches = Math.round( theinput.value / 2.54 / 10 );
	eval("document.inputform."+impname).value = entered_inches;
	return true;
}

// weight

function entered_oz( theinput)  {
var metric_val = Math.round( theinput.value / .0353 );
	eval("document.inputform.metric_"+theinput.name).value = metric_val;
	return true;
}

function entered_gm( theinput ) {
var imp_value = Math.round( theinput.value * .0353 );
var impname = imp_name( theinput.name );
	eval("document.inputform."+impname).value = imp_value;
	return true;
}



// distance

function entered_miles( theinput)  {
var metric_val = Math.round( theinput.value * 1.6093 );
	eval("document.inputform.metric_"+theinput.name).value = metric_val;
	return true;
}

function entered_km( theinput ) {
var imp_value = Math.round( theinput.value / 1.6093 );
var impname = imp_name( theinput.name );
	eval("document.inputform."+impname).value = imp_value;
	return true;
}

function calc_chord() {
var av_chord=0;
var met_av_chord=0;
	with (document.inputform) {
		if ((rchord.value > 0) && (tchord.value > 0)) {
			wingchord.value = ( (rchord.value/1) + (tchord.value/1) ) / 2;
			metric_wingchord.value = ( (metric_rchord.value/1) + (metric_tchord.value/1) ) / 2;						
		}
	}
	return true;
}


function round( Thevalue, Places ) {
	return (Math.round( Thevalue * Math.pow(10,Places) ) / Math.pow(10,Places));
}

