function mtgIns()
	{
	var dwnpmtB
	
	dwnpmtB = (1 - ( parseFloat(document.forms[0].LoanAmt3.value)/parseFloat(document.forms[0].CurrentValue.value)))*100;
	dwnpmtB = Math.round((dwnpmtB*100)+0.499)/100;
	//alert ("Down Payment B1 = " +dwnpmtB);
	
if ((document.forms[0].CurrentValue.value > "")&&(document.forms[0].LoanAmt1.value > "")) {

	if (document.forms[0].loanterm3.value == 40){
		if ((dwnpmtB >= 0) && (dwnpmtB < 5)){
				document.forms[0].mtgInsPmtAmt3.value = .96;
				}
		if ((dwnpmtB >= 5)&& (dwnpmtB < 10)) {
				document.forms[0].mtgInsPmtAmt3.value = .78;
				}
		if ((dwnpmtB >= 10)&& (dwnpmtB < 15)){
				document.forms[0].mtgInsPmtAmt3.value = .52;
				}
		if ((dwnpmtB >= 15)&& (dwnpmtB < 20)){
				document.forms[0].mtgInsPmtAmt3.value = .32;
				}
		if (dwnpmtB >= 20) {
				document.forms[0].mtgInsPmtAmt3.value = 0;
				}
	}
	
	if (document.forms[0].loanterm3.value == 30){
		if ((dwnpmtB >= 0) && (dwnpmtB < 5)){
				document.forms[0].mtgInsPmtAmt3.value = .96;
				}
		if ((dwnpmtB >= 5)&& (dwnpmtB < 10)) {
				document.forms[0].mtgInsPmtAmt3.value = .78;
				}
		if ((dwnpmtB >= 10)&& (dwnpmtB < 15)){
				document.forms[0].mtgInsPmtAmt3.value = .52;
				}
		if ((dwnpmtB >= 15)&& (dwnpmtB < 20)){
				document.forms[0].mtgInsPmtAmt3.value = .32;
				}
		if (dwnpmtB >= 20) {
				document.forms[0].mtgInsPmtAmt3.value = 0;
				}
	}

	if (document.forms[0].loanterm3.value == 25) {
		if ((dwnpmtB >= 0) && (dwnpmtB < 5)) {
				document.forms[0].mtgInsPmtAmt3.value = .85;
				}
		if ((dwnpmtB >= 5)&& (dwnpmtB < 10)) {
				document.forms[0].mtgInsPmtAmt3.value = .67;
				}
		if ((dwnpmtB >= 10)&& (dwnpmtB < 15)){
				document.forms[0].mtgInsPmtAmt3.value = .41;
				}
		if ((dwnpmtB >= 15)&& (dwnpmtB < 20)){
				document.forms[0].mtgInsPmtAmt3.value = .21;
				}
		if (dwnpmtB >= 20) {
				document.forms[0].mtgInsPmtAmt3.value = 0;
				}
	}
	
	if (document.forms[0].loanterm3.value == 20) {
		if ((dwnpmtB >= 0) && (dwnpmtB < 5)) {
				document.forms[0].mtgInsPmtAmt3.value = .80;
				}
		if ((dwnpmtB >= 5)&& (dwnpmtB < 10)) {
				document.forms[0].mtgInsPmtAmt3.value = .56;
				}
		if ((dwnpmtB >= 10)&& (dwnpmtB < 15)){
				document.forms[0].mtgInsPmtAmt3.value = .23;
				}
		if ((dwnpmtB >= 15)&& (dwnpmtB < 20)){
				document.forms[0].mtgInsPmtAmt3.value = .19;
				}
		if (dwnpmtB >= 20) {
				document.forms[0].mtgInsPmtAmt3.value = 0;
				}
	}
	
	if ((document.forms[0].loanterm3.value == 15) || (document.forms[0].loanterm3.value == 10)){
		if ((dwnpmtB >= 0) && (dwnpmtB < 5)) {
				document.forms[0].mtgInsPmtAmt3.value = .80;
				}
		if ((dwnpmtB >= 5)&& (dwnpmtB < 10)) {
				document.forms[0].mtgInsPmtAmt3.value = .56;
				}
		if ((dwnpmtB >= 10)&& (dwnpmtB < 15)){
				document.forms[0].mtgInsPmtAmt3.value = .23;
				}
		if ((dwnpmtB >= 15)&& (dwnpmtB < 20)){
				document.forms[0].mtgInsPmtAmt3.value = .19;
				}
		if (dwnpmtB >= 20) {
				document.forms[0].mtgInsPmtAmt3.value = 0;
				}
	}
	

	l = parseFloat(document.forms[0].LoanAmt3.value)*parseFloat(document.forms[0].mtgInsPmtAmt3.value)/1200;
	l = Math.round((l*100)+0.499)/100;
	document.forms[0].mtgInsPmtAmt3.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);
	}

