
var erde= 0.879;  //California Emissions Rate for Delivered Electricity: 0.879 lbs CO2 per kWh.
var eepg= 0.013;  //Average Energy Embedded in One gallon of Water in Southern California (Kwh/gal).
var wtrHadSaved= 852499243.000; //Gallons of Water Had Saved up to (02-22-2011 00:00:00) Comes from the spreadsheet named "" that Wade made.
var wsms= 0.006327877; //Gallons of Water Saving per Millisecond. Comes from the spreadsheet named "" that Wade made.
var dayStarted= new Date ("February 22, 2011 00:00:00").getTime(); //Milliseconds from 1970 to the Starting Date.
var today= new Date().getTime(); //Milliseconds from 1970 to the page loaded.
var incrMilliseconds= today-dayStarted; // The Amount of Milliseconds From the Started Day to the Page is Loaded.

//------------------------------function to get the amount of water saved to show in the couter when the page is loaded as a string---------------

var incrWtrHadSaved= incrMilliseconds*wsms; //Additional Savings from Started Day to the Page is Loaded.
var wst= wtrHadSaved+incrWtrHadSaved; //Water Saved up to the Page is Loaded.
var wstCounter= new String(wst); //Convert the Number into a String to add Commas.
var wstCounter1= (wstCounter.substring(0,1)+','); //The next three lines add commas.
var wstCounter2= (wstCounter.substring(1,4)+',');
var wstCounter3= (wstCounter.substring(4,7)+',');
var wstCounter4= (wstCounter.substring(7,10));
wstCounter= wstCounter1+wstCounter2+wstCounter3+wstCounter4; //The String that is going to appear in the counter when the page is loaded.

//-------------------------function to get the amount of energy saved to show in the couter when the page is loaded as a string----------------
var est= wst*eepg; //Energy Saved up to the Page is Loaded.
var estCounter= new String(est); //Convert the Number into a String to add Commas.
var estCounter1= (estCounter.substring(0,2)+','); //The next three lines add commas.
var estCounter2= (estCounter.substring(2,5)+',');
var estCounter3= (estCounter.substring(5,12));
estCounter= estCounter1+estCounter2+estCounter3; //The String that is going to appear in the counter when the page is loaded.

//--------------------function to get the amount of CO2 emmisions saved to show in the couter when the page is loaded as a string----------------

var emst= est*erde; //CO2 Emmisions Saved up to the Page is Loaded.
var emstCounter= new String(emst); //Convert the Number into a String to add Commas.
var emstCounter1= (emstCounter.substring(0,2)+','); //The next three lines add commas.
var emstCounter2= (emstCounter.substring(2,5)+',');
var emstCounter3= (emstCounter.substring(5,12));
emstCounter= emstCounter1+emstCounter2+emstCounter3; //The String that is going to appear in the counter when the page is loaded.

//-----------------------------------------------------Start counters-------------------------------------------------------------------------
var wtr= wstCounter;
var engy= estCounter;
var emssn= emstCounter;
var t1;
var t2;
var t3;
var timer_is_on= 0;

//-----------------------------------------------------function timeCount-------------------------------------------------------------------------

//-----------------------------------------------------for water----------------------------------------------------------------------------------

function timedCount1()
{
document.getElementById('water').value=wtr;
var wtrR= wtr.replace(/,/g, '');
var wtrN= Number(wtrR);
wtrN=((wtrN+(wsms*158)).toFixed(0));
var wtrS= new String(wtrN);
wtrS1= (wtrS.substring(0,1)+",");
wtrS2= (wtrS.substring(1,4)+",");
wtrS3= (wtrS.substring(4,7)+",");
wtrS4= (wtrS.substring(7,10));
wtrS= wtrS1+wtrS2+wtrS3+wtrS4;
wtr=wtrS;

t1=setTimeout("timedCount1()",158);
}

function timedCount2()
{
//-----------------------------------------------------for energy----------------------------------------------------------------------------------
document.getElementById('energy').value=engy;
var engyR= engy.replace(/,/g, '');
var engyN= Number(engyR);
engyN=((engyN+(wsms*1216*eepg)).toFixed(1));
var engyS= new String(engyN);
engyS1= (engyS.substring(0,2)+",");
engyS2= (engyS.substring(2,5)+",");
engyS3= (engyS.substring(5,12));
engyS= engyS1+engyS2+engyS3;
engy=engyS;

t2=setTimeout("timedCount2()",1216);
}

function timedCount3()
{
//-----------------------------------------------------for emissions----------------------------------------------------------------------------------
document.getElementById('emission').value=emssn;
var emssnR= emssn.replace(/,/g, '');
var emssnN= Number(emssnR);
emssnN=((emssnN+(wsms*1300*eepg*erde)).toFixed(1));
var emssnS= new String(emssnN);
emssnS1= (emssnS.substring(0,2)+",");
emssnS2= (emssnS.substring(2,5)+",");
emssnS3= (emssnS.substring(5,12));
emssnS= emssnS1+emssnS2+emssnS3;
emssn=emssnS;

t3=setTimeout("timedCount3()",1300);
}

function doTimer()
	{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount1();
  timedCount2();
  timedCount3();
  }
}



