function output_cc_toc()
{
var html='';

html=html+'<div class="toc_list">';
html=html+'<span class="title">'+calcCCConfig['definitions_headline_toc']+'</span><ul>';
html=html+'<li>'+calcCCConfig['definitions_cc_payment_toc']+'</li>';
html=html+'<li>'+calcCCConfig['definitions_cc_term_toc']+'</li>';
html=html+'</ul>';
html=html+'</div>';

return html;
}

/* BEGIN GENERAL LOAN PAYMENT */
function cc_payment(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="cc_payment" id="cc_payment" value="1" />';
html=html+calcCCConfig['definitions_cc_amount_formfield'];
if(isDownPayment)
{
html=html+calcCCConfig['definitions_cc_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="cc_down" id="cc_down" value="0" />';
}
html=html+calcCCConfig['definitions_cc_term_formfield'];
html=html+calcCCConfig['definitions_cc_rate_formfield'];
html=html+calcCCConfig['definitions_cc_payment_calculate']+'</form>';

html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function cc_payment_calculate()
{
cc_validate();

if(ccRate==0)
{
ccPayment=ccAmount/ccTerm;
}
else
{
ccPayment=(ccRate+(ccRate/(Math.pow((1+ccRate),(ccTerm))-1)))*ccAmount;
}
ccPayment = ccPayment*100;ccPayment=Math.round(ccPayment);ccPayment=ccPayment/100;


if(isNaN(ccPayment) || ccPayment==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcCCConfig['definitions_cc_payment_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Payment: </span><strong>$'+ccPayment+'</strong><em> per month</em>';
}
}
/* END GENERAL LOAN PAYMENT */

/* BEGIN GENERAL LOAN AMOUNT */
function cc_amount(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="cc_down" id="cc_down" value="0" /><input type="hidden" name="cc_amount" id="cc_amount" value="1" />';
if(isDownPayment)
{
html=html+calcCCConfig['definitions_cc_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="cc_down" id="cc_down" value="0" />';
}
html=html+calcCCConfig['definitions_cc_payment_formfield'];
html=html+calcCCConfig['definitions_cc_term_formfield'];
html=html+calcCCConfig['definitions_cc_rate_formfield'];
html=html+calcCCConfig['definitions_cc_amount_calculate']+'</form>';
html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function cc_amount_calculate()
{
cc_validate();

if(ccRate==0)
{
ccAmount=ccTerm*ccPayment;
}
else
{
ccAmount = ccPayment/(ccRate+(ccRate/(Math.pow((1+ccRate),(ccTerm))-1)));
}
ccAmount = ccAmount*100;ccAmount=Math.round(ccAmount);ccAmount=ccAmount/100;


if(isNaN(ccAmount) || ccAmount==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcCCConfig['definitions_cc_amount_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Amount: </span><strong>$'+ccAmount+'</strong>';
}
}
/* END GENERAL LOAN AMOUNT */

/* BEGIN GENERAL LOAN TERM */
function cc_term(formTitle,isDownPayment)
{
var html='';

html=html+'<form action="#"><strong class="title">'+formTitle+'</strong><input type="hidden" name="cc_term" id="cc_term" value="1" />';
html=html+calcCCConfig['definitions_cc_amount_formfield'];

if(isDownPayment)
{
html=html+calcCCConfig['definitions_cc_down_formfield'];
}
else
{
html=html+'<input type="hidden" name="cc_down" id="cc_down" value="0" />';
}
html=html+calcCCConfig['definitions_cc_payment_formfield'];
html=html+calcCCConfig['definitions_cc_rate_formfield'];
html=html+calcCCConfig['definitions_cc_term_calculate']+'</form>';

html=html+'<div id="calc_answer"></div>';

var object=document.getElementById("calc_content");
object.innerHTML=html;
}

function cc_term_calculate()
{
cc_validate();


if(ccRate==0)
{
ccTerm=ccAmount/ccPayment;
}
else
{
ccTerm=(Math.log(1+(ccRate/(ccPayment/(ccAmount)-ccRate)))/Math.log(1+ccRate));
}
//ccTerm=ccTerm*1000;
ccTerm=Math.round(ccTerm);
//ccTerm=ccTerm/1000;

if(isNaN(ccTerm) || ccTerm==Infinity){
document.getElementById("calc_answer").innerHTML='<div class="error">'+calcCCConfig['definitions_cc_term_error']+'</div>'
}
else
{
document.getElementById("calc_answer").innerHTML='<span>Term: </span><strong>'+ccTerm+' months</strong>';
}
}
/* END GENERAL LOAN TERM */

function cc_validate(){
ccAmount = document.getElementById('cc_amount').value;
ccDown = document.getElementById('cc_down').value;
ccTerm = document.getElementById('cc_term').value;
ccRate = document.getElementById('cc_rate').value;
ccPayment = document.getElementById('cc_payment').value;
if(isNaN(Number(ccAmount)) || isNaN(Number(ccDown)) || isNaN(Number(ccTerm)) || isNaN(Number(ccRate)) || isNaN(Number(ccPayment))){ document.getElementById("calc_answer").innerHTML='<div class="error"><strong>Invalid Entry - Please check your numbers.</strong></div>'; return 0; }

if(ccRate!=0){ccRate=ccRate/1200;}


ccAmount=ccAmount-ccDown;
if(ccAmount<=0 || ccDown<0 || ccTerm<=0 || ccPayment<=0 || ccRate<0 || ccRate>=1){ document.getElementById("calc_answer").innerHTML='<div class="error">'+calcCCConfig['definitions_cc_generic_error']+'</div>'; return 0; }
return 0;
}


