can someone help with this? nothing works beyond the // *#############
<script>
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid() {
var amtpaid = document.getElementById("amtpaid");
var rentdue = document.getElementById("rentdue");
var prevbal = document.getElementById("prevbal");
var hudpay = document.getElementById("hudpay");
var tentpay = document.getElementById("tentpay");
var datepaid = document.getElementById("datepaid");
var late = document.getElementById("late");
var damage = document.getElementById("damage");
var courtcost = document.getElementById("courtcost");
var nsf = document.getElementById("nsf");
var latechg = document.getElementById("latechg");
var secdep = document.getElementById("secdep");
var paidsum = document.getElementById("paidsum");
var dateNow = new Date();
var dayNow = dateNow.getDate();
var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
datepaid.value = datePaid;
// ***************************************************************************************
// * if paid later than the 5th of the month, insert an "L" in the late field and add 10 the the rentdue
// ***************************************************************************************
if(dayNow > 5) { late.value = "L"; rentdue = rentdue + 10; }
// ***************************************************************************************
// * add the amtpaid (current) to any previous payments (paidsum)
// ***************************************************************************************
paidsum.value = parseInt(paidsum.value) + parseInt(amtpaid.value);
// ***************************************************************************************
// * tentpay = amtpaid - hudpay
// ***************************************************************************************
tentpay.value = parseInt(tentpay.value) + parseInt(amtpaid.value) - parseInt(hudpay.value);
// ##############################################################
// * totOwed = everything = everything owed
// ***************************************************************************************
var totOwed = parseInt(rentdue.value) + parseInt(prevbal.value) +
parseInt(secdep.value) + parseInt(damage.value) + parseInt(latechg.value) +
parseInt(courtcost.value) + parseInt(nsf.value) - parseInt(hudpay.value);
// ***************************************************************************************
// * stillOwed = what is still owed after the payment(amtpaid)
// ***************************************************************************************
var stillOwed = totOwed - parseInt(amtpaid.value);
// ***************************************************************************************
// * if an excess has been paid, prevbal will be a minus amt & all previous chgs will be zero
// ***************************************************************************************
if (amtpaid.value >= totOwed) { prevbal.value = totOwed - amtpaid.value; secdep.value = 0;
damage.value = 0; latechg.value = 0; courtcost.value = 0; nsf.value = 0;}
// ***************************************************************************************
// * if money is still owed, pay in order-prevbal,secdep,damage,latechg,courtcost,nsf
// * until payment is exhausted
// ***************************************************************************************
if (stillOwed >= prevbal.value) {stillOwed = stillOwed - prevbal.value; prevbal.value = 0;}
if (stillOwed > 0) {prevbal.value = prevbal.value - stillOwed; stillOwed = 0;}
if (stillOwed >= secdep.value) {stillOwed = stillOwed - secdep.value; secdep.value = 0;}
if (stillOwed > 0) {secdep.value = secdep.value - stillOwed; stillOwed = 0;}
if (stillOwed >= damage.value) {stillOwed = stillOwed - damage.value; damage.value = 0;}
if (stillOwed > 0) {damage.value = damage.value - stillOwed; stillOwed = 0;}
if (stillOwed >= latechg.value) {stillOwed = stillOwed - latechg.value; latechg.value = 0;}
if (stillOwed > 0) {latechg.value = latechg.value - stillOwed; stillOwed = 0;}
if (stillOwed >= courtcost.value) {stillOwed = stillOwed - courtcost.value; courtcost.value = 0;}
if (stillOwed > 0) {courtcost.value = courtcost.value - stillOwed; stillOwed = 0;}
if (stillOwed >= nsf.value) {stillOwed = stillOwed - nsf.value; nsf.value = 0;}
if (stillOwed > 0) {nsf.value = nsf.value - stillOwed; stillOwed = 0;}
}
</script>