function computeNewLoans()
{
	var RefiType 
	
	if (document.forms[0].RefiType.options.selectedIndex == 0){
		RefiType = 1; }
		else {
		RefiType = 2; }
		//alert ("RefiType = " +RefiType);	
	var PointsCosts 
		if (document.forms[0].PointsAndCosts[0].checked == 0){
		PointsCosts = 2}
		else {
		PointsCosts = 1}
		//alert ("PointsAndCosts Value = " +PointsCosts);
		
	if (RefiType == 1 ) {
// This next section is used to save input prior to calculations in the event the user
// toggles between Refi Each and Consolidate
	if (document.forms[0].LoanAmt4.value != "      N/A"){
	document.forms[0].refi1loanamt4.value = document.forms[0].LoanAmt4.value;
	document.forms[0].LoanAmt4.value = document.forms[0].refi1loanamt4.value;
	LoanAmt4 = document.forms[0].LoanAmt4.value;
	}
	if (document.forms[0].intrate4.value != "      N/A"){
	document.forms[0].refi1intrate4.value = document.forms[0].intrate4.value;
	document.forms[0].intrate4.value = document.forms[0].refi1intrate4.value;
	intrate4 = document.forms[0].intrate4.value;
	}
	if (document.forms[0].loanterm4.value != "      N/A"){
	document.forms[0].refi1loanterm4.value = document.forms[0].loanterm4.value;
	document.forms[0].loanterm4.value = document.forms[0].refi1loanterm4.value;
	loanterm4 = document.forms[0].loanterm4.value;
	}
	if (document.forms[0].points4.value != "      N/A"){
	document.forms[0].refi1points4.value = document.forms[0].points4.value;
	document.forms[0].points4.value = document.forms[0].refi1points4.value;
	points4 = document.forms[0].points4.value;
	if (points4 < 0.1){point4 = 0};
	}
	if (document.forms[0].OtherCosts4.value != "      N/A"){
	document.forms[0].refi1othercosts4.value = document.forms[0].OtherCosts4.value;
	document.forms[0].OtherCosts4.value = document.forms[0].refi1othercosts4.value;
	OtherCosts4 = document.forms[0].OtherCosts4.value;
	if (OtherCosts4 < 0.1){OtherCosts4 = 0};
	}
	
// The following lines retrieve input before calculations have been run and after
// user has toggled between Refi Each and Consolidate

	if (document.forms[0].LoanAmt4.value == "      N/A"){
	document.forms[0].LoanAmt4.value = document.forms[0].refi1loanamt4.value;
	LoanAmt4 = (document.forms[0].refi1loanamt4.value);
	}
	if (document.forms[0].intrate4.value == "      N/A"){
	document.forms[0].intrate4.value = document.forms[0].refi1intrate4.value;
	intrate4 = (document.forms[0].refi1intrate4.value);
	}
	if (document.forms[0].loanterm4.value == "      N/A"){
	document.forms[0].loanterm4.value = document.forms[0].refi1loanterm4.value;
	loanterm4 = document.forms[0].refi1loanterm4.value;
	}
	if (document.forms[0].points4.value == "      N/A"){
	document.forms[0].points4.value = document.forms[0].refi1points4.value;
	points4 = document.forms[0].refi1points4.value;
	if (points4 < 0.1){point4 = 0};
	}
	if (document.forms[0].OtherCosts4.value == "      N/A"){
	document.forms[0].OtherCosts4.value = document.forms[0].refi1othercosts4.value;
	OtherCosts4 = document.forms[0].refi1othercosts4.value;
	if (OtherCosts4 < 0.1){OtherCosts4 = 0};
	}
	}
		
// The following lines restore input after calculations have run
	if (RefiType == 1 && document.forms[0].sessionvars.value == "true") {
	
	document.forms[0].LoanAmt4.value = document.forms[0].refi1loanamt4.value;
	document.forms[0].intrate4.value = document.forms[0].refi1intrate4.value;
	document.forms[0].loanterm4.value = document.forms[0].refi1loanterm4.value;
	document.forms[0].points4.value = document.forms[0].refi1points4.value;
	document.forms[0].OtherCosts4.value = document.forms[0].refi1othercosts4.value;
	LoanAmt4 = document.forms[0].LoanAmt4.value;
	intrate4 = document.forms[0].intrate4.value;
	loanterm4 = document.forms[0].loanterm4.value;
	points4 = document.forms[0].points4.value;
	if (points4 < 0.1){point4 = 0};
	OtherCosts4 = document.forms[0].OtherCosts4.value;
	if (OtherCosts4 < 0.1){OtherCosts4 = 0};
	
	}

// The following populates the Loan 4 input prompts when Consolidate is selected
	if (RefiType == 2) {
		document.forms[0].LoanAmt4.value = "      N/A";
		document.forms[0].intrate4.value = "      N/A";
		document.forms[0].loanterm4.value = "      N/A"
		document.forms[0].points4.value = "      N/A";
		document.forms[0].OtherCosts4.value = "      N/A";
	}
	
// The following calculates Loan3 and Loan 4 for any combination of user choices

	var LoanAmt1=(document.forms[0].LoanAmt1.value);
	var LoanAmt2=(document.forms[0].LoanAmt2.value);
	if (LoanAmt2 == "") {LoanAmt2 = 0};
	var LoanAmt3=(document.forms[0].LoanAmt3.value);
	var points3 = (document.forms[0].points3.value);
	if(points3 == "") {points3 = 0}
	var OtherCosts3 = (document.forms[0].OtherCosts3.value);
	if (OtherCosts3 == ""){OtherCosts3 = 0};
	if(points4 == "") {points4 = 0}
	if (OtherCosts4 == ""){OtherCosts4 = 0};
	
// Set up 4 possible combinations of RefiType and PointsCosts
	
if (document.forms[0].LoanAmt1.value > ""){

	if (RefiType == 1 && PointsCosts == 1){
	
		document.forms[0].LoanAmt3.value = Math.round(parseFloat(LoanAmt1));
		if (LoanAmt2 > "" ) {
		document.forms[0].LoanAmt4.value = Math.round(parseFloat(LoanAmt2));
		}
	
	} // End if (RefiType == 1 && PointsAndCosts == 1)
	
	if (RefiType == 2 && PointsCosts == 1){
	
		document.forms[0].LoanAmt3.value = Math.round(parseFloat(LoanAmt1) + parseFloat(LoanAmt2));
		
	} // End if (RefiType == 2 && PointsCosts == 1)

	if (RefiType == 1 && PointsCosts == 2){
	
		document.forms[0].LoanAmt3.value = Math.round((parseFloat(LoanAmt1) + parseFloat(OtherCosts3)) / (1 - parseFloat(points3)/100));
		if (LoanAmt2 > "" ) {
		document.forms[0].LoanAmt4.value = Math.round((parseFloat(LoanAmt2) + parseFloat(OtherCosts4)) / (1 - parseFloat(points4)/100));
		}
	
	} // End if (RefiType == 1 && PointsCosts == 2)

	if (RefiType == 2 && PointsCosts == 2){
	
		document.forms[0].LoanAmt3.value = Math.round((parseFloat(LoanAmt1) + parseFloat(LoanAmt2) + parseFloat(OtherCosts3)) / (1 - parseFloat(points3)/100));
	
	} // End if (RefiType == 2 && PointsCosts == 2)
} // End if LoanAmt1 > ""

mtgIns()

}
