function initialize()
	{
	var note= "Do Step 1";
	document.gds.gds.value= note;
	document.gds.tds.value= note;

	document.monthly.gdsTotal.value= note;
	document.monthly.tdsTotal.value= note;
	document.monthly.grandTotal.value= note;

	document.mortgage.gds.value= note;
	document.mortgage.tds.value= note;
	document.mortgage.hExp.value= note;
	document.mortgage.tExp.value= note;
	document.mortgage.gdsMax.value= note;
	document.mortgage.tdsMax.value= note;
	}

function gdsCalc(form)
	{
	totalGross= 0;
	var MAX=10000000;	// 10 million

 	for(j=0; j< document.forms[form].elements.length; ++j)
		{
		// Make sure we reset the total field (gross) to 0 before proceeding with our sums.
		// If we don't we may end up adding in a value from a previous calculation
		if (document.forms[form].elements[j].name== "gross")
			document.forms[form].elements[j].value=0;

		// Only consider those input fields that were of type text. (i.e. ignore input buttons)
		if (document.forms[form].elements[j].type== "text")
			{
			gdsPattern= /gross+/;

			if (gdsPattern.test(document.forms[form].elements[j].name)== true)
				{
				checkNumeric(document.forms[form].elements[j], MAX);
				totalGross+= parseFloat(document.forms[form].elements[j].value);
				}
			}
		}

	// Assign the total value calculations back to the "worth", "debt", & "net" fields in the form
	document.gds.gross.value= totalGross;
	var gds= Math.round(totalGross* 0.32);
	var tds= Math.round(totalGross* 0.40);
	document.gds.gds.value= gds;
	document.gds.tds.value= tds;

	document.mortgage.gds.value= gds;
	document.mortgage.tds.value= tds;

	var note= "Do Step 2";

	document.monthly.gdsTotal.value= note;
	document.monthly.tdsTotal.value= note;
	document.monthly.grandTotal.value= note;

	document.mortgage.hExp.value= note;
	document.mortgage.tExp.value= note;
	document.mortgage.gdsMax.value= note;
	document.mortgage.tdsMax.value= note;
	}


function monthyPayments(form)
	{
	var GDS= 0;
	var TDS= 0;
	var MAX=10000000;	// 10 million

 	for(j=0; j< document.forms[form].elements.length; ++j)
		{
		// Only consider those input fields that were of type text. (i.e. ignore input buttons)
		if (document.forms[form].elements[j].type== "text")
			{
			// Make sure we reset the totals fields (worth, debt, net) to 0 before proceeding with our sums.
			// If we don't we may end up adding in a value from a previous calculation
			if (document.forms[form].elements[j].name== "gdsTotal")
				document.forms[form].elements[j].value=0;
			if (document.forms[form].elements[j].name== "tdsTotal")
				document.forms[form].elements[j].value=0;

			gdsPattern= /gds+/;
			tdsPattern= /tds+/;

			if (gdsPattern.test(document.forms[form].elements[j].name)== true)
				{
				checkNumeric(document.forms[form].elements[j], MAX);
				GDS+= parseFloat(document.forms[form].elements[j].value);
				}

			if (tdsPattern.test(document.forms[form].elements[j].name)== true)
				{
				checkNumeric(document.forms[form].elements[j], MAX);
				TDS+= parseFloat(document.forms[form].elements[j].value);
				}

			}
		}

	// Assign the total value calculations back to the "worth", "debt", & "net" fields in the form
	var GDS= Math.round(GDS);
	var TDS= Math.round(TDS);
	var TOTAL= Math.round(TDS+ GDS);
	document.monthly.gdsTotal.value= GDS;
	document.monthly.tdsTotal.value= TDS;
	document.monthly.grandTotal.value= TOTAL;


	document.mortgage.hExp.value= GDS;
	document.mortgage.tExp.value= TOTAL;

	// Assign the total value calculations back to the "worth", "debt", & "net" fields in the form
	document.mortgage.gdsMax.value= document.mortgage.gds.value- GDS;
	document.mortgage.tdsMax.value= document.mortgage.tds.value- TOTAL;
	}




