var c=0;
var d=0;
var co=0;
var s=0;
var n=0;
var rebatecount=0;
var delay=1533;
var today=new Date();
var yesterday=new Date()-1;
var then=new Date(2006,12,20,00,00,00);
var rebateiv=2454333

var saved=Math.floor(((today-then)/(2600))+4415251);

var demand=0.00000022*saved;
var co2=Math.floor(2.2*saved);
var so2=Math.floor(0.016*saved);
var nox=Math.floor(0.069*saved);
var rebate=Math.floor(0.190905*saved+21190);

window.onload=function(){
countup();
}


function countup() {
document.getElementById('kwh').firstChild.nodeValue=addCommas(saved+c);
c++;

document.getElementById('demand').firstChild.nodeValue=(demand+d).toFixed(1);
d=0.00000022*c;

document.getElementById('co2').firstChild.nodeValue=addCommas(Math.floor(1.2*(saved+c)));
co=2.2*c;

//document.getElementById('so2').firstChild.nodeValue=addCommas(Math.floor(so2+s));
s=0.016*c;

//document.getElementById('nox').firstChild.nodeValue=addCommas(Math.floor(nox+n));
n=0.069*c;

document.getElementById('rebate').firstChild.nodeValue=addCommas(Math.floor(rebate+rebatecount));
rebatecount=0.190905*c;

setTimeout('countup()',delay);


}


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;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=345,left = 440,top = 127.5');");
}

function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=100,left = 440,top = 127.5');");
}