function warnings(n)
{
      if(n==1) alert("Calculation not possible.");
}
function windchil(form,speed)                // speed in m/s
{
    if(speed>25.)
	{form.wch.value="not defined"; return;}
    var t=parseFloat(form.temp.value);     // T in C ?
    var h=(10.45 + 10*Math.sqrt(speed) - speed) * (33-t);
    var wc = 33 - h/22.04;
    form.wch.value=ausgab(wc);
    return;
}


function calc(form,val,index)
{
if(index==0) v=val;               // m s-1
if(index==1) v=val/3.6;           // km h-1
if(index==2) v=val*(0.51+4/900);  // knots
if(index==3) v=val*0.44704;       // mi h-1
if(index==4) v=val*0.3048;        // ft s-1
if(index==5) v=val/60.;           // m min-1
if(index==6) v=val*0.3048/60.;    // ft min-1
if(index==7) v=chilinvers(form,val);                             // windchill
if(index==8) v=Math.sqrt(val*2./parseFloat(form.dich.value));           // Pa
if(index==9) v=Math.sqrt(val*47.8803*2./parseFloat(form.dich.value));   // lbf / sft

form.ms.value=ausgab(v);                 // m s-1
var kmh=v*3.6;
form.kmh.value=ausgab(v*3.6);            // km h-1
var knot=v/(0.51+4/900);
form.knot.value=ausgab(knot);            // knot
form.mih.value=ausgab(v/0.44704);        // mi h-1
form.fts.value=ausgab(v/0.3048);         // ft s-1
form.mmi.value=ausgab(v*60.);            // m min-1
form.ftm.value=ausgab(v/0.3048*60.);     // ft min-1
beaufort(form,knot);
windchil(form,v);
form.ppa.value=ausgab(parseFloat(form.dich.value)*v*v/2.)           // Pa
form.pfi.value=ausgab(parseFloat(form.dich.value)*v*v/2./47.8803)   // lbf / sft
return;
}
function beaufort(form,knot)
{
if(knot<=1) form.bea.value=ausgab(0);
if(knot>1 && knot<3.5) form.bea.value=ausgab(1);
if(knot>=3.5 && knot<6.5) form.bea.value=ausgab(2);
if(knot>=6.5 && knot<10.5) form.bea.value=ausgab(3);
if(knot>=10.5 && knot<16.5) form.bea.value=ausgab(4);
if(knot>=16.5 && knot<21.5) form.bea.value=ausgab(5);
if(knot>=21.5 && knot<27.5) form.bea.value=ausgab(6);
if(knot>=27.5 && knot<33.5) form.bea.value=ausgab(7);
if(knot>=33.5 && knot<40.5) form.bea.value=ausgab(8);
if(knot>=40.5 && knot<47.5) form.bea.value=ausgab(9);
if(knot>=47.5 && knot<55.5) form.bea.value=ausgab(10);
if(knot>=55.5 && knot<63.5) form.bea.value=ausgab(11);
if(knot>=63.5 && knot<74.5) form.bea.value=ausgab(12);
if(knot>=74.5 && knot<80.5) form.bea.value=ausgab(13);
if(knot>=80.5 && knot<89.5) form.bea.value=ausgab(14);
if(knot>=89.5) form.bea.value=ausgab(15);
return;
}
function chilinvers(form,chill)   // calculates windspeed fromchill temperature
{
    var t=parseFloat(form.temp.value);     // T in C ?
    var a=(chill-33.) * 22.04 / (t-33) - 10.45;
    if(a>25.) {warnings(1); return;}
    var v = Math.sqrt(25.-a) - 5.;
    return v*v;
}
	
