function reducedpayments() {

d = document.reducedpayments;


// declare variables

var v_income;
var v_outgoings;
var v_availableincome;

var creditor_name1;
var creditor_name2;
var creditor_name3;
var creditor_name4;
var creditor_name5;
var creditor_name6;
var creditor_name7;
var creditor_name8;
var creditor_name9;
var creditor_name10;

var creditor_ref1;
var creditor_ref2;
var creditor_ref3;
var creditor_ref4;
var creditor_ref5;
var creditor_ref6;
var creditor_ref7;
var creditor_ref8;
var creditor_ref9;
var creditor_ref10;

var creditor_outstanding1;
var creditor_outstanding2;
var creditor_outstanding3;
var creditor_outstanding4;
var creditor_outstanding5;
var creditor_outstanding6;
var creditor_outstanding7;
var creditor_outstanding8;
var creditor_outstanding9;
var creditor_outstanding10;

var creditor_total;

var creditor_monthly1;
var creditor_monthly2;
var creditor_monthly3;
var creditor_monthly4; 
var creditor_monthly5; 
var creditor_monthly6; 
var creditor_monthly7; 
var creditor_monthly8; 
var creditor_monthly9; 
var creditor_monthly10; 

var monthlytotal;


// asign values to variables

v_income = d.income.value - 0;
v_outgoings = d.outgoings.value - 0;
v_availableincome = v_income - v_outgoings;

creditor_name1 = d.i1.value;
creditor_name2 = d.i2.value;
creditor_name3 = d.i3.value;
creditor_name4 = d.i4.value;
creditor_name5 = d.i5.value;
creditor_name6 = d.i6.value;
creditor_name7 = d.i7.value;
creditor_name8 = d.i8.value;
creditor_name9 = d.i9.value;
creditor_name10 = d.i10.value;

creditor_ref1 = d.j1.value;
creditor_ref2 = d.j2.value;
creditor_ref3 = d.j3.value;
creditor_ref4 = d.j4.value;
creditor_ref5 = d.j5.value;
creditor_ref6 = d.j6.value;
creditor_ref7 = d.j7.value;
creditor_ref8 = d.j8.value;
creditor_ref9 = d.j9.value;
creditor_ref10 = d.j10.value;

creditor_outstanding1 = d.k1.value - 0;
creditor_outstanding2 = d.k2.value - 0;
creditor_outstanding3 = d.k3.value - 0;
creditor_outstanding4 = d.k4.value - 0;
creditor_outstanding5 = d.k5.value - 0;
creditor_outstanding6 = d.k6.value - 0;
creditor_outstanding7 = d.k7.value - 0;
creditor_outstanding8 = d.k8.value - 0;
creditor_outstanding9 = d.k9.value - 0;
creditor_outstanding10 = d.k10.value - 0;

creditor_total = creditor_outstanding1 + creditor_outstanding2 + creditor_outstanding3 + creditor_outstanding4 + creditor_outstanding5 + creditor_outstanding6 + creditor_outstanding7 + creditor_outstanding8 + creditor_outstanding9 + creditor_outstanding10;

creditor_monthly1 = Math.round((creditor_outstanding1 / creditor_total) * v_availableincome);
creditor_monthly2 = Math.round((creditor_outstanding2 / creditor_total) * v_availableincome);
creditor_monthly3 = Math.round((creditor_outstanding3 / creditor_total) * v_availableincome);
creditor_monthly4 = Math.round((creditor_outstanding4 / creditor_total) * v_availableincome);
creditor_monthly5 = Math.round((creditor_outstanding5 / creditor_total) * v_availableincome);
creditor_monthly6 = Math.round((creditor_outstanding6 / creditor_total) * v_availableincome);
creditor_monthly7 = Math.round((creditor_outstanding7 / creditor_total) * v_availableincome);
creditor_monthly8 = Math.round((creditor_outstanding8 / creditor_total) * v_availableincome);
creditor_monthly9 = Math.round((creditor_outstanding9 / creditor_total) * v_availableincome);
creditor_monthly10 = Math.round((creditor_outstanding10 / creditor_total) * v_availableincome);

monthlytotal = creditor_monthly1 + creditor_monthly2 + creditor_monthly3 + creditor_monthly4 + creditor_monthly5 + creditor_monthly6 + creditor_monthly7 + creditor_monthly8 + creditor_monthly9 + creditor_monthly10;

document.open();

document.write('<table width="600" border="0">');
document.write('<td> ');
      document.write('<p align="center"><b>DISTRIBUTION OF AVAILABLE INCOME</b></p>');
      document.write('<p align="center"><b>STRICTLY PRIVATE AND CONFIDENTIAL</b></p>');
      document.write('<table width="600" border="0" cellspacing="0" cellpadding="0">');
        document.write('<tr> ');
          document.write('<td width="200"> ');
            document.write('<p class="tabletop"> <b>INCOME & OUTGOINGS</b></p>');
          document.write('</td>');
          document.write('<td width="400">&nbsp;</td>');
        document.write('</tr>');
        document.write('<tr> ');
          document.write('<td width="200"> ');
            document.write('<div align="left">Monthly Income : </div>');
          document.write('</td>');
          document.write('<td width="400">&#163 ' + v_income + ' </td>');
        document.write('</tr>');
        document.write('<tr> ');
          document.write('<td width="200"> ');
            document.write('<div align="left">Monthly Expenditure :</div>');
          document.write('</td>');
          document.write('<td width="400">&#163 ' + v_outgoings + ' </td>');
        document.write('</tr>');
        document.write('<tr> ');
          document.write('<td width="200"> ');
            document.write('<div align="left">Available Monthly Income:</div>');
          document.write('</td>');
          document.write('<td width="400">&#163 ' + v_availableincome + ' </td>');
        document.write('</tr>');
      document.write('</table>');
  
      document.write('<br>');
    
      document.write('<table width="600" border="0" cellspacing="0" cellpadding="0">');
        document.write('<tr> ');
          document.write('<td width="150" class="tabletop"><b>CREDITORS</b></td>');
          document.write('<td width="150">&nbsp;</td>');
          document.write('<td width="150">&nbsp;</td>');
          document.write('<td width="150">&nbsp;</td>');
        document.write('</tr>');
        document.write('<tr> ');
          document.write('<td width="150"> ');
           document.write(' <div align="left"><b>Creditor</b></div>');
          document.write('</td>');
          document.write('<td width="150"> ');
           document.write(' <div align="left"><b>Account / Ref No.</b></div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left"><b>Amount<br>Outstanding</b></div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left"><b>Pro Rata<br>Monthly Payment</b></div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_name1 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_ref1 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding1 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly1 + '</div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_name2 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_ref2 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">&#163 ' + creditor_outstanding2 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">&#163 ' + creditor_monthly2 + '</div>');
          document.write('</td>');
      document.write('  </tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
           document.write(' <div align="left">' + creditor_name3 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_ref3 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding3 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly3 + '</div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_name4 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_ref4 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding4 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly4 + '</div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_name5 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">' + creditor_ref5 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding5 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly5 + '</div>');
          document.write('</td>');
       document.write(' </tr>');

        document.write('<tr> ');
         document.write(' <td width="150">');
          document.write('  <div align="left">' + creditor_name6 + '</div>');
         document.write(' </td>');
          document.write('<td width="150">');
          document.write('  <div align="left">' + creditor_ref6 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">&#163 ' + creditor_outstanding6 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">&#163 ' + creditor_monthly6 + '</div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
         document.write(' <td width="150">');
           document.write(' <div align="left">' + creditor_name7 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">' + creditor_ref7 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding7 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly7 + '</div>');
          document.write('</td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
           document.write(' <div align="left">' + creditor_name8 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
           document.write(' <div align="left">' + creditor_ref8 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_outstanding8 + '</div>');
         document.write(' </td>');
          document.write('<td width="150">');
            document.write('<div align="left">&#163 ' + creditor_monthly8 + '</div>');
         document.write(' </td>');
       document.write(' </tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
          document.write('  <div align="left">' + creditor_name9 + '</div>');
         document.write(' </td>');
         document.write(' <td width="150">');
          document.write(' <div align="left">' + creditor_ref9 + '</div>');
          document.write('</td>');
          document.write('<td width="150">');
          document.write('  <div align="left">&#163 ' + creditor_outstanding9 + '</div>');
         document.write(' </td>');
          document.write('<td width="150">');
          document.write('  <div align="left">&#163 ' + creditor_monthly9 + '</div>');
         document.write(' </td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
           document.write(' <div align="left">' + creditor_name10 + '</div>');
          document.write('</td>');
         document.write(' <td width="150">');
           document.write(' <div align="left">' + creditor_ref10 + '</div>');
          document.write('</td>');
         document.write(' <td width="150">');
          document.write('  <div align="left">&#163 ' + creditor_outstanding10 + '</div>');
         document.write(' </td>');
         document.write(' <td width="150">');
          document.write('  <div align="left">&#163 ' + creditor_monthly10 + '</div>');
         document.write(' </td>');
        document.write('</tr>');

        document.write('<tr> ');
          document.write('<td width="150">');
           document.write(' <div align="left"></div>');
          document.write('</td>');
         document.write(' <td width="150">');
           document.write(' <div align="left"><b>TOTAL</b> </div>');
          document.write('</td>');
         document.write(' <td width="150">');
          document.write('  <div align="left"><b>&#163 ' + creditor_total + '</b></div>');
         document.write(' </td>');
         document.write(' <td width="150">');
          document.write('  <div align="left"><b>&#163 ' + monthlytotal + '</b></div>');
         document.write(' </td>');
        document.write('</tr>');

      document.write('</table>');

      document.write('<p>This is an accurate record of my financial position as at: ___________________________</p>');
      document.write('<table width="600" border="0" cellspacing="0" cellpadding="0">');
      document.write('  <tr> ');
         document.write(' <td width="200">Signed:</td>');
          document.write('<td width="400">____________________________________________</td>');
        document.write('</tr>');
        document.write('<tr> ');
        document.write('  <td width="200">&nbsp;</td>');
        document.write('  <td width="400">&nbsp;</td>');
        document.write('</tr>');
        document.write('<tr>');
        document.write('  <td width="200">Signed:</td>');
        document.write('  <td width="400">____________________________________________</td>');
        document.write('</tr>');
      document.write('</table>');
    document.write('</td>');
document.write('</table>');

document.close();
}
