function ScrubNumber(F) {
	return(F.value.replace("$", "").replace(",", "").replace(",", "").replace(",", "")-0);
}

function CalculatePayment() {
	var F=document.MCF;

	var Price=parseFloat(ScrubNumber(F.Price));
	var DownPayment=parseFloat(ScrubNumber(F.DownPayment));
	var Principle=Price-DownPayment;

	var Months=parseInt(ScrubNumber(F.Years)*12);
	var MonthlyIntRate=parseFloat(F.InterestRate.value)/1200;
	var MonthlyPayment=0;

	if (MonthlyIntRate==0) {
		MonthlyPayment=Principle/LenMonths;
	} else {
		MonthlyPayment=Principle*(MonthlyIntRate/(1-Math.pow((1+MonthlyIntRate), Months*-1)));
	}

	F.MonthlyPayment.value="$"+Math.round(MonthlyPayment);

	var X, Y;

}

function MortValid(A) {
	var F=document.MCF;
	var Good=1;

	if (F.Price.value=="") {
		if (A==1) {
			alert("Please enter the price of the property.");
			F.Price.focus();
		}
		Good=0;
	}
	if (F.DownPayment.value=="" && Good==1) {
		if (A==1) {
			alert("Please enter the down payment you are going to place on the property.");
			F.DownPayment.focus();
		}
		Good=0;
	}
	if (F.Years.value=="" && Good==1) {
		if (A==1) {
			alert("Please enter the down number of years this mortgage is going to be.");
			F.Years.focus();
		}
		Good=0;
	}
	if (F.InterestRate.value=="" && Good==1) {
		if (A==1) {
			alert("Please enter the annual rate of interest for this mortgage.");
			F.InterestRate.focus();
		}
		Good=0;
	}
	

	if (Good==1) {
		CalculatePayment();
	}
}