<!-- hide --
	
/* Resource Clock
Counts the Earth's human population and acres of productive land based on information from the United Nations.

Original script written by Kevin McCann, IDRC, March 1996.
Revised and updated by John Stevenson, jhs@well.com.

This script may be used, but please retain proper credit. Also, be aware
that this script depends on data that is non-static - the starting land
and population numbers, as well as their rates of increase/decrease are
recalculated yearly. Check this site semi-regularly for the latest
numbers.

*/

function counter() {
	
	startpop 	= 	5946422755;
	startland 	=  	8596978646;
	poprate 	= 	2.4452;
	landrate 	= 	0.13035;

	today = new Date();
	startdatepop = new Date("February 1, 1999");
	startdateland = new Date("January 1, 1999");
	offset = today.getTimezoneOffset() * 60 * 1000;

	diffpop = (( today.getTime() + offset ) - startdatepop.getTime() ) / 1000;
	diffland = (( today.getTime() + offset ) - startdateland.getTime() ) / 1000;

	var newpop = Math.ceil(startpop + (diffpop * poprate));
	newpop = "" + newpop;

	var newland = Math.ceil(startland - (diffland * landrate));
	newland = "" + newland;

	a1 = newpop.substring(0,1);
	a2 = newpop.substring(1,4);
	a3 = newpop.substring(4,7);
	a4 = newpop.substring(7,10);

	formpop = a1 + "," + a2 + "," + a3 + "," + a4; 

	b1 = newland.substring(0,1);
	b2 = newland.substring(1,4);
	b3 = newland.substring(4,7);
	b4 = newland.substring(7,10);

	formland = b1 + "," + b2 + "," + b3 + "," + b4;

	/* Revised, Coal etc. NextFusion Pte Ltd */
	thisyear = today.getFullYear();
	startdatethisyear = new Date("January 1," + thisyear);
	timepassed = (( today.getTime() + offset ) - startdatethisyear.getTime() ) / 1000;
	
	fossil_per_sec = 272.704211 // Based on 8.6e9 metric tonnes a year
	energy_per_sec = 85616.438356 // Based on 2.7e12 metric tonnes a year
	co2_per_sec = 761 // Based on 761 metric tonnes a second
	co2_offser_per_sec = 7.927448 // Based on 2.5e8 metric tonnes a year
	var fossil = Math.ceil(timepassed * fossil_per_sec);
	var energy = Math.ceil(timepassed * energy_per_sec);
	var co2 = Math.ceil(timepassed * co2_per_sec);
	var co2_offset = Math.ceil(timepassed * co2_offser_per_sec);
	
	document.getElementById('counter_fossil').innerHTML = addCommas(fossil);
	document.getElementById('counter_energy').innerHTML = addCommas(energy);
	document.getElementById('counter_co2').innerHTML = addCommas(co2);
	document.getElementById('counter_co2_offset').innerHTML = addCommas(co2_offset);
	/* End NXF */
	
	document.getElementById('counter_pop').innerHTML = formpop;
	document.getElementById('counter_land').innerHTML = formland;

	setTimeout('counter()',1000);
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
// -- stop hiding -->
