function output_auto_toc()
{
var html='';

html=html+'<div class="toc_list">';
html=html+'<span class="title">'+calcAutoConfig['definitions_headline_toc']+'</span><ul>';
html=html+'<li>'+calcAutoConfig['definitions_auto_payment_toc']+'</li>';
html=html+'<li>'+calcAutoConfig['definitions_auto_amount_toc']+'</li>';
html=html+'<li>'+calcAutoConfig['definitions_auto_term_toc']+'</li>';
html=html+'</ul>';
html=html+'</div>';

return html;
}

/* BEGIN GENERAL AUTO PAYMENT */
function auto_payment(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="auto_payment" id="auto_payment" value="1" />';
html=html+calcAutoConfig['definitions_auto_amount_formfield'];
if(isDownPayment)
{
html=html+calcAutoConfig['definitions_auto_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="auto_down" id="auto_down" value="0" />';
}
html=html+calcAutoConfig['definitions_auto_term_formfield'];
html=html+calcAutoConfig['definitions_auto_rate_formfield'];
html=html+calcAutoConfig['definitions_auto_payment_calculate']+'</form>';

html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function auto_payment_calculate()
{
auto_validate();

if(autoRate==0)
{
autoPayment=autoAmount/autoTerm;
}
else
{
autoPayment=(autoRate+(autoRate/(Math.pow((1+autoRate),(autoTerm))-1)))*autoAmount;
}
autoPayment = autoPayment*100;autoPayment=Math.round(autoPayment);autoPayment=autoPayment/100;


if(isNaN(autoPayment) || autoPayment==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcAutoConfig['definitions_auto_payment_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Payment: </span><strong>$'+autoPayment+'</strong><em> per month</em>';
}
}
/* END GENERAL AUTO PAYMENT */

/* BEGIN GENERAL AUTO AMOUNT */
function auto_amount(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="auto_down" id="auto_down" value="0" /><input type="hidden" name="auto_amount" id="auto_amount" value="1" />';
if(isDownPayment)
{
html=html+calcAutoConfig['definitions_auto_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="auto_down" id="auto_down" value="0" />';
}
html=html+calcAutoConfig['definitions_auto_payment_formfield'];
html=html+calcAutoConfig['definitions_auto_term_formfield'];
html=html+calcAutoConfig['definitions_auto_rate_formfield'];
html=html+calcAutoConfig['definitions_auto_amount_calculate']+'</form>';
html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function auto_amount_calculate()
{
auto_validate();

if(autoRate==0)
{
autoAmount=autoTerm*autoPayment;
}
else
{
autoAmount = autoPayment/(autoRate+(autoRate/(Math.pow((1+autoRate),(autoTerm))-1)));
}
autoAmount = autoAmount*100;autoAmount=Math.round(autoAmount);autoAmount=autoAmount/100;


if(isNaN(autoAmount) || autoAmount==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcAutoConfig['definitions_auto_amount_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Amount: </span><strong>$'+autoAmount+'</strong>';
}
}
/* END GENERAL AUTO AMOUNT */

/* BEGIN GENERAL AUTO TERM */
function auto_term(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="auto_term" id="auto_term" value="1" />';
html=html+calcAutoConfig['definitions_auto_amount_formfield'];

if(isDownPayment)
{
html=html+calcAutoConfig['definitions_auto_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="auto_down" id="auto_down" value="0" />';
}
html=html+calcAutoConfig['definitions_auto_payment_formfield'];
html=html+calcAutoConfig['definitions_auto_rate_formfield'];
html=html+calcAutoConfig['definitions_auto_term_calculate']+'</form>';

html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function auto_term_calculate()
{
auto_validate();


if(autoRate==0)
{
autoTerm=autoAmount/autoPayment;
}
else
{
autoTerm=(Math.log(1+(autoRate/(autoPayment/(autoAmount)-autoRate)))/Math.log(1+autoRate));
}
autoTerm=Math.round(autoTerm);


if(isNaN(autoTerm) || autoTerm==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcAutoConfig['definitions_auto_term_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Term: </span><strong>'+autoTerm+' months</strong>';
}
}
/* END GENERAL AUTO TERM */

function auto_validate(){
autoAmount = document.getElementById('auto_amount').value;
autoDown = document.getElementById('auto_down').value;
autoTerm = document.getElementById('auto_term').value;
autoRate = document.getElementById('auto_rate').value;
autoPayment = document.getElementById('auto_payment').value;
if(isNaN(Number(autoAmount)) || isNaN(Number(autoDown)) || isNaN(Number(autoTerm)) || isNaN(Number(autoRate)) || isNaN(Number(autoPayment))){ document.getElementById("calc_answer").innerHTML='<div class="error"><strong>Invalid Entry - Please check your numbers.</strong></div>'; return 0; }

if(autoRate!=0){autoRate=autoRate/1200;}


autoAmount=autoAmount-autoDown;
if(autoAmount<=0 || autoDown<0 || autoTerm<=0 || autoPayment<=0 || autoRate<0 || autoRate>=1){ document.getElementById("calc_answer").innerHTML='<div class="error">'+calcAutoConfig['definitions_auto_generic_error']+'</div>'; return 0; }
return 0;
}


