// Calculations for Millennia Logix loan comparison calculator
// Copyright 2005 Millennia Logix, Inc by Paul F Johnson and John B Lisle
function checkLC() {

// Check if data has been entered correctly then do the calculation.

	if (document.calculator.loanTerm.value == "" || document.calculator.loanTerm.value == "0" ) {
		alert("Please enter the length of time you wish to borrow the money.");
		document.calculator.loanTerm.focus();
		return false
		}

	if (document.calculator.IntRateLow.value == "" || document.calculator.IntRateLow.value == "0" ) {
		alert("Please enter the Low Interest Rate.");
		document.calculator.IntRateLow.focus();
		return false
		}

	if (document.calculator.IntRateHigh.value == "" || document.calculator.IntRateHigh.value == "0" ) {
		alert("Please enter the High Interest Rate.");
		document.calculator.IntRateHigh.focus();
		return false
		}

	if (document.calculator.IntRateIncr.value == "" || document.calculator.IntRateIncr.value == "0" ) {
		alert("Please enter the Interest Rate Increment.");
		document.calculator.IntRateIncr.focus();
		return false
		}

	var calcType = getRadioButtonValue(document.calculator.calcType)

	var numMonths = document.calculator.loanTerm.value
	var perUnit = getRadioButtonValue(document.calculator.loanTermUnit)
	if ( perUnit == "year" ) { numMonths = numMonths * 12 }

//	var rRateFactor = document.calculator.IntRate.value / 1200.
//	var rInitDep = document.calculator.InitDeposit.value
//	var Factor = Math.pow( (1. + rRateFactor), numMonths )

	if ( calcType == "monthlyPayment" ) {
		if (document.calculator.loanLow.value == "" || document.calculator.loanLow.value == "0" ) {
			alert("Please enter the low end of what you would like to borrow.");
			document.calculator.loanLow.focus();
			return false
			}
		if (document.calculator.loanHigh.value == "" || document.calculator.loanHigh.value == "0" ) {
			alert("Please enter the high end of what you would like to borrow.");
			document.calculator.loanHigh.focus();
			return false
			}

//		document.calculator.amountSaved.value = document.calculator.savingsGoal.value
//		var rGoal = document.calculator.savingsGoal.value - (rInitDep * Factor)
//		var rdepAmt = (rRateFactor * rGoal) / ( Factor - 1. )
//		document.calculator.depAmount.value = Round2Dollars(rdepAmt)		
		}
	else {
		if (document.calculator.payLow.value == "" || document.calculator.payLow.value == "0" ) {
			alert("Please enter the low end of what you would like to pay each month.");
			document.calculator.payLow.focus();
			return false
			}
		if (document.calculator.payHigh.value == "" || document.calculator.payHigh.value == "0" ) {
			alert("Please enter the high end of what you would like to pay each month.");
			document.calculator.payHigh.focus();
			return false
			}

//		document.calculator.depAmount.value = document.calculator.depositAmount.value
//		var rPrincipal = document.calculator.depositAmount.value
//		var rSaveTotal = (rInitDep * Factor) + ( rPrincipal / rRateFactor ) * ( Factor - 1. )
//		document.calculator.amountSaved.value = Round2Dollars(rSaveTotal)
		}

	bCalc = true
	return true
	
	}
