function mtgIns()
	{

	if (document.forms[0].intrate1.value > ""){
	document.forms[0].intrate2.value = document.forms[0].intrate1.value;
	}//if (document.forms[0].intrate1.value > "")

	document.forms[0].loanterm2.options.selectedIndex = document.forms[0].loanterm1.options.selectedIndex;
	
	if (document.forms[0].points1.value > ""){
	document.forms[0].points2.value = document.forms[0].points1.value;
	}//if (document.forms[0].points1.value > "")

//alert ("Loan Type = " + document.forms[0].loantype[0].checked);
if ((document.forms[0].CurrentValue.value > "")&&(document.forms[0].LoanAmt1.value > "")&&(document.forms[0].loantype[0].checked)){
	document.forms[0].LoanAmt2.value = parseFloat(document.forms[0].CurrentValue.value)*.80;
	document.forms[0].LoanAmt3.value = document.forms[0].LoanAmt1.value - document.forms[0].LoanAmt2.value;
	}//if ((document.forms[0].CurrentValue.value > "")&&
if (document.forms[0].loantype[1].checked) {  // User Defined selected

if((document.forms[0].LoanAmt2.value > "")&&(document.forms[0].LoanAmt2.value < document.forms[0].CurrentValue.value * .80)){
	document.forms[0].LoanAmt3.value = document.forms[0].LoanAmt1.value - document.forms[0].LoanAmt2.value;
	}//if((document.forms[0].LoanAmt2.value > "")&&
	if (document.forms[0].LoanAmt2.value >= document.forms[0].CurrentValue.value * .80) {
	alert("The user specified first mortgage \n must be less than " + document.forms[0].CurrentValue.value * .80 + "\n (80% of the current value of the property)");
	document.forms[0].LoanAmt2.value = "";
	document.forms[0].LoanAmt3.value = "";
	document.forms[0].LoanAmt2.focus();
	}//if (document.forms[0].LoanAmt2.value >= document.forms[0].CurrentValue.value * .80)
	
	}//if (document.forms[0].loantype[1].checked)
	
if ((document.forms[0].CurrentValue.value > "")&&(document.forms[0].LoanAmt1.value > "")){
	dwnpmtA = (1 - ( parseFloat(document.forms[0].LoanAmt1.value)/parseFloat(document.forms[0].CurrentValue.value)))*100;
	dwnpmtA = Math.round((dwnpmtA*100)+0.499)/100;
	}
	
if ((document.forms[0].CurrentValue.value > "")&&(document.forms[0].LoanAmt1.value > "")){

	if (document.forms[0].loanterm1.options.selectedIndex == 0){
		if ((dwnpmtA >= 0) && (dwnpmtA < 5)){
				document.forms[0].mtgInsPmtAmt1.value = .96;
				}
		if ((dwnpmtA >= 5)&& (dwnpmtA < 10)) {
				document.forms[0].mtgInsPmtAmt1.value = .78;
				}
		if ((dwnpmtA >= 10)&& (dwnpmtA < 15)){
				document.forms[0].mtgInsPmtAmt1.value = .52;
				}
		if ((dwnpmtA >= 15)&& (dwnpmtA < 20)){
				document.forms[0].mtgInsPmtAmt1.value = .32;
				}
		if (dwnpmtA >= 20) {
				document.forms[0].mtgInsPmtAmt1.value = 0;
				}
	}
	
	if (document.forms[0].loanterm1.options.selectedIndex == 1){
		if ((dwnpmtA >= 0) && (dwnpmtA < 5)){
				document.forms[0].mtgInsPmtAmt1.value = .96;
				}
		if ((dwnpmtA >= 5)&& (dwnpmtA < 10)) {
				document.forms[0].mtgInsPmtAmt1.value = .78;
				}
		if ((dwnpmtA >= 10)&& (dwnpmtA < 15)){
				document.forms[0].mtgInsPmtAmt1.value = .52;
				}
		if ((dwnpmtA >= 15)&& (dwnpmtA < 20)){
				document.forms[0].mtgInsPmtAmt1.value = .32;
				}
		if (dwnpmtA >= 20) {
				document.forms[0].mtgInsPmtAmt1.value = 0;
				}
	}

	if (document.forms[0].loanterm1.options.selectedIndex == 2) {
		if ((dwnpmtA >= 0) && (dwnpmtA < 5)) {
				document.forms[0].mtgInsPmtAmt1.value = .85;
				}
		if ((dwnpmtA >= 5)&& (dwnpmtA < 10)) {
				document.forms[0].mtgInsPmtAmt1.value = .67;
				}
		if ((dwnpmtA >= 10)&& (dwnpmtA < 15)){
				document.forms[0].mtgInsPmtAmt1.value = .41;
				}
		if ((dwnpmtA >= 15)&& (dwnpmtA < 20)){
				document.forms[0].mtgInsPmtAmt1.value = .21;
				}
		if (dwnpmtA >= 20) {
				document.forms[0].mtgInsPmtAmt1.value = 0;
				}
	}
	
	if (document.forms[0].loanterm1.options.selectedIndex == 3) {
		if ((dwnpmtA >= 0) && (dwnpmtA < 5)) {
				document.forms[0].mtgInsPmtAmt1.value = .80;
				}
		if ((dwnpmtA >= 5)&& (dwnpmtA < 10)) {
				document.forms[0].mtgInsPmtAmt1.value = .56;
				}
		if ((dwnpmtA >= 10)&& (dwnpmtA < 15)){
				document.forms[0].mtgInsPmtAmt1.value = .23;
				}
		if ((dwnpmtA >= 15)&& (dwnpmtA < 20)){
				document.forms[0].mtgInsPmtAmt1.value = .19;
				}
		if (dwnpmtA >= 20) {
				document.forms[0].mtgInsPmtAmt1.value = 0;
				}
	}
	
	if ((document.forms[0].loanterm1.options.selectedIndex == 4) || 		(document.forms[0].loanterm1.options.selectedIndex == 5)){
		if ((dwnpmtA >= 0) && (dwnpmtA < 5)) {
				document.forms[0].mtgInsPmtAmt1.value = .80;
				}
		if ((dwnpmtA >= 5)&& (dwnpmtA < 10)) {
				document.forms[0].mtgInsPmtAmt1.value = .56;
				}
		if ((dwnpmtA >= 10)&& (dwnpmtA < 15)){
				document.forms[0].mtgInsPmtAmt1.value = .23;
				}
		if ((dwnpmtA >= 15)&& (dwnpmtA < 20)){
				document.forms[0].mtgInsPmtAmt1.value = .19;
				}
		if (dwnpmtA >= 20) {
				document.forms[0].mtgInsPmtAmt1.value = 0;
				}
				}
				
		l = parseFloat(document.forms[0].LoanAmt1.value)*parseFloat(document.forms[0].mtgInsPmtAmt1.value)/1200;
	l = Math.round((l*100)+0.499)/100;
	document.forms[0].mtgInsPmtAmt1.value = l;
	
	}
	}

function format(expr,decplaces){
	var str = "" + Math.round(eval(expr)*Math.pow(10,decplaces))
	while (str.length <= decplaces){
		str = "0" + str
		}
	var decpoint = str.length - decplaces;
	return str.substring(0,decpoint) + "" + str.substring(decpoint,str.length);
	}
	
function dollarize(expr){
	return "$" + format(expr,0)
	}
