
function FensterOeffnen (Adresse) {
  MeinFenster = window.open(Adresse, "Zweitfenster", "width=800,height="+screen.availHeight+",left=1,top=1,status=1,toolbar=no, menubar=1, location=no, scrollbars=yes");
  MeinFenster.focus();
}


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)
{
 if (betrag < 0) 
   {
   betrag = 0 - betrag;
   document.form.eingabe.value= betrag;
   }
   
 ergebnis(betrag);
}

function ergebnis(wert)
{
 wertMonatGrundgebuehr=8.95;
 SHOWwertMonatGrundgebuehr ="¤" + runden(wertMonatGrundgebuehr,-2);
 SHOWwertMonatGrundgebuehr = SHOWwertMonatGrundgebuehr.replace(".",",");
 
 wertMonatArbeitspreis=Math.floor((wert*0.2419/12)*100)/100;
 SHOWwertMonatArbeitspreis ="¤ " + runden(wertMonatArbeitspreis,-2);
 SHOWwertMonatArbeitspreis = SHOWwertMonatArbeitspreis.replace(".",",");
 
 wertMonatGesamtpreis= wertMonatGrundgebuehr + wertMonatArbeitspreis;
 SHOWwertMonatGesamtpreis =runden(wertMonatGesamtpreis,-2) ;
 SHOWwertMonatGesamtpreis = SHOWwertMonatGesamtpreis.replace(".",",");
 
 
 wertJahrGrundgebuehr=107.40;
 SHOWwertJahrGrundgebuehr =runden(wertJahrGrundgebuehr,-2) + " ¤ ";
 SHOWwertJahrGrundgebuehr = SHOWwertJahrGrundgebuehr.replace(".",",");
 
 wertJahrArbeitspreis=Math.floor((wert*0.2419)*100)/100;
 SHOWwertJahrArbeitspreis =runden(wertJahrArbeitspreis,-2) + " ¤ ";
 SHOWwertJahrArbeitspreis = SHOWwertJahrArbeitspreis.replace(".",",");
 
 wertJahrGesamtpreis=wertJahrGrundgebuehr + wertJahrArbeitspreis;
 SHOWwertJahrGesamtpreis = runden(wertJahrGesamtpreis,-2) ;
 SHOWwertJahrGesamtpreis = SHOWwertJahrGesamtpreis.replace(".",",");
 
 SHOWwertCO2 =" "+runden((wert*508/1000),0);
 SHOWwertCO2 = SHOWwertCO2.replace(".",",");
 
 SHOWatom = " "+runden((wert*0.7),0);
 SHOWatom = SHOWatom.replace(".",",");

// Bonus
// Preis / Jahr
 SHOWwertJahrGrundgebuehr = SHOWwertJahrGesamtpreis;
  // Bonusfeld
 SHOWwertJahrArbeitspreis = runden(50,-2);
 SHOWwertJahrArbeitspreis = SHOWwertJahrArbeitspreis.replace(".",",");
  // eur / Jahr

 SHOWwertJahrGesamtpreis = runden(wertJahrGesamtpreis,-2);
 SHOWwertJahrGesamtpreis = SHOWwertJahrGesamtpreis.replace(".",",");
  // eur / monat

 SHOWwertMonatGesamtpreis =runden(wertMonatGesamtpreis,-2) ;
 SHOWwertMonatGesamtpreis = SHOWwertMonatGesamtpreis.replace(".",",");
// ENde bonus
  
   
 //document.form.MonatGrundgebuehr.value=SHOWwertMonatGrundgebuehr;  
 //document.form.MonatArbeitspreis.value=SHOWwertMonatArbeitspreis;  
 document.form.MonatGesamtpreis.value=SHOWwertMonatGesamtpreis;  

 //document.form.JahrGrundgebuehr.value=SHOWwertJahrGrundgebuehr;  
 //document.form.JahrArbeitspreis.value=SHOWwertJahrArbeitspreis;  
 document.form.JahrGesamtpreis.value=SHOWwertJahrGesamtpreis; 
 document.form.CO2.value=SHOWwertCO2;
 document.form.atom.value = SHOWatom;
/*
// document.form.Link1.value ='Test.php';
if (wert <= 100000) {
 document.getElementById("Link1").href = "wechsel-zu-lichtblick-oekostrom.php";
 //document.getElementById("Link2").href = "wechsel-zu-lichtblick-oekostrom.php";
 } 
 else
 {
 document.getElementById("Link1").href = "gewerbe-schuetzt-klima-und-umwelt.php";
 //document.getElementById("Link2").href = "gewerbe-schuetzt-klima-und-umwelt.php";
 }
*/
 
 Bilon();
}

function single()
 {
 document.form.eingabe.value="1700"; 
 ergebnis(1700);
 Bilon;
 }

function zweipersonen()
 {
 document.form.eingabe.value="2600";  
 ergebnis(2600);
 }
 
function dreipersonen()
 {
 document.form.eingabe.value="3300";  
 ergebnis(3300);
 }

function vierpersonen()
 {
 document.form.eingabe.value="4100";  
 ergebnis(4100);
 }
 
function Bilon () {
  if (document.getElementById)
    //document.getElementById("Bilanz").style.visibility = "visible";
	document.getElementById('Bilanz').style.display='';
}

function Biloff () {
  if (document.getElementById)
    //document.getElementById("Bilanz").style.visibility = "hidden";
	document.getElementById('Bilanz').style.display='';
}

function toggle_visible (id) {
        var el=$(id);
        if (el.style.display == "none") {;
                el.style.display="block";
        } else {
                el.style.display="none";
        }
}
 
//-->


