<!--

function ergebnisLoeschen()
{
   document.zinsrechner.endkapital.value='?';
   document.zinsrechner.zinsertrag.value='?';
}

//Darlehensvergleich
var z=1;

zinssatz=new Array();
tilgung=new Array();
sondertilgung=new Array();
monatslast=new Array();
restschuld10=new Array();
restschuld15=new Array();
laufzeit_ende=new Array();
aufwand=new Array();

//--------------------------------------------------------------------------------------------------------

function clear_ergebnis(v)
{

if (v==3)
{

for (v=0;v<=2;v++)
{
document.h3_rechner.monatslast[v].value="";
document.h3_rechner.laufzeit_ende[v].value="";
document.h3_rechner.aufwand[v].value="";
document.h3_rechner.restschuld10[v].value="";
document.h3_rechner.restschuld15[v].value="";
}}
else
{
document.h3_rechner.monatslast[v].value="";
document.h3_rechner.laufzeit_ende[v].value="";
document.h3_rechner.aufwand[v].value="";
document.h3_rechner.restschuld10[v].value="";
document.h3_rechner.restschuld15[v].value="";
}}

//----------------------------------------------------------------------------------------
function auslesen(wert)
{
wert=wert.replace(/,/,".");wert=parseFloat(wert);if (isNaN(wert)) wert=0;
if (wert<0)wert=Math.abs(wert);
return (wert);
}
//--------------------------------------------------------------------------------------------------------


function berechnung()
{

for (v=0;v<=2;v++)
{
var restschuld10=0;
var restschuld15=0;

x=auslesen(document.h3_rechner.darlehen.value);document.h3_rechner.darlehen.value=x;
x=auslesen(document.h3_rechner.zinssatz[v].value);document.h3_rechner.zinssatz[v].value=x;
x=auslesen(document.h3_rechner.tilgung[v].value);document.h3_rechner.tilgung[v].value=x;
x=auslesen(document.h3_rechner.sondertilgung[v].value);document.h3_rechner.sondertilgung[v].value=x;

if(document.h3_rechner.tilgung[v].value <= 0)
{
alert("Tilgungsfreie Darlehen werden mit diesem Hypothekenrechner nicht berechnet!");
document.h3_rechner.tilgung[v].focus();
return;
}

var zinssatz=parseFloat(document.h3_rechner.zinssatz[v].value)/100;if(zinssatz<=0)zinssatz=0.000000001;
var tilgung=parseFloat (document.h3_rechner.tilgung[v].value)/100;
var sondertilgung=parseFloat (document.h3_rechner.sondertilgung[v].value);
var darlehen=parseFloat(document.h3_rechner.darlehen.value); 
var saldo=parseFloat(document.h3_rechner.darlehen.value);
var monatslast=(zinssatz+tilgung)*darlehen/12;

var mz=0,summesondertilgung=0,aufwand=0,laufzeit_ende=0;

var mz=1;
document.h3_rechner.monatslast[v].value=(Math.round(monatslast*100)/100);

for (i=1;i<=1200;i++)
{
	if(i== 1200){alert("Die Daten sind unrealistisch! Überprüfen Sie die Eingaben.");document.h3_rechner.zinssatz[i].focus();return;}
	if (saldo<=0){break;}
	if (mz==12)
	{
	saldo=saldo-sondertilgung;
	summesondertilgung=summesondertilgung+sondertilgung;	
	}
	mz=mz+1;
	if(mz==13)
	{mz=1};
	tilgung=monatslast-saldo*zinssatz/12;
	saldo=saldo-tilgung;
	aufwand=aufwand+monatslast;
	if (saldo<=0){aufwand=aufwand+saldo;saldo=0;}
	laufzeit_ende=i/12;


	if (i==120)restschuld10=saldo;
	if (i==180)restschuld15=saldo;
}

document.h3_rechner.laufzeit_ende[v].value=(Math.floor(laufzeit_ende*10))/10;
document.h3_rechner.aufwand[v].value=Math.round(aufwand+summesondertilgung);
document.h3_rechner.restschuld10[v].value=Math.round(restschuld10);
document.h3_rechner.restschuld15[v].value=Math.round(restschuld15);

}
}

function loeschen(formular){
for (i=0;i<=4; i++ ){
	formular.erg[i].value="";
	//formular.rental_fee.value="";
	//formular.erhoehung.value="";
}
}//end of function

//Hauskostenrechner Überschuss Ermittlung
function check(param){
if (isNaN(param)) param=0;
return param
}//end of function


function calculate_haushaltskosten(form){
form.erg_einahmen.value = check(parseInt(form.nek.value))+check(parseInt(form.nek_par.value))+check()
+check(parseInt(form.kindergeld.value))+check(parseInt(form.selb_eink.value))+check(parseInt(form.miet_ein.value))+check(parseInt(form.renten_ein.value))
+check(parseInt(form.kap_ertr.value))+check(parseInt(form.sonst_eink.value))+check(parseInt(Math.round(form.j_url_geld.value)/12))
+check(parseInt(Math.round(form.j_boni.value)/12));

form.erg_ausgaben.value = check(parseInt(form.wohn_nk.value))+check(parseInt(form.haush.value))+check(parseInt(form.tel.value))+
check(parseInt(form.kleid.value))+check(parseInt(form.gesund.value))+check(parseInt(form.kindergarten.value))+
check(parseInt(form.haust.value))+check(parseInt(form.hobby.value))+check(parseInt(form.kind_unt.value))+
check(parseInt(form.leas_rate.value))+check(parseInt(form.sprit_auto.value))+
check(parseInt(form.darl_immo.value))+check(parseInt(form.rente.value))+
check(parseInt(form.bu.value))+check(parseInt(form.krank.value))+check(parseInt(form.uv.value))+
check(parseInt(form.sons_ver.value))+check(parseInt(form.kredit.value))+check(parseInt(form.sonst_aus.value))+
check(parseInt(Math.round(form.j_moeb.value)/12))+check(parseInt(Math.round(form.j_auto_rep.value)/12))+
check(parseInt(Math.round(form.j_auto_vers.value)/12))+check(parseInt(Math.round(form.j_auto_st.value)/12))+
check(parseInt(Math.round(form.j_urlaub.value)/12))+check(parseInt(Math.round(form.j_feste.value)/12))+
check(parseInt(Math.round(form.j_geschenke.value)/12))+check(parseInt(Math.round(form.j_instand.value)/12));

form.erg_frei_verfuegbar.value = form.erg_einahmen.value-form.erg_ausgaben.value;

form.erg_reserve.value = check(parseInt(form.reserve.value));

form.erg_gesamt.value = form.erg_frei_verfuegbar.value - form.erg_reserve.value;
}//end of function


// -->
