function resetForms() {
   for (i=0; i < document.form.length; i++) {
     document.form[i].reset();
   }
}

// collapse individual elements
  function collapseElem(obj)
     {
         var el = document.getElementById(obj);
         el.style.display = 'none';
     }


         // expand next element
  function expandElem(obj)
     {
         var el = document.getElementById(obj);
         el.style.display = 'inline';
     }

function clientType(var1) {
	if (var1.selectedIndex == 0) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
    } else if (var1.selectedIndex == 1) {
        document.getElementById("single").style.display = "inline";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
    } else if (var1.selectedIndex == 2) {
        document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "inline";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 3) {
        document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "inline";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
		} else if (var1.selectedIndex == 4) {
        document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "inline";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 5) {
        document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "inline";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 6) {
        document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "inline";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 7) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "inline";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 8) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "inline";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 9) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "inline";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 10) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "inline";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
		} else if (var1.selectedIndex == 11) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "inline";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 12) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "inline";
		document.getElementById("other_business1").style.display = "none";
	} else if (var1.selectedIndex == 13) {
		document.getElementById("single").style.display = "none";
        document.getElementById("mobile").style.display = "none";
		document.getElementById("triplex").style.display = "none";
		document.getElementById("duplex").style.display = "none";
		document.getElementById("apartments1-4").style.display = "none";
		document.getElementById("apartments4").style.display = "none";
		document.getElementById("retail").style.display = "none";
		document.getElementById("center").style.display = "none";
		document.getElementById("industrial").style.display = "none";
		document.getElementById("land_under5").style.display = "none";
		document.getElementById("land_over5").style.display = "none";
		document.getElementById("office_buld").style.display = "none";
		document.getElementById("other_business1").style.display = "inline";
	}
	
}

function checkWholeForm(theForm)
	{
		
	checkPrice(theForm.down_payment.value, theForm.first_mortgage_value.value, theForm.second_mortgage_value.value, theForm.price_sold.value);
		
	}
	

function checkPrice(down_payment, first_mortgage_value, second_mortgage_value, price_sold)
	{
		var error= "";
		var price;
		price= (down_payment*1)+(first_mortgage_value*1)+(second_mortgage_value*1);
		var down;
		down=down_payment;
		if (price_sold != price) {
			document.getElementById("payment_check").style.display = "inline";
			}else {
				document.getElementById("payment_check").style.display = "none";
			}
	}
	
	
function checkForm2(theForm)
	{
		
	checkCheck(theForm.peyor_select.value);
		
	}
function checkCheck(peyor_select)
	{
		var error= "";
		if(peyor_select==0){
			document.getElementById("peyor_check1").style.display = "inline";
			}else {
				document.getElementById("peyor_check1").style.display = "none";
			}
	}

function checkForm3(theForm)
	{
	var i;var j;
	var myOption = -1;
	var myOption2 = -1;
	for (i=theForm.no_creditchk.length-1; i > -1; i--) {
	if (theForm.no_creditchk[i].checked) {
	myOption = i; i = -1;
	}
	}
	for (j=theForm.yes_creditchk.length-1; j > -1; j--) {
	if (theForm.yes_creditchk[j].checked) {
	myOption2 = j; j = -1;
		}
	}
	if ((myOption == -1)&&(myOption2 == -1)) {
			document.getElementById("payor_check2").style.display = "inline";
			}else {
				document.getElementById("payor_check2").style.display = "none";
			
	}
	}


function checkForm4(theForm)
	{
	if ((theForm.original_first.value==null) || (theForm.original_first.value==0) ) {
			document.getElementById("amount_check2").style.display = "inline";
			}else {
			document.getElementById("amount_check2").style.display = "none";
			
	}
	}

function checkForm5(theForm)
	{
	if ((theForm.interest_first.value==null) || (theForm.interest_first.value==0) ) {
			document.getElementById("interest_check2").style.display = "inline";
			}else {
			document.getElementById("interest_check2").style.display = "none";
			
	}
	}

function checkForm6(theForm)
	{
	if ((theForm.amortization_number.value==null) || (theForm.amortization_number.value==0) ) {
			document.getElementById("amortization_check2").style.display = "inline";
			}else {
			document.getElementById("amortization_check2").style.display = "none";
			
	}
	}
	

function checkPrice2()
	{
		document.getElementById("payment_check").style.display = "none";

	}




function clientType1(var1) {
	if (var1.selectedIndex == "0") {
        document.getElementById("retail_radio").style.display = "none";
		
    } else if (var1.selectedIndex == "1") {
        document.getElementById("retail_radio").style.display = "inline";
   }
}

function clientType2(var1) {
	if (var1.selectedIndex == "0") {
        document.getElementById("office_radio").style.display = "none";
		
    } else if (var1.selectedIndex == "1") {
        document.getElementById("office_radio").style.display = "inline";
   }
}
function clientType3(var1) {
	if (var1.selectedIndex == "0") {
        document.getElementById("center_radio").style.display = "none";
		
    } else if (var1.selectedIndex == "1") {
        document.getElementById("center_radio").style.display = "inline";
   }
}
function clientType4(var1) {
	if (var1.selectedIndex == "0") {
        document.getElementById("over5_radio").style.display = "none";
		
    } else if (var1.selectedIndex == "1") {
        document.getElementById("over5_radio").style.display = "inline";
   }
}
function clientType5(var1) {
	if (var1.selectedIndex == "1") {
        document.getElementById("credit_check_yes").style.display = "none";
		document.getElementById("credit_check_no").style.display = "inline";
		
    } else if (var1.selectedIndex == "2") {
        document.getElementById("credit_check_no").style.display = "none";
		document.getElementById("credit_check_yes").style.display = "inline";
   } else if (var1.selectedIndex == "0") {
        document.getElementById("credit_check_no").style.display = "none";
		document.getElementById("credit_check_yes").style.display = "none";
   }
}

function clientType6(var1) {
	if (var1.selectedIndex == "0") {
        document.getElementById("noteseller_radio").style.display = "none";
		
    } else if (var1.selectedIndex == "1") {
        document.getElementById("noteseller_radio").style.display = "inline";
   }
}


function original_first() {
	var theForm = document.theForm;
	theForm.original_first.value = theForm.first_mortgage_value.value;
}

function moveOnMax(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

function calcValues(){
	var theForm = document.theForm;
	theForm.apartment_plus_3bed1bath_calc.value = (theForm.apartment_plus_3bed1bath_n.value * theForm.apartment_plus_3bed1bath_money.value);
}
function calcValues2(){
	var theForm = document.theForm;
	theForm.apartment_plus_2Bed1Bath_calc.value = (theForm.apartment_plus_2Bed1Bath_n.value * theForm.apartment_plus_2Bed1Bath_money.value);
}
function calcValues3(){
	var theForm = document.theForm;
	theForm.apartment_plus_1Bed1Bath_calc.value = (theForm.apartment_plus_1Bed1Bath_n.value * theForm.apartment_plus_1Bed1Bath_money.value);
}


function calcValues4(){
	var theForm = document.theForm;
	theForm.apartment_plus_studio_calc.value = (theForm.apartment_plus_studio_n.value * theForm.apartment_plus_studio_money.value);
}

function calcValues5(){
	var theForm = document.theForm;
	theForm.apartment_plus_ther_calc.value = (theForm.apartment_plus_other_n.value * theForm.apartment_plus_other_money.value);
}

function calcTotal(){
	var theForm = document.theForm;
	theForm.apartment_plus_total_calc.value = (theForm.apartment_plus_ther_calc.value *1)+( theForm.apartment_plus_studio_calc.value*1)
	+( theForm.apartment_plus_1Bed1Bath_calc.value*1)+( theForm.apartment_plus_2Bed1Bath_calc.value*1)+( theForm.apartment_plus_3bed1bath_calc.value*1);
}
function totalAppartment4N1(){
	var theForm = document.theForm;
	theForm.apartment_plus_unit_total.value = (theForm.apartment_plus_3bed1bath_n.value *1)+( theForm.apartment_plus_2Bed1Bath_n.value*1)
	+( theForm.apartment_plus_1Bed1Bath_n.value*1)+( theForm.apartment_plus_studio_n.value*1)+( theForm.apartment_plus_other_n.value*1);
}

function calcRetail1(){
	var theForm = document.theForm;
	theForm.retail_apartments_calc.value = (theForm.retail_apartments_n.value * theForm.retail_apartments_money.value);
}

function calcRetail2(){
	var theForm = document.theForm;
	theForm.retail_spaces_calc.value = (theForm.retail_spaces_n.value * theForm.retail_spaces_money.value);
}

function calcRetail3(){
	var theForm = document.theForm;
	theForm.retail_offices_calc.value = (theForm.retail_offices_n.value * theForm.retail_offices_money.value);
}

function calcRetail4(){
	var theForm = document.theForm;
	theForm.retail_other_calc.value = (theForm.retail_other_n.value * theForm.retail_other_money.value);
}

function calcRetail5(){
	var theForm = document.theForm;
	theForm.retail_other1_calc.value = (theForm.retail_other1_n.value * theForm.retail_other1_money.value);
}

function totalRetail(){
	var theForm = document.theForm;
	theForm.retail_total_calc.value = (theForm.retail_other1_calc.value *1)+( theForm.retail_other_calc.value*1)
	+( theForm.retail_offices_calc.value*1)+( theForm.retail_spaces_calc.value*1)+( theForm.retail_apartments_calc.value*1);
}
function totalRetailSQFT(){
	var theForm = document.theForm;
	theForm.retail_total_sqrt.value = (theForm.retail_sqft5.value *theForm.retail_other1_n.value)+( theForm.retail_sqft4.value*theForm.retail_other_n.value)
	+( theForm.retail_sqft3.value*theForm.retail_offices_n.value)+( theForm.retail_sqft2.value*theForm.retail_spaces_n.value)+( theForm.retail_sqft1.value*theForm.retail_apartments_n.value);
}
function totalRetailN1(){
	var theForm = document.theForm;
	theForm.retail_unit_total.value = (theForm.retail_other1_n.value *1)+( theForm.retail_other_n.value*1)
	+( theForm.retail_offices_n.value*1)+( theForm.retail_spaces_n.value*1)+( theForm.retail_apartments_n.value*1);
}


function calcOffice1(){
	var theForm = document.theForm;
	theForm.office1_calc1.value = (theForm.office1_n1.value * theForm.office1_money1.value);
}

function calcOffice2(){
	var theForm = document.theForm;
	theForm.office1_calc2.value = (theForm.office1_n2.value * theForm.office1_money2.value);
}
function calcOffice3(){
	var theForm = document.theForm;
	theForm.office1_calc3.value = (theForm.office1_n3.value * theForm.office1_money3.value);
}
function calcOffice4(){
	var theForm = document.theForm;
	theForm.office1_calc4.value = (theForm.office1_n4.value * theForm.office1_money4.value);
}
function calcOffice5(){
	var theForm = document.theForm;
	theForm.office1_calc5.value = (theForm.office1_n5.value * theForm.office1_money5.value);
}
function totalOffice(){
	var theForm = document.theForm;
	theForm.office_total_calc.value = (theForm.office1_calc5.value *1)+( theForm.office1_calc4.value*1)
	+( theForm.office1_calc3.value*1)+( theForm.office1_calc2.value*1)+( theForm.office1_calc1.value*1);
}
function totalOfficeN1(){
	var theForm = document.theForm;
	theForm.office1_total_n.value = (theForm.office1_n5.value *1)+( theForm.office1_n4.value*1)
	+( theForm.office1_n3.value*1)+( theForm.office1_n2.value*1)+( theForm.office1_n1.value*1);
}
function totalOfficeSQFT(){
	var theForm = document.theForm;
	theForm.office1_total_sqft.value = (theForm.office1_sqft5.value *theForm.office1_n5.value)+( theForm.office1_sqft4.value*theForm.office1_n4.value)
	+( theForm.office1_sqft3.value*theForm.office1_n3.value)+( theForm.office1_sqft2.value*theForm.office1_n2.value)+( theForm.office1_sqft1.value*theForm.office1_n1.value);
}




function calcCenter1(){
	var theForm = document.theForm;
	theForm.center_calc1.value = (theForm.center_n1.value * theForm.center_money1.value);
}
function calcCenter2(){
	var theForm = document.theForm;
	theForm.center_calc2.value = (theForm.center_n2.value * theForm.center_money2.value);
}
function calcCenter3(){
	var theForm = document.theForm;
	theForm.center_calc3.value = (theForm.center_n3.value * theForm.center_money3.value);
}
function calcCenter4(){
	var theForm = document.theForm;
	theForm.center_calc4.value = (theForm.center_n4.value * theForm.center_money4.value);
}
function calcCenter5(){
	var theForm = document.theForm;
	theForm.center_calc5.value = (theForm.center_n5.value * theForm.center_money5.value);
}
function totalCenter(){
	var theForm = document.theForm;
	theForm.center_total_calc.value = (theForm.center_calc5.value *1)+( theForm.center_calc4.value*1)
	+( theForm.center_calc3.value*1)+( theForm.center_calc2.value*1)+( theForm.center_calc1.value*1);
}
function totalCenterN1(){
	var theForm = document.theForm;
	theForm.center_total_n.value = (theForm.center_n5.value *1)+( theForm.center_n4.value*1)
	+( theForm.center_n3.value*1)+( theForm.center_n2.value*1)+( theForm.center_n1.value*1);
}
function totalCenterSQFT(){
	var theForm = document.theForm;
	theForm.center_total_sqrt.value = (theForm.center_sqft5.value*theForm.center_n5.value)+( theForm.center_sqft4.value*theForm.center_n4.value)
	+( theForm.center_sqft3.value*theForm.center_n3.value)+( theForm.center_sqft2.value*theForm.center_n2.value)+( theForm.center_sqft1.value*theForm.center_n1.value);
}


function calcIndustrial1(){
	var theForm = document.theForm;
	theForm.industrial_calc1.value = (theForm.industrial_n1.value * theForm.industrial_money1.value);
}
function calcIndustrial2(){
	var theForm = document.theForm;
	theForm.industrial_calc2.value = (theForm.industrial_n2.value * theForm.industrial_money2.value);
}
function calcIndustrial3(){
	var theForm = document.theForm;
	theForm.industrial_calc3.value = (theForm.industrial_n3.value * theForm.industrial_money3.value);
}
function calcIndustrial4(){
	var theForm = document.theForm;
	theForm.industrial_calc4.value = (theForm.industrial_n4.value * theForm.industrial_money4.value);
}
function calcIndustrial5(){
	var theForm = document.theForm;
	theForm.industrial_calc5.value = (theForm.industrial_n5.value * theForm.industrial_money5.value);
}
function totalIndusrial(){
	var theForm = document.theForm;
	theForm.industrial_total_calc.value = (theForm.industrial_calc5.value *1)+( theForm.industrial_calc4.value*1)
	+( theForm.industrial_calc3.value*1)+( theForm.industrial_calc2.value*1)+( theForm.industrial_calc1.value*1);
}
function totalIndustrialN1(){
	var theForm = document.theForm;
	theForm.industrial_total_n.value = (theForm.industrial_n5.value *1)+( theForm.industrial_n4.value*1)
	+( theForm.industrial_n3.value*1)+( theForm.industrial_n2.value*1)+( theForm.industrial_n1.value*1);
}
function totalIndustrialSQFT(){
	var theForm = document.theForm;
	theForm.industrial_total_sqft.value = (theForm.industrial_sqft5.value *theForm.industrial_n5.value)+( theForm.industrial_sqft4.value*theForm.industrial_n4.value)
	+( theForm.industrial_sqft3.value*theForm.industrial_n3.value)+( theForm.industrial_sqft2.value*theForm.industrial_n2.value)+( theForm.industrial_sqft1.value*theForm.industrial_n1.value);
}

