//<SCRIPT LANGUAGE="JavaScript">
<!--

function runden(zahl,wert)
{

  if (typeof(zahl)=="string")
    if (zahl.indexOf(",")!=-1)
      zahl =  zahl.substring(0,zahl.indexOf(","))+"."
            + zahl.substring(zahl.indexOf(",")+1,zahl.length)


  zahl=Math.round(zahl/Math.pow(10,wert))*Math.pow(10,wert);

  zahl=zahl+"";
  if (zahl.indexOf(".")!=-1)
    if (zahl.length-zahl.indexOf(".")>Math.abs(wert)+1)
      zahl=zahl.substring(0,zahl.indexOf(".")+Math.abs(wert)+1);

  if (wert<0)
   {
    if (zahl.indexOf(".")==-1) zahl=zahl+".";
    if (zahl.indexOf(".")== 0) zahl="0"+zahl;
    while (Math.abs(wert)-(zahl.length-zahl.indexOf("."))>-1)
           zahl=zahl+"0";
   }

  return zahl;
}


function berechne(betrag)
{
 ergebnis(betrag);
}

function ergebnis(wert)
{
 wertMonatGrundgebuehr=8.95;
 SHOWwertMonatGrundgebuehr ="€ " + runden(wertMonatGrundgebuehr,-2);
 SHOWwertMonatGrundgebuehr = SHOWwertMonatGrundgebuehr.replace(".",",");
 
 wertMonatArbeitspreis=Math.floor((wert*0.2199/12)*100)/100;
 SHOWwertMonatArbeitspreis ="€ " + runden(wertMonatArbeitspreis,-2);
 SHOWwertMonatArbeitspreis = SHOWwertMonatArbeitspreis.replace(".",",");
 
 wertMonatGesamtpreis= wertMonatGrundgebuehr + wertMonatArbeitspreis;
 SHOWwertMonatGesamtpreis ="€ " + runden(wertMonatGesamtpreis,-2);
 SHOWwertMonatGesamtpreis = SHOWwertMonatGesamtpreis.replace(".",",");
 
 wertMonatCO2Ersparnis=Math.floor((wert*0.506/12)*100)/100;
 SHOWwertMonatCO2Ersparnis =runden(wertMonatCO2Ersparnis,-2) + " kg";
 SHOWwertMonatCO2Ersparnis = SHOWwertMonatCO2Ersparnis.replace(".",",");
 
 
 wertJahrGrundgebuehr=107.40;
 SHOWwertJahrGrundgebuehr ="€ " + runden(wertJahrGrundgebuehr,-2);
 SHOWwertJahrGrundgebuehr = SHOWwertJahrGrundgebuehr.replace(".",",");
 
 wertJahrArbeitspreis=Math.floor((wert*0.2199)*100)/100;
 SHOWwertJahrArbeitspreis ="€ " + runden(wertJahrArbeitspreis,-2);
 SHOWwertJahrArbeitspreis = SHOWwertJahrArbeitspreis.replace(".",",");
 
 wertJahrGesamtpreis=wertJahrGrundgebuehr + wertJahrArbeitspreis;
 SHOWwertJahrGesamtpreis ="€ " + runden(wertJahrGesamtpreis,-2);
 SHOWwertJahrGesamtpreis = SHOWwertJahrGesamtpreis.replace(".",",");
  
 wertJahrCO2Ersparnis=Math.floor((wert*0.506)*100)/100;
 SHOWwertJahrCO2Ersparnis =runden(wertJahrCO2Ersparnis,-2) + " kg";
 SHOWwertJahrCO2Ersparnis = SHOWwertJahrCO2Ersparnis.replace(".",",");

  
   
 document.form.MonatGrundgebuehr.value=SHOWwertMonatGrundgebuehr;  
 document.form.MonatArbeitspreis.value=SHOWwertMonatArbeitspreis;  
 document.form.MonatGesamtpreis.value=SHOWwertMonatGesamtpreis;  
 document.form.MonatCO2Ersparnis.value=SHOWwertMonatCO2Ersparnis;  

 document.form.JahrGrundgebuehr.value=SHOWwertJahrGrundgebuehr;  
 document.form.JahrArbeitspreis.value=SHOWwertJahrArbeitspreis;  
 document.form.JahrGesamtpreis.value=SHOWwertJahrGesamtpreis; 
 document.form.JahrCO2Ersparnis.value=SHOWwertJahrCO2Ersparnis;  
}

function single()
 {
 document.form.eingabe.value="1500"; 
 ergebnis(1500);
 }

function zweipersonen()
 {
 document.form.eingabe.value="2500";  
 ergebnis(2500);
 }

function vierpersonen()
 {
 document.form.eingabe.value="4000";  
 ergebnis(4000);
 }
 
// -->
//</SCRIPT>
