function Trim(Zahl,Maxkomma)
{
 var Numzahl = eval(Zahl);
 var Vorkomma = Math.floor(Numzahl);
 var Nachkomma = Numzahl - Vorkomma;
 var Potenz = Math.pow(10,Maxkomma);
 Nachkomma = Math.round(Nachkomma * Potenz);
 var Ergebnis = Vorkomma + (Nachkomma / Potenz);
 return(Ergebnis);
}
function SucheErsetze(Text,Suche,Ersetze)
{
 var Neutext = "";
 var i = 0;
 while(i < Text.length)
  {
   if(Text.substring(i,i + Suche.length) == Suche)
    {
     Neutext = Neutext + Ersetze;
     i = i + Suche.length - 1;
    }
   else
    Neutext = Neutext + Text.substring(i,i + 1);
   i++;
  }
 return Neutext;
}
function Ergebnis()
{
var i=0, beam=0, bandwidth = 0, velocity=0, spots=0, frequence=0, access=0;
var tbeam = "", tbandwidth = "", tvelocity = ""; 
if(document.Acousto.beam.value != "") { i+=1; } 
if(document.Acousto.bandwidth.value != "") { i+=1; } 
if(document.Acousto.velocity.value != "") { i+=1; }
if(i <3)
 {
  alert("Please input all three start values:\n Beam dia., Bandwidth and Sound velocity");
  return;
 } 
 {
  tbeam = SucheErsetze(document.Acousto.beam.value,",",".");
  tbandwidth = SucheErsetze(document.Acousto.bandwidth.value,",",".");
  tvelocity = SucheErsetze(document.Acousto.velocity.value,",",".");
  spots = tbeam * tbandwidth * 1000 / tvelocity;
  frequence = tvelocity / (tbeam * 1000);
  access = tbeam * 1000/tvelocity;
 }
 document.Acousto.spots.value = Trim(spots,2);
document.Acousto.frequence.value = Trim(frequence,2);
document.Acousto.access.value = Trim(access,2);
} 