function rechnen (lPara){
var lBasisMaterial;

    lBasisMaterial=document.eln.BasisMaterial.value;
    
    if (document.eln.Keller.checked==true)
    {
        lKeller=1;
    } 
    else
    {
        lKeller=0;
    }
    
    if (lKeller==0)
    {
    lKrBasis=0.89;
    lKrErd=0;
    lKrBodenplatte=1.57;
    lKrKrabd=0;
    lKrDrain=0;
    lKrHzg=1.3;
    lKrSani=1.3;
    lKrEl=1.04;
    lKrIp=1.3;
    lKrEstr=0.91;
    lKrTepp=1.3;
    lKrBdflies=1.3;
    lKrItuer=0.98;
    lKrTrp=0.65;
    lKrTap=1.3;
    lKrDckgips=1.3;
    lKrSaniobj=1.3;
    lKrAp=1.17;
    lKrVersch=1.3;
    
    lBasisMaterialAnteil=30.54;
    lBasisLohnAnteil=15.68;
    
    
    }
    else
    {
    lKrBasis=1;
    lKrErd=1;
    lKrBodenplatte=1;
    lKrKrabd=1;
    lKrDrain=1;
    lKrHzg=1;
    lKrSani=1;
    lKrEl=1;
    lKrIp=1;
    lKrEstr=1;
    lKrTepp=1;
    lKrBdflies=1;
    lKrItuer=1;
    lKrTrp=1;
    lKrTap=1;
    lKrDckgips=1;
    lKrSaniobj=1;
    lKrAp=1;
    lKrVersch=1;
    
    lBasisMaterialAnteil=33.54;
    lBasisLohnAnteil=18.26;
    }
    
    lMaterialFaktor=lBasisMaterial/lBasisMaterialAnteil;

    lBasisLohn=lMaterialFaktor*lBasisLohnAnteil;
    
    lLohnFaktor=lBasisLohn/lBasisLohnAnteil;


    
    lErdMaterialAnteil=2.1*lKrErd;
    lBodenplatteMaterialAnteil=3.66*lKrBodenplatte;
    lKrabdMaterialAnteil=0.75*lKrKrabd;
    lDrainMaterialAnteil=0.72*lKrDrain;
    lHzgMaterialAnteil=4.125*lKrHzg;
    lSaniMaterialAnteil=1.26*lKrSani;
    lElMaterialAnteil=1.44*lKrEl;
    lIpMaterialAnteil=0.75*lKrIp;
    lEstrMaterialAnteil=1.785*lKrEstr;
    lTeppMaterialAnteil=0.975*lKrTepp;
    lBdfliesMaterialAnteil=1.35*lKrBdflies;
    lItuerMaterialAnteil=1.35*lKrItuer;
    lTrpMaterialAnteil=2.1*lKrTrp;
    lTapMaterialAnteil=0.84*lKrTap;
    lDckgipsMaterialAnteil=0.84*lKrDckgips;
    lSaniobjMaterialAnteil=1.8*lKrSaniobj;
    lApMaterialAnteil=0.66*lKrAp;
    lVerschMaterialAnteil=2.4*lKrVersch;
    
    lErdLohnAnteil=0*lKrErd;
    lBodenplatteLohnAnteil=2.44*lKrBodenplatte;
    lKrabdLohnAnteil=0.75*lKrKrabd;
    lDrainLohnAnteil=0.48*lKrDrain;
    lHzgLohnAnteil=1.375*lKrHzg;
    lSaniLohnAnteil=0.84*lKrSani;
    lElLohnAnteil=0.96*lKrEl;
    lIpLohnAnteil=2.25*lKrIp;
    lEstrLohnAnteil=0.315*lKrEstr;
    lTeppLohnAnteil=0.525*lKrTepp;
    lBdfliesLohnAnteil=1.35*lKrBdflies;
    lItuerLohnAnteil=0.45*lKrItuer;
    lTrpLohnAnteil=0.9*lKrTrp;
    lTapLohnAnteil=1.26*lKrTap;
    lDckgipsLohnAnteil=1.56*lKrDckgips;
    lSaniobjLohnAnteil=1.2*lKrSaniobj;
    lApLohnAnteil=2.64*lKrAp;
    lVerschLohnAnteil=0;

    lSonstMaterialAnteil=lErdMaterialAnteil+lBodenplatteMaterialAnteil+lKrabdMaterialAnteil+lDrainMaterialAnteil+lHzgMaterialAnteil+lSaniMaterialAnteil+lElMaterialAnteil+lIpMaterialAnteil+lEstrMaterialAnteil+lTeppMaterialAnteil+lBdfliesMaterialAnteil+lItuerMaterialAnteil+lTrpMaterialAnteil+lTapMaterialAnteil+lDckgipsMaterialAnteil+lSaniobjMaterialAnteil+lApMaterialAnteil+lVerschMaterialAnteil;
    lSonstLohnAnteil=lErdLohnAnteil+lBodenplatteLohnAnteil+lKrabdLohnAnteil+lDrainLohnAnteil+lHzgLohnAnteil+lSaniLohnAnteil+lElLohnAnteil+lIpLohnAnteil+lEstrLohnAnteil+lTeppLohnAnteil+lBdfliesLohnAnteil+lItuerLohnAnteil+lTrpLohnAnteil+lTapLohnAnteil+lDckgipsLohnAnteil+lSaniobjLohnAnteil+lApLohnAnteil+lVerschLohnAnteil;

    lErdMaterial=lMaterialFaktor*lErdMaterialAnteil;
    lBodenplatteMaterial=lMaterialFaktor*lBodenplatteMaterialAnteil;
    lKrabdMaterial=lMaterialFaktor*lKrabdMaterialAnteil;
    lDrainMaterial=lMaterialFaktor*lDrainMaterialAnteil;
    lHzgMaterial=lMaterialFaktor*lHzgMaterialAnteil;
    lSaniMaterial=lMaterialFaktor*lSaniMaterialAnteil;
    lElMaterial=lMaterialFaktor*lElMaterialAnteil;
    lIpMaterial=lMaterialFaktor*lIpMaterialAnteil;
    lEstrMaterial=lMaterialFaktor*lEstrMaterialAnteil;
    lTeppMaterial=lMaterialFaktor*lTeppMaterialAnteil;
    lBdfliesMaterial=lMaterialFaktor*lBdfliesMaterialAnteil;
    lItuerMaterial=lMaterialFaktor*lItuerMaterialAnteil;
    lTrpMaterial=lMaterialFaktor*lTrpMaterialAnteil;
    lTapMaterial=lMaterialFaktor*lTapMaterialAnteil;
    lDckgipsMaterial=lMaterialFaktor*lDckgipsMaterialAnteil;
    lSaniobjMaterial=lMaterialFaktor*lSaniobjMaterialAnteil;
    lApMaterial=lMaterialFaktor*lApMaterialAnteil;
    lVerschMaterial=lMaterialFaktor*lVerschMaterialAnteil;
    lSonstMaterial=lMaterialFaktor*lSonstMaterialAnteil;
 
    lErdLohn=lLohnFaktor*lErdLohnAnteil;
    lBodenplatteLohn=lLohnFaktor*lBodenplatteLohnAnteil;
    lKrabdLohn=lLohnFaktor*lKrabdLohnAnteil;
    lDrainLohn=lLohnFaktor*lDrainLohnAnteil;
    lHzgLohn=lLohnFaktor*lHzgLohnAnteil;
    lSaniLohn=lLohnFaktor*lSaniLohnAnteil;
    lElLohn=lLohnFaktor*lElLohnAnteil;
    lIpLohn=lLohnFaktor*lIpLohnAnteil;
    lEstrLohn=lLohnFaktor*lEstrLohnAnteil;
    lTeppLohn=lLohnFaktor*lTeppLohnAnteil;
    lBdfliesLohn=lLohnFaktor*lBdfliesLohnAnteil;
    lItuerLohn=lLohnFaktor*lItuerLohnAnteil;
    lTrpLohn=lLohnFaktor*lTrpLohnAnteil;
    lTapLohn=lLohnFaktor*lTapLohnAnteil;
    lDckgipsLohn=lLohnFaktor*lDckgipsLohnAnteil;
    lSaniobjLohn=lLohnFaktor*lSaniobjLohnAnteil;
    lApLohn=lLohnFaktor*lApLohnAnteil;
    lVerschLohn=lLohnFaktor*lVerschLohnAnteil;
    lSonstLohn=lMaterialFaktor*lSonstLohnAnteil;
 

    document.eln.ErdMaterial.value=runden(lErdMaterial);
    document.eln.BodenplatteMaterial.value=runden(lBodenplatteMaterial);
    document.eln.KrabdMaterial.value=runden(lKrabdMaterial);
    document.eln.DrainMaterial.value=runden(lDrainMaterial);
    document.eln.HzgMaterial.value=runden(lHzgMaterial);
    document.eln.SaniMaterial.value=runden(lSaniMaterial);
    document.eln.ElMaterial.value=runden(lElMaterial);
    document.eln.IpMaterial.value=runden(lIpMaterial);
    document.eln.EstrMaterial.value=runden(lEstrMaterial);
    document.eln.TeppMaterial.value=runden(lTeppMaterial);
    document.eln.BdfliesMaterial.value=runden(lBdfliesMaterial);
    document.eln.ItuerMaterial.value=runden(lItuerMaterial);
    document.eln.TrpMaterial.value=runden(lTrpMaterial);
    document.eln.TapMaterial.value=runden(lTapMaterial);
    document.eln.DckgipsMaterial.value=runden(lDckgipsMaterial);
    document.eln.SaniobjMaterial.value=runden(lSaniobjMaterial);
    document.eln.ApMaterial.value=runden(lApMaterial);
    document.eln.VerschMaterial.value=runden(lVerschMaterial);
    document.eln.SonstMaterial.value=runden(lSonstMaterial);

    document.eln.ErdLohn.value=runden(lErdLohn);
    document.eln.BodenplatteLohn.value=runden(lBodenplatteLohn);
    document.eln.KrabdLohn.value=runden(lKrabdLohn);
    document.eln.DrainLohn.value=runden(lDrainLohn);
    document.eln.HzgLohn.value=runden(lHzgLohn);
    document.eln.SaniLohn.value=runden(lSaniLohn);
    document.eln.ElLohn.value=runden(lElLohn);
    document.eln.IpLohn.value=runden(lIpLohn);
    document.eln.EstrLohn.value=runden(lEstrLohn);
    document.eln.TeppLohn.value=runden(lTeppLohn);
    document.eln.BdfliesLohn.value=runden(lBdfliesLohn);
    document.eln.ItuerLohn.value=runden(lItuerLohn);
    document.eln.TrpLohn.value=runden(lTrpLohn);
    document.eln.TapLohn.value=runden(lTapLohn);
    document.eln.DckgipsLohn.value=runden(lDckgipsLohn);
    document.eln.SaniobjLohn.value=runden(lSaniobjLohn);
    document.eln.ApLohn.value=runden(lApLohn);
    document.eln.VerschLohn.value=runden(lVerschLohn);
    document.eln.SonstLohn.value=runden(lSonstLohn);

    document.eln.ErdGesamt.value=runden(lErdLohn)+runden(lErdMaterial);
    document.eln.BodenplatteGesamt.value=runden(lBodenplatteLohn)+runden(lBodenplatteMaterial);
    document.eln.KrabdGesamt.value=runden(lKrabdLohn)+runden(lKrabdMaterial);
    document.eln.DrainGesamt.value=runden(lDrainLohn)+runden(lDrainMaterial);
    document.eln.HzgGesamt.value=runden(lHzgLohn)+runden(lHzgMaterial);
    document.eln.SaniGesamt.value=runden(lSaniLohn)+runden(lSaniMaterial);
    document.eln.ElGesamt.value=runden(lElLohn)+runden(lElMaterial);
    document.eln.IpGesamt.value=runden(lIpLohn)+runden(lIpMaterial);
    document.eln.EstrGesamt.value=runden(lEstrLohn)+runden(lEstrMaterial);
    document.eln.TeppGesamt.value=runden(lTeppLohn)+runden(lTeppMaterial);
    document.eln.BdfliesGesamt.value=runden(lBdfliesLohn)+runden(lBdfliesMaterial);
    document.eln.ItuerGesamt.value=runden(lItuerLohn)+runden(lItuerMaterial);
    document.eln.TrpGesamt.value=runden(lTrpLohn)+runden(lTrpMaterial);
    document.eln.TapGesamt.value=runden(lTapLohn)+runden(lTapMaterial);
    document.eln.DckgipsGesamt.value=runden(lDckgipsLohn)+runden(lDckgipsMaterial);
    document.eln.SaniobjGesamt.value=runden(lSaniobjLohn)+runden(lSaniobjMaterial);
    document.eln.ApGesamt.value=runden(lApLohn)+runden(lApMaterial);
    document.eln.VerschGesamt.value=runden(lVerschLohn)+runden(lVerschMaterial);
    document.eln.SonstGesamt.value=runden(lSonstLohn)+runden(lSonstMaterial);

    document.eln.BasisLohn.value=runden(lBasisLohn);
    document.eln.BasisGesamt.value=runden(lBasisLohn)+runden(lBasisMaterial);

    document.eln.SumLohn.value=runden(lBasisLohn)+runden(lSonstLohn);
    document.eln.SumMaterial.value=runden(lBasisMaterial)+runden(lSonstMaterial);
    document.eln.SumGesamt.value=runden(lBasisLohn)+runden(lSonstLohn)+runden(lBasisMaterial)+runden(lSonstMaterial);

}

function rechnenDirekt(){
	//hauskosten.txtFl.value='';
	//hauskosten.txtVol.value='';
	rechnen();
}

function rechnenChangeKeller(){
    lBasisMaterial=document.eln.BasisMaterial.value;
    if (document.eln.Keller.checked==true)
    {
        lBasisMaterial =   lBasisMaterial * 1.425;
    } 
    else
    {
        lBasisMaterial =   lBasisMaterial / 1.425;
    }
    document.eln.BasisMaterial.value=   runden( lBasisMaterial);
    
    document.eln.BasisMaterial.value=0;
    
    alert("Bitte geben Sie die Materialkosten des geschlossenen Rohbaus ein.")
	rechnen();
}

function rechnenVol(){
	lVol=hauskosten.txtVol.value;
	lVolPreis=hauskosten.txtVolPreis.value;
	lKosten=lVol*lVolPreis;
	lEndpreis=runden(lKosten);
	hauskosten.txtHauskostenSumme.value=lEndpreis;
	document.eln.txtPreis.value=lEndpreis;

	lFlPreis=hauskosten.txtFlPreis.value;
	hauskosten.txtFl.value=runden(lEndpreis/lFlPreis);

	rechnen();
}

function rechnenFl(){
	
	lFlaeche=hauskosten.txtFl.value;
	lFlaechePreis=hauskosten.txtFlPreis.value;
	lFlKosten=lFlaeche*lFlaechePreis;
	lFlEndpreis=runden(lFlKosten);
	hauskosten.txtHauskostenSumme.value=lFlEndpreis;
	eln.txtPreis.value=lFlEndpreis;

	lVolPreis=hauskosten.txtVolPreis.value;
	hauskosten.txtVol.value=runden(lFlEndpreis/lVolPreis);

	rechnen();
}

function rechnenFinanz(){
	finanzierung.txtZins.value="5.0";
	finanzierung.txtTilgung.value="1.0";
	
	lGrundstueck=eval(finanzierung.txtGrundstueck.value);
	lBaukosten=eval(finanzierung.txtBaukosten.value);
	lZwSumme=lGrundstueck + lBaukosten;
	lNebenkosten=lZwSumme*0.06;
	lSumme=lNebenkosten + lZwSumme;

	lZinsTilgung=eval(finanzierung.txtZins.value) + eval(finanzierung.txtTilgung.value);
	
	lBarmittel=eval(finanzierung.txtBarmittel.value);
	lEigenleistung=eln.txtElnSumme.value;
	lKredit=lSumme - lBarmittel - lEigenleistung;

	lRate=lKredit/100*lZinsTilgung/12;

	finanzierung.txtNebenkosten.value=runden(lNebenkosten);
	finanzierung.txtGesamt.value=runden(lSumme);
	finanzierung.txtKredit.value=runden(lKredit);
	finanzierung.txtRate.value=runden(lRate);

	
}

function runden(lWert){
	lWert=Math.round(lWert);
	return lWert;
}
