college_calculate = function()
{
	var savings = document.getElementById("college_savings").value;
	if ( savings.length == 0 )
	{
		 alert("Please enter your current savings");
		 return;
	}
	savings = fixNumber(savings);
	savings = parseFloat(savings);
	if ( isNaN(savings) )
	{
		 alert("Please enter your current savings as a number");
		 return;
	}

	var deposit = document.getElementById("college_deposit").value;
	if (  deposit.length == 0 )
	{
		 alert("Please enter your yearly contributions");
		 return;
	}
	deposit  = fixNumber(deposit);
	deposit  = parseFloat(deposit);
	if ( isNaN(deposit) )
	{
		 alert("Please enter your yearly contributions as a number");
		 return;
	}

	var cost = document.getElementById("college_cost").value;
	if (  cost.length == 0 )
	{
		 alert("Please enter the current college cost");
		 return;
	}
	cost  = fixNumber(cost);
	cost  = parseFloat(cost);
	if ( isNaN(cost) )
	{
		 alert("Please enter the current college cost as a number");
		 return;
	}
	if ( cost < 0 )
	{
		 alert("Please enter a current college cost >= 0");
		 return;
	}


	var rate = document.getElementById("college_rate").value;
	if (  rate.length == 0 )
	{
		 alert("Please enter an investment rate of return");
		 return;
	}
	rate  = fixNumber(rate);
	rate  = parseFloat(rate);
	if ( isNaN(rate) )
	{
		 alert("Please enter the investment rate of return as a number");
		 return;
	}
	if ( rate < 0 )
	{
		 alert("Please enter an investment rate of return >= 0");
		 return;
	}
	rate = 1 + rate/100;


	var inflation = document.getElementById("college_inflation").value;
	if (  inflation.length == 0 )
	{
		 alert("Please enter an educational inflation rate");
		 return;
	}
	inflation  = fixNumber(inflation);
	inflation  = parseFloat(inflation);
	if ( isNaN(inflation) )
	{
		 alert("Please enter an educational inflation rate");
		 return;
	}
	if ( inflation < 0 )
	{
		 alert("Please enter an educational inflation rate >= 0");
		 return;
	}
	inflation = 1 + inflation/100;


	var children = new Array(4);
	children[0] = parseInt( document.getElementById("college_child1").value);
	children[1] = parseInt( document.getElementById("college_child2").value);
	children[2] = parseInt( document.getElementById("college_child3").value);
	children[3] = parseInt( document.getElementById("college_child4").value);
	

	var res = "<table cellpadding='0' cellspacing='0' class=\"data\">";
	
	res += "<tr><th>Year<th>Starting<br>Savings<th>Education<br>Expenses<br>Child1<th>Education<br>Expenses<br>Child2<th>Education<br>Expenses<br>Child3<th>Education<br>Expenses<br>Child4<th>Interest<br>Earned<th>Yearly<br>Contribution<th>Ending<br>Savings";

	var done = false;
	
	var money = savings;
	var currentCost = cost;
	var y = 0;
	var i;

	while ( !done )
	{
		res += "<tr><td>" + (y+1) + "<td>" + formatDollars(money);

		for (i=0; i<4; i++)
		{
			if ( children[i]+y >= 18 && children[i]+y <= 21 && children[i] != -1 )
			{
				res += "<td>" + formatDollars(currentCost);
				money = money - currentCost;
			}
			else res += "<td>$0";
		}		

		y++;
		done = true;
		for (i=0; i<4; i++)
		{
			if ( children[i] == -1 )
				continue;
			if ( children[i] + y <= 21 )
			{	
				done = false;
				break;
			}
		}

		currentCost *= inflation;
		if ( money > 0 )
		{
			res += "<td>" + formatDollars(money*rate-money);
			money = (money*rate);
		}
		else
			res += "<td>$0";

		money += deposit;
		res += "<td>" + formatDollars(deposit) + "<td>" + formatDollars(money);

	}

	res += "</table>";

	if ( money < 0 )
		res = "Unfortunately, this level of savings will not pay all of your childrens' college costs.<p>" + res;
	else
		res = "Congratulations, at this level of savings you will be able to pay all of your childrens' college costs.<p>" + res;
	
	var x = document.getElementById("college_dt_results");
	x.innerHTML = res;
	x.style.display = "block";

}