function compute(form) {
	window.status="Calculations ongoing"
	if (form.copyright.value=="(c) V. Reijs, 2000")
	{}
	else
	{alert("(C) Copyright JavaScript V. Reijs, 2000")}
	angela=parseFloat(form.angel.value)
	pa=parseFloat(form.P.value)
	if (pa < 0 || isNaN (pa)) {
		alert("AIR PRESSURE should be positive")
	}
	ta=273.15 + parseFloat(form.T.value)
	if (ta <= 0 || isNaN (ta)) {
		alert("TEMPERATURE should be higher than -273°C")
	}
	aaa=parseFloat(form.AA.value)
	if (aaa < -2 || isNaN (aaa) || aaa>30) {
		alert("APPARENT ALTITUDE should be higher than -2° and smaller than 30°")
	}
	ha=parseFloat(form.H.value)
	deltaha=parseFloat(form.deltaH.value)
	if (isNaN (ha)) {
		alert("DISTAND HEIGHT altitude should be positive or negative")
	}	
	heighta= parseFloat(form.height.value)
	if (isNaN(heighta)) {heighta=form.heightoud.value}
	if (heighta=="") {heighta=1}
        if (heighta==1) {heighta=1}
        if (heighta==2) {heighta=2}
	form.heightoud.value=heighta
	kma=parseFloat(form.Km.value)
	deltakma=parseFloat(form.deltaKm.value)
	if (kma <= 0 || isNaN (kma)) {
		alert("DISTANCE should be positive")
	}	
	hha=parseFloat(form.HH.value)
	if (isNaN (hha)) {
		alert("LOCAL HEIGHT altitude should be positive or negative")
	}	
	     kka=parseFloat(form.kknew.value)
	if (isNaN(kka)) {kka=form.kkoud.value}
	if (kka=="") {kka=2}

        if (kka==2) {ka=10.64; errorka=1.56}
        if (kka==6) {ka=7.5; errorka=0.31}
        if (kka==3) {ka=4.91; errorka=0.16}
        if (kka==4) {ka=parseFloat(form.Userk.value); errorka=parseFloat(form.ErrorUserk.value)}
// assuming an error of 2 m/sec in the windspeed (wind can vary from zero to 12 m/sec)
        if (kka==5) {
windspeed=parseFloat(form.WSpeed.value); 
errorwindspeed=parseFloat(form.ErrorWSpeed.value);
ka=(0.0039*Math.pow(Math.min(windspeed,8),2) - 0.077*Math.min(windspeed,8) + 0.5269)/0.0238;
errorka=-(0.0039*2*Math.min(windspeed,8)- 0.077)/0.0238*errorwindspeed;
}
// determine lapse rate due to refraction
lapse=-(ka*0.0238*0.154-0.034)*1000
// alert(lapse)
// determine temp and pressure in case given values are at sea level.
		if (heighta==2) {
			ta=ta-lapse*hha/1000
				// use average temp (sea and local temp) for airpressure determination
			pa=pa*Math.exp(-9.80665*0.0289644/(ta+3.25*hha/1000)/8.31441*hha)
		};
form.Userk.value=Math.round(ka*100)/100
form.ErrorUserk.value=Math.round(errorka*100)/100
	form.kkoud.value=kka
// formula from Sinclair
	refrac2 = pa * (0.1594 + 0.0196*aaa + 0.00002*aaa*aaa)/ ta/(1 +0.505*aaa+0.0845*aaa*aaa)
// from The calculation of astronomical refraction in marine navigation
// temp and pressure compensation
              tf=(ta-273.15)/5*9+32
              pim=pa/33.8639
              weathercomp= 510/(460+tf)*pim/(29.83)
//an intermeditae value
              refractM=Math.tan((90-(aaa+7.31/(aaa+4.4)))/180*Math.PI)
              refract1=weathercomp*(refractM-0.06*Math.sin((14.7*refractM+13)/180*Math.PI))/60
              refract=refract1
	form.Alt.value = Math.round((aaa -refract)*100)/100
	terrefract = 0.057288*(ha-hha)/kma-0.00447387*kma+0.008296359*ka*kma*pa/ta/ta
	form.terrefract.value = Math.round(terrefract*100)/100
	tererror= Math.pow(0.057288*2*deltaha/kma,2)
	tererror=tererror+ Math.pow(deltakma*(-0.057288*ha/kma/kma-0.00447387+0.0087308*ka*pa/ta/ta),2)
	tererror=tererror+ Math.pow(0.008296359*errorka*kma*pa/ta/ta,2)
	tererror=Math.sqrt(tererror)
	form.errorterrefract.value = Math.round(tererror*1000)/1000
	searefract= -0.03203*Math.sqrt(hha)*Math.sqrt(1-1.848042142*ka*pa/ta/ta)
	form.searefract.value = Math.round(searefract*100)/100
	errorsearefract = Math.pow(0.03203/2/Math.sqrt(hha)*Math.sqrt(1-1.848042142*ka*pa/ta/ta)*deltaha,2)
	errorsearefract = errorsearefract+Math.pow(0.03203*Math.sqrt(hha)/Math.sqrt(1-1.848042142*ka*pa/ta/ta)*(1.848042142*errorka*pa/ta/ta),2)
	errorsearefract=Math.sqrt(errorsearefract)
	form.errorsearefract.value = Math.round(errorsearefract*1000)/1000
	if (searefract > terrefract ) {
		if (ha > hha) { alert("WARNING: The distant object is behind the horizon")
			}
			else {
		alert("WARNING: The vast plain horizon is above the distant object")
			}
	}	

	form.celsius.value = 5/9*(angela-32)
        form.meter.value = .3048*angela
        form.kmeters.value=1.609344*angela
	form.mbar.value= angela*33.7685
	form.mbarmm.value= angela*1.328389
		window.status="Calculations finished"

}

