<!--
// FP = Fahrzeugpreis
// JKL = Jahreskilometerleistung
// ENTF = Entfernung Wohnung / Arbeitsplatz
// AP = Anteil Privatnutzung
// LK = Laufende Kosten
// STVER = Steuer und Versicherung / Jahr
// RI = Reperatur / Instandsetzung
function calculate(FP,LR,JKL,ENTF,AP,LK,STVER,RI) {
	setfield("PBEST", FP*0.12);
	setfield("GVORT", FP*0.0003*ENTF*12);
	var WKOST;
	if ( ENTF > 10 ) {
		WKOST = 10 * 0.36;
		WKOST = (WKOST+(ENTF-10)*0.40)*180;
	} else {
		WKOST = ENTF * 0.36 * 180;
	}
	var AWKOS=WKOST;
	if ( WKOST > 5112 ) {
		WKOST = 5112;
	}	
	setfield("WKOST", WKOST);
	var ESTEU = FP*0.12+FP*0.0003*ENTF*12-WKOST;
	var ESTEUNEU = FP*0.12*1.5+FP*0.0003*ENTF*12-WKOST;
	setfield("ESTEU", ESTEU);
	var LRJ = LR*12;
	setfield("LRJ", LRJ);
	setfield("GKOST", STVER*1+LK*1+RI*1);
	var summe = LRJ+STVER*1+LK*1+RI*1;
	setfield("SUMME", summe);
	var APFB = summe*AP/100;
	setfield("APFB", APFB);
	var apafb = summe/JKL*ENTF*180;
	setfield("APAFB", apafb);
	setfield("AWKOS", AWKOS);
	var VSTEU = APFB+apafb-AWKOS;
	setfield("VSTEU", VSTEU);
	var DIFF = ESTEU-VSTEU;
	var DIFFNEU = ESTEUNEU-VSTEU;
	setfield("DIFF", DIFF);
	var DIFF6 = DIFF*6;
	var DIFFNEU6 = DIFFNEU*6;
	setfield("DIFF6", DIFF6);
	result_window(ESTEU,ESTEUNEU,VSTEU,DIFF,DIFF6,DIFFNEU,DIFFNEU6);
} 
function result_window(ESTEU,ESTEUNEU,VSTEU,DIFF,DIFF6,DIFFNEU,DIFFNEU6)
{
	var win;
	ESTEU=Math.round(ESTEU*100)/100;
	ESTEUNEU=Math.round(ESTEUNEU*100)/100;
	VSTEU=Math.round(VSTEU*100)/100;
	DIFF=Math.round(DIFF*100)/100;
	DIFF6=Math.round(DIFF6*100)/100;
	DIFFNEU=Math.round(DIFFNEU*100)/100;
	DIFFNEU6=Math.round(DIFFNEU6*100)/100;
	var MaxVal=0;
	if ( ESTEU > MaxVal ) {
		MaxVal = ESTEU;
	}	
	
	if ( ESTEUNEU > MaxVal ) {
		MaxVal = ESTEUNEU;
	}
	
	if ( VSTEU > MaxVal ) {
		MaxVal = VSTEU;
	}	
	var Height = 150;	
	var ESTEUChart=ESTEU/MaxVal*Height;
	var ESTEUNEUChart=ESTEUNEU/MaxVal*Height;
	var VSTEUChart=VSTEU/MaxVal*Height;
	ESTEUChart=Math.round(ESTEUChart);
	ESTEUNEUChart=Math.round(ESTEUNEUChart);
	VSTEUChart=Math.round(VSTEUChart);
	win=window.open("","Ergebnis","width=620,height=550,resizable=yes,scrollbars=no");
	win.document.open("text/html");
win.document.write("<html>");
win.document.write("<head>");
win.document.write("<title>Ergebnis</title>");
win.document.write("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>");
win.document.write("<link rel=stylesheet type='text/css' href='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_common/format.css'>");
win.document.write("</head>");
win.document.write("");
win.document.write("<body bgcolor='#FFFFFF'>");
win.document.write("<center>");
win.document.write("  <table width='600' border='2' cellspacing='0' cellpadding='0' bordercolor='#CCCCCC' bordercolorlight='#CCCCCC' bordercolordark='#CCCCCC'>");
win.document.write("    <tr> ");
win.document.write("      <td colspan='2'> ");
win.document.write("        <table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#CCCCCC'>");
win.document.write("          <tr> ");
win.document.write("            <td width='80'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/button/statement-grey.gif' width='68' height='68'></td>");
win.document.write("            <td> ");
win.document.write("              <h1>ERGEBNIS</h1>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("        </table>");
win.document.write("        <table width='100%' border='0' cellspacing='10' cellpadding='0'>");
win.document.write("          <tr valign='bottom'> ");
win.document.write("            <td width='33%' valign='bottom'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/red.gif' width='32' height='");
win.document.write(ESTEUChart);
win.document.write("'></td>");
win.document.write("            <td width='33%' valign='bottom'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/red.gif' width='32' height='");
win.document.write(ESTEUNEUChart);
win.document.write("'></td>");
win.document.write("            <td width='33%' valign='bottom'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/green.gif' width='32' height='");
win.document.write(VSTEUChart);
win.document.write("'></td>");
win.document.write("          </tr>");
win.document.write("          <tr valign='top'> ");
win.document.write("            <td height='13' width='33%'> ");
win.document.write("              <div align='right'> ");
win.document.write("                <p class='left'><b>Pauschalversteuerung</b></p>");
win.document.write("                <p class='left'>(auf 1%-Basis)</p>");
win.document.write("              </div>");
win.document.write("            </td>");
win.document.write("            <td height='13' width='33%'> ");
win.document.write("              <p class='left'><b>Pauschalversteuerung<br>");
win.document.write("                </b>(auf 1,5 %-Basis)</p>");
win.document.write("            </td>");
win.document.write("            <td height='13' width='33%'> ");
win.document.write("              <p class='left'><b>Fahrtenbuchvariante</b></p>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("        </table>");
win.document.write("        <table border='0' cellspacing='0' cellpadding='5' width='100%'>");
win.document.write("          <tr> ");
win.document.write("            <td colspan='3' bgcolor='#CCCCCC'> ");
win.document.write("              <table width='100%' border='0' cellspacing='0' cellpadding='5'>");
win.document.write("                <tr> ");
win.document.write("                  <td width='40'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/button/link-grey.gif' width='30' height='24'></td>");
win.document.write("                  <td> ");
win.document.write("                    <h2>Pauschalversteuerung</h2>");
win.document.write("                  </td>");
win.document.write("                </tr>");
win.document.write("              </table>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("          <tr> ");
win.document.write("            <td bgcolor='#EEEEEE'> ");
win.document.write("              <p class='left'><b>Zu versteuerndes Einkommen</b> (pro Jahr, auf ");
win.document.write("                1%-Basis) </p>");
win.document.write("            </td>");
win.document.write("            <td align='right' width='100' bgcolor='#EEEEEE'> ");
win.document.write("              <p class='right'><b>");
win.document.write(ESTEU);
win.document.write("</b></p>");
win.document.write("            </td>");
win.document.write("            <td bgcolor='#EEEEEE' width='30'> ");
win.document.write("              <p class='left'>&euro;</p>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("          <tr> ");
win.document.write("            <td bgcolor='#CCCCCC'> ");
win.document.write("              <p class='left'><b>Zu versteuerndes Einkommen</b> (pro Jahr, auf ");
win.document.write("                1,5%-Basis)</p>");
win.document.write("            </td>");
win.document.write("            <td align='right' width='100' bgcolor='#CCCCCC'> ");
win.document.write("              <p class='right'><b>");
win.document.write(ESTEUNEU);
win.document.write("</b></p>");
win.document.write("            </td>");
win.document.write("            <td width='30' bgcolor='#CCCCCC'> ");
win.document.write("              <p class='left'>&euro;</p>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("          <tr> ");
win.document.write("            <td colspan='3'>&nbsp; </td>");
win.document.write("          </tr>");
win.document.write("        </table>");
win.document.write("        <table border='0' cellspacing='0' cellpadding='5' width='100%'>");
win.document.write("          <tr bgcolor='#CCCCCC'> ");
win.document.write("            <td colspan='3'> ");
win.document.write("              <table width='100%' border='0' cellspacing='0' cellpadding='5'>");
win.document.write("                <tr> ");
win.document.write("                  <td width='40'><img src='http://www.ermittlungenallerart.de/fileadmin/rechner-leasing/_images/button/link-grey.gif' width='30' height='24'></td>");
win.document.write("                  <td> ");
win.document.write("                    <h2><font color='#008800'>Fahrtenbuchmethode</font></h2>");
win.document.write("                  </td>");
win.document.write("                </tr>");
win.document.write("              </table>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("          <tr> ");
win.document.write("            <td bgcolor='#EEEEEE'> ");
win.document.write("              <p class='left'><b>Zu versteuerndes Einkommen</b> (pro Jahr)</p>");
win.document.write("            </td>");
win.document.write("            <td align='right' bgcolor='#EEEEEE' width='100'> ");
win.document.write("                <p class='right'><b>");
win.document.write(VSTEU);
win.document.write("</b> </p>");
win.document.write("            </td>");
win.document.write("            <td bgcolor='#EEEEEE' width='30'> ");
win.document.write("              <p class='left'>&euro;</p>");
win.document.write("            </td>");
win.document.write("          </tr>");
win.document.write("        </table>");
win.document.write("      </td>");
win.document.write("    </tr>");
win.document.write("  </table>");
win.document.write("  <br>");
win.document.write("</center>");
win.document.write("</body>");
win.document.write("</html>");
}
function setfield(field, value ) {
	value=Math.round(value*100)/100;
	eval("document.calc."+field+".value=value;");
}
// -->