function goldenerschnitt(obj) // Hauptfunktion
{
 // Eingaben
 var phi = 1.618033989;
 var tmp = parseFloat(obj.value.replace(/\,/g, "."));
 var nk = parseInt(obj.form.nk.value);
 if (isNaN(tmp) || tmp=="")
  document.getElementById("fehler_goldenerschnitt").innerHTML = "Geben Sie bitte eine Zahl ein!";
 else
 { 
  document.getElementById("fehler_goldenerschnitt").innerHTML = "";
  // Berechnung und Ausgabe
  switch(obj.name)
  {
   case "a":
    obj.form.a.value = trim5(tmp, nk);
    obj.form.b.value = trim5(tmp / phi, nk);			
    obj.form.c.value = trim5(tmp + tmp / phi, nk);
    break;
   case "b":
    obj.form.a.value = trim5(tmp * phi, nk);
    obj.form.b.value = trim5(tmp, nk);	
    obj.form.c.value = trim5(tmp + tmp * phi, nk);
    break;
   case "c":
    obj.form.a.value = trim5(tmp / phi, nk);	
    obj.form.b.value = trim5(tmp / phi / phi, nk);
    obj.form.c.value = trim5(tmp, nk);
    break;
  }
 }
}



function trim5(we, ank) // Runden
{
 var ha	= eval(we);
 var vo	= Math.floor(ha);
 var na	= ha - vo;
 var fa	= Math.pow(10, ank);
 return(vo + (Math.round(na * fa) / fa));
}



function loesch5() // Löschen
{
document.getElementById("fehler_goldenerschnitt").innerHTML = "";
}
