function formatCurrency(num)
{
        num = num.toString().replace(/\$|\,/g,'');
        if(isNaN(num))
        num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num*100+0.50000000001);
        cents = num%100;
        num = Math.floor(num/100).toString();
        if(cents<10)
        cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
        return (((sign)?'':'-') + '$' + num + '.' + cents);
}
function FnGetFinancialStatus(APRVAL)
{
                        if(APRVAL>49000)
                         {
                                message = '<font color="#FF0000">Get professional help to aggressively reduce debt.</font>';

                        }
                        else if(APRVAL>42000 && APRVAL<=49000)
                        {
                                message = '<font color="FA8080">Financial difficulties are probably imminent unless you take immediate action.</font>';

                        }
                        else if(APRVAL>36000 && APRVAL<=42000)
                        {
                                message = '<font color="#00CC00">Not bad, but start paring debt now before you get in real trouble.</font>';

                        }
                        else if(APRVAL>0 && APRVAL<=36000)
                        {
                                message = '<font color="#009900">This is a healthy debt load to carry for most people.</font>';

                        }

                        return message;


}
function ShowDIR()
{
        var totalDebt=parseInt(document.frm1.totalDebt.value);
        if((totalDebt <= 0 || isNaN(totalDebt)))
        {
                var Result='<font color="#FA8080">Please enter valid number in the calculator</font>';
                document.frm1.totalDebt.focus();
        }
        else
        {
                var totalDebtAmount = totalDebt;
                var saveDebtAmount = ((totalDebtAmount * 40)/100);
                var debtReduce = totalDebtAmount - saveDebtAmount;
                totalDebtAmount = formatCurrency(totalDebtAmount);
                saveDebtAmount = formatCurrency(saveDebtAmount);
                debtReduce = formatCurrency(debtReduce);
                var Result='<b>Your debt : </b>'+totalDebtAmount+'<br><b>Your debt will reduce to : </b>'+debtReduce+'<br><b>We Can Save You : </b>'+saveDebtAmount+'<br />';
        }

       document.getElementById('DIR').innerHTML = Result;


}
function RemoveValue()
{
  document.getElementById('DIR').innerHTML ='';
}
function FnShowInitialTableForCalculator()
{
if(document.getElementById('DebtReductionCalculatorLink')=='http://www.debtconsolidationcare.com/')
{
var HtmlForm='<div align="center"><form name="frm1">';
HtmlForm += '<table width="175" border="0"';
HtmlForm += '<tr><td align="center">';
HtmlForm+='<div align="center"><table width="175" cellspacing="3" cellpadding="0" border="0" style="border:1px solid #006666;">';
HtmlForm+='<tbody><tr><td bgcolor="#006666" align="center" colspan="2"><font color="#ffffff"><b>Debt Reduction Calculator</b></font></td></tr>';
HtmlForm+='<tr><td bgcolor="#eeeeee" colspan="4"><div align="center"><b><font color="#ff9900">Calculate </font>how much your debt can be reduced</b></div></td></tr>';
HtmlForm+='<tr><td class="pointscalctext"><b>Total Debt $ </b></td><td><input type="text" name="totalDebt" size="10"/></td></tr>';
HtmlForm+='<tr><td colspan="4"><div align="center"><input type="button" value="Calculate" name="calculate" class="pointscalcbutton" onclick="javascript:ShowDIR();" /><input type="reset" name="Reset" value="Reset" class="pointscalcbutton" onClick="javascript:RemoveValue();"></div></td></tr>';
HtmlForm+='<tr><td colspan="4" ><div id="DIR" align="center"></div></td></tr>';
HtmlForm+='</tbody></table></div></td></tr></table></form></div>';

        document.getElementById('DebtReductionCalculator').innerHTML = HtmlForm;
}
else
{
        document.getElementById('DebtReductionCalculatorMain').innerHTML = 'To enable this Calculator, please paste the full code as described at <a href="http://www.debtconsolidationcare.com/syndicate/">Debt Consolidation Care</a>';
}
}
function FnInitialiseCSSAndShowInitialTableForCalculator()
{
    FnShowInitialTableForCalculator();
}
document.write('<style type="text/css">.pointscalctableformat{ border-color:#666666;}.pointscalctablecellformat{ border:0;}.pointscalctableheading{ color:#000066; font-weight:bold; font-family: Verdana, Tahoma, Arial, Trebuchet MS, Sans-Serif, Georgia, Courier, Times New Roman, Serif;font-size: 14px;}.pointscalcbutton { border: 1px solid white; background-color: #006666; color: white; font-size: 10px; font-weight: bold;}.pointscalctext{font-family: Verdana, Tahoma, Arial, Trebuchet MS, Sans-Serif, Georgia, Courier, Times New Roman, Serif;font-size: 10px;}.pointscalcsyndicate{ text-decoration:none; color:#999; font-family:sans-serif; font-size:11px;}</style>');
FnInitialiseCSSAndShowInitialTableForCalculator()