




function clearQuickMortgageForm(form) {

	document.income.gross.value= '';
			
	document.income.ptax.value= '';
	document.income.heat.value= '';
	document.income.rrsp.value= '';
	document.income.condo.value= '';
	
	document.income.rate.selectedIndex= 0;
	document.income.mortPeriod.selectedIndex= 0;

	document.income.maxExpense.value= '';
	document.income.maxPrice.value= '';
	document.income.tMonthly.value= '';
	
	return false;
	}



function clearFullMortgageForm(form) {

	document.income.price.value= '';
	document.income.dpayment.value= '';
	
	document.income.interest.selectedIndex= 0;
	document.income.time.selectedIndex= 15;

	/*
	document.income.maxExpense.value= '';
	document.income.maxPrice.value= '';
	document.income.tMonthly.value= '';
	*/
	
	return false;
	}



function checkFullMortgageForm(curForm) {

	// Now pull the integer values- and check if they are set.
	var dPayment = parseInt(curForm.dpayment.value);
	var price = parseInt(curForm.price.value);
	

	// Price cannot be empty
	if( isNaN(price) ) {
		alert("Please enter a purchase price for your home.");
		return false;
		}


	// Downpayment cannot be greater than purchase price
	if(price< dPayment)	{
		alert("Your downpayment is greater than the purchase price.\n\nYou can buy your home with cash!");
		return false;
		}

	if(curForm.rate.selectedIndex== 0) {
		alert("Please select a mortgage interest rate.");
		return false;
		}

	if(curForm.period.selectedIndex== 0) {
		alert("Please select a payment period.");
		return false;
		}
	
	}


function checkAmortizationForm(curForm) {

	var dPayment = curForm.dpayment.value;
	var price = curForm.price.value;

	// First two checks on on the string values represented by the price and downpayment
	if(price.indexOf(",") >= 0) {
		alert("Please do not put commas in the Purchase Price.");
		return false;
		}

	if(dPayment.indexOf(",") >= 0) {
		alert("Please do not put commas in the Down Payment number");
		return false;
		}

	if(curForm.periods1.selectedIndex== 0) {
		alert("Please select a mortgage repayment period.");
		return false;
		}

	if(curForm.rate.selectedIndex== 0) {
		alert("Please select a mortgage interest rate.");
		return false;
		}




	// Now pull the integer values- and check if they are set.
	price= parseInt(price);
	dPayment= parseInt(dPayment);

	// Price cannot be empty
	if( isNaN(price) )
		{
		alert("Please enter a purchase price for your home.");
		return false;
		}

	// Downpayment can be empty, but set it to zero if it is.
	if(isNaN(dPayment))
		dpayment= 0;

	// Downpayment cannot be greater than purchase price
	if(price< dPayment)
		{
		alert("Your downpayment is greater than the purchase price.\nYou can buy the home with cash!");
		return false;
		}

	// And must be >0
	if(price<0 || dPayment<0)
		{
		alert("Please use numbers greater than 0.");
		curForm.price.value= 0;
		curForm.dpayment.value= 0;
		return false;
		}




	return true;
	}

	