function calculate()
{  


	var miles = document.getElementById("miles").value;
	if ( miles.length == 0 )
	{
		 alert("Please enter commute distance in miles (one way).");
		 return;
	}
	miles = fixNumber(miles);
	miles = parseFloat(miles);
	if ( isNaN(miles) )
	{
		 alert("Please enter commute distance (miles, one way) as a number");
		 return;
	}
	if ( miles <= 0 )
	{
		 alert("You aren't driving any miles, so you won't be spending anything on gas");
		 return;
	}

	var mpg = document.getElementById("mpg").value;
	if ( mpg.length == 0 )
	{
		 alert("Please enter the MPG of your current vehicle.");
		 return;
	}
	mpg = fixNumber(mpg);
	mpg = parseFloat(mpg);
	if ( isNaN(mpg) )
	{
		 alert("Please enter the MPG of your current vehicle as a number.");
		 return;
	}
	if ( mpg <= 0 )
	{
		alert("Please enter an MPG greater than 0, unless you're riding a bike, in which case you don't spend anything on your commute. Congratulations!")
		return;
	}
	
	var cost = document.getElementById("cost").value;
	if ( cost.length == 0 )
	{
		 alert("Please enter the cost of a gallon of gas");
		 return;
	}
	cost = fixNumber(cost);
	cost = parseFloat(cost);
	if ( isNaN(cost) )
	{
		 alert("Please enter the cost of a gallon of gas as a number");
		 return;
	}
	if ( cost <= 0 )
	{
		 alert("If gas is free, your commute doesn't cost you anything.");
		 return;
	}
	
	var parking = document.getElementById("parking").value;
	if ( parking.length > 0 )
	{
		parking = fixNumber(parking);
		parking = parseFloat(parking);
		if ( isNaN(parking) )
		{
			 alert("Please enter the cost of parking as a number");
			 return;
		}
		if ( parking < 0 )
		{
			parking = 0;
		}
	}

	var costDay = (( 2 * miles / mpg ) * cost) + parking;
	var costWeek = 5 * (costDay);
	var costYear = 250 * (costDay);

	var results = "<p>Your daily commute costs you " + formatDollars(costDay) + " round-trip.</p>";
	results += "<p>A five-day working week will run up " + formatDollars(costWeek) + " in commuting costs.</p>";
	results += "<p>With a 250-workday year, you spend " + formatDollars(costYear) + " per year commuting by car.</p>";

	 
	var x = document.getElementById("results");

	x.innerHTML = results;
	x.style.display = "block";
}

