//Loan Application Created by Brad Handy, www.bradhandy.com

function CheckApplicationType() {
	if (document.getElementById("ApplicationType").value == "Joint") {
		EnableCoBorrower();
	}else{
		DisableCoBorrower();
	}
}

function EnableCoBorrower() {
	document.getElementById("CoBorrowerDisabled").style.display = "none";
	document.getElementById("CoBorrowerEnabled").style.display = "block";
	
	document.getElementById("CoBorrowerContactInfoDisabled").style.display = "none";
	document.getElementById("CoBorrowerContactInfoEnabled").style.display = "block";

	document.getElementById("CoBorrowerIncomeInfoDisabled").style.display = "none";
	document.getElementById("CoBorrowerIncomeInfoEnabled").style.display = "block";	
}

function DisableCoBorrower() {
	document.getElementById("CoBorrowerEnabled").style.display = "none";
	document.getElementById("CoBorrowerDisabled").style.display = "block";

	document.getElementById("CoBorrowerContactInfoEnabled").style.display = "none";
	document.getElementById("CoBorrowerContactInfoDisabled").style.display = "block";

	document.getElementById("CoBorrowerIncomeInfoEnabled").style.display = "none";
	document.getElementById("CoBorrowerIncomeInfoDisabled").style.display = "block";
	
	document.getElementById("CoBorrowerContactInfoSameAsBorrower").checked = false;
	CheckCoBorrowerContactInfoSameAsBorrower();
}

function CheckBorrowerMailingSameAsPresent() {
	if (document.getElementById("BorrowerMailingAddressSame").checked == true) {
		document.getElementById("BorrowerMailingAddress").style.display = "none";
		document.getElementById("BorrowerMailingAddressDisabled").style.display = "block";
	}else{
		document.getElementById("BorrowerMailingAddressDisabled").style.display = "none";
		document.getElementById("BorrowerMailingAddress").style.display = "block";		
		document.getElementById("BorrowerMailingStreet").value = "";
		document.getElementById("BorrowerMailingCity").value = "";
		document.getElementById("BorrowerMailingState").value = "";
		document.getElementById("BorrowerMailingZip").value = "";			
	}
}

function CheckCoBorrowerMailingSameAsPresent() {
	if (document.getElementById("CoBorrowerMailingAddressSame").checked == true) {
		document.getElementById("CoBorrowerMailingAddress").style.display = "none";
		document.getElementById("CoBorrowerMailingAddressDisabled").style.display = "block";
	}else{
		document.getElementById("CoBorrowerMailingAddressDisabled").style.display = "none";
		document.getElementById("CoBorrowerMailingAddress").style.display = "block";		
		document.getElementById("CoBorrowerMailingStreet").value = "";
		document.getElementById("CoBorrowerMailingCity").value = "";
		document.getElementById("CoBorrowerMailingState").value = "";
		document.getElementById("CoBorrowerMailingZip").value = "";			
	}
}

function CheckCoBorrowerContactInfoSameAsBorrower() {
	if (document.getElementById("CoBorrowerContactInfoSameAsBorrower").checked == true) {
		document.getElementById("CoBorrowerContactInfoDifferent").style.display = "none";
		document.getElementById("CoBorrowerContactInfoSame").style.display = "block";
	}else{
		document.getElementById("CoBorrowerContactInfoSame").style.display = "none";
		document.getElementById("CoBorrowerContactInfoDifferent").style.display = "block";		
	}
}

function CheckBorrowerTimeOnJobYears() {
	var Years = document.getElementById("BorrowerTimeOnJobYears").value;
	if (isNaN(Years) == true) {
		alert("Your number of years must be a numeric value only.");
		document.getElementById("BorrowerTimeOnJobYears").focus();
	}else{
		if (Years >= 2) {
			document.getElementById("BorrowerPreviousEmployerInfo").style.display = "none";
		}else{
			document.getElementById("BorrowerPreviousEmployerInfo").style.display = "block";
		}	
	}
}

function CheckCoBorrowerTimeOnJobYears() {
	var Years = document.getElementById("CoBorrowerTimeOnJobYears").value;
	if (isNaN(Years) == true) {
		alert("Your number of years must be a numeric value only.");
		document.getElementById("CoBorrowerTimeOnJobYears").focus();
	}else{
		if (Years >= 2) {
			document.getElementById("CoBorrowerPreviousEmployerInfo").style.display = "none";
		}else{
			document.getElementById("CoBorrowerPreviousEmployerInfo").style.display = "block";
		}	
	}
}

function CheckCoBorrowerYearsAtPresentAddress() {
	var Years = document.getElementById("CoBorrowerYearsAtPresentAddress").value;
	if (isNaN(Years) == true) {
		alert("Your number of years must be a numeric value only.");
		document.getElementById("CoBorrowerYearsAtPresentAddress").focus();
	}else{
		if (Years >= 2) {
			document.getElementById("CoBorrowerPreviousAddressEnabled").style.display = "none";
			document.getElementById("CoBorrowerPreviousAddressDisabled").style.display = "block";
		}else{
			document.getElementById("CoBorrowerPreviousAddressDisabled").style.display = "none";
			document.getElementById("CoBorrowerPreviousAddressEnabled").style.display = "block";
		}	
	}
}

function CheckBorrowerYearsAtPresentAddress() {
	var Years = document.getElementById("BorrowerYearsAtPresentAddress").value;
	if (isNaN(Years) == true) {
		alert("Your number of years must be a numeric value only.");
		document.getElementById("BorrowerYearsAtPresentAddress").focus();
	}else{
		if (Years >= 2) {
			document.getElementById("BorrowerPreviousAddressEnabled").style.display = "none";
			document.getElementById("BorrowerPreviousAddressDisabled").style.display = "block";
		}else{
			document.getElementById("BorrowerPreviousAddressDisabled").style.display = "none";
			document.getElementById("BorrowerPreviousAddressEnabled").style.display = "block";
		}	
	}
}

function CheckBorrowerRentOrOwn() {
	if (document.getElementById("BorrowerRentOrOwn").value == "Rent") {
		document.getElementById("BorrowerRentPaymentDiv").style.display = "block";
	}else{
		document.getElementById("BorrowerRentPaymentDiv").style.display = "none";
	}
}


function CheckPurposeOfLoan() {
	if (document.getElementById("PurposeOfLoan").value == "Refinance") {
		document.getElementById("RefinanceOnlyDiv").style.display = "block";
	}else{
		document.getElementById("RefinanceOnlyDiv").style.display = "none";
	}
	if (document.getElementById("PurposeOfLoan").value == "Purchase") {
		document.getElementById("PurchaseOnlyDiv").style.display = "block";
	}else{
		document.getElementById("PurchaseOnlyDiv").style.display = "none";
	}


}
