var coffeeDataAreaCups = "spanCoffeeCounterCups";
var coffeeDataAreaCaffeine = "spanCoffeeCounterCaffeine";

function CalculateCoffee()
{
	// -- Get the seconds since Jan 1, 1960
	var date = new Date();
	var secondsElapsed = Math.floor(date.getTime()/1000);
	
	// -- Subtract the seconds between Jan 1, 1960 and Jan 1, 2005 to get the seconds between now and Jan 1, 2005 (the start of tracking)
	secondsElapsed -= 1104641740;

	// -- Calculate out the current totals based on the tested average amount of coffee, converted to coffee/second, and using 
	// -- the average caffination of African tropical coffee with weighting for expresso grinding and bioling-down
	var mL = secondsElapsed * 0.0095393518;    // milliliters
	var mg = secondsElapsed * 0.0088738425;    // milligrams of caffeine in the above mL of coffee
	
	// -- Find the number of cups by converting from milliliters
	var cups = mL * 0.00422675282;
	
	// -- Build the counter HTML
	var html1 = "";
	var html2 = "";
	
	html1 += cups.toFixed(1) + " cups of coffee."
	html2 += mg.toFixed(2) + " mg of caffeine.";
	
	// -- Display the counter HTML
	try
	{
		document.getElementById(coffeeDataAreaCups).innerHTML     = html1;
		document.getElementById(coffeeDataAreaCaffeine).innerHTML = html2;
	}
	catch (exception)
	{
		
	}
	
	setTimeout("CalculateCoffee()", 1000);
}

// -- Start it up
WindowOnload(CalculateCoffee);