

function startClock() {
        timeRemaining();
}
function string(number) {
        var tempnum;

        tempnum= Math.round(number)+" ";
        tempnum= tempnum.substring(0,tempnum.length-1);

        if (tempnum.length >3) {
        tempnum = tempnum.substring(0,tempnum.length-3) + "," + tempnum.substring(tempnum.length-3, 99);
        }
        if (tempnum.length >7) {
        tempnum = tempnum.substring(0,tempnum.length-7) + "," + tempnum.substring(tempnum.length-7, 99);
        }
        if (tempnum.length >11) {
        tempnum = tempnum.substring(0,tempnum.length-11) + "," + tempnum.substring(tempnum.length-11, 99);
        }

        if (tempnum.length == 11) {
                tempnum = "  " + tempnum;
        }
        if (tempnum.length == 10) {
                tempnum = "   " + tempnum;
        }
        if (tempnum.length == 9) {
                tempnum = "   " + tempnum;
        }
        if (tempnum.length == 7) {
                tempnum = "      " + tempnum;
        }
        if (tempnum.length == 6) {
                tempnum = "       " + tempnum;
        }
        if (tempnum.length == 5) {
                tempnum = "        " + tempnum;
        }
        if (tempnum.length == 3) {
                tempnum = "          " + tempnum;
        }
        if (tempnum.length == 2) {
                tempnum = "           " + tempnum;
        }
        if (tempnum.length == 1) {
                tempnum = "            " + tempnum;
        }
        return tempnum;
}


function timeRemaining() {

        var now = new Date();                                
        var newyears = new Date("January 1, 2000");
        var todaysdate = new Date("January 1, 2000");
        var may4 = new Date("May 4, 1999");
         
        var currentPop;
        var BirthsInYear;

        newyears.setFullYear(now.getFullYear());

        secsSince = Math.round(now.getTime() - newyears.getTime())/1000;
        secsSincePop = Math.round(now.getTime() - may4.getTime())/1000;
          
        todaysdate.setMonth(now.getMonth());
        todaysdate.setDate(now.getDate());
        todaysdate.setFullYear(now.getFullYear());
        secsToday = (now.getTime()-todaysdate.getTime())/1000;


// test to see what page is loaded, then activate the appropriate worldometers
// NOTE: if you startup more than 20, they go to slow

switch (document.title) {
   case 'Worldometers - real time world statistics':
   {    
        // population
        current_population = string(secsSincePop * 2.69 + 5965370016);
        births_this_year = string((secsSince) * 4.11);
        births_today = string((secsToday) * 4.11);
        dth1s_this_year = string((secsSince) * 1.69);
        dth1s_today = string((secsToday) * 1.69);
		absolute_growth = string((secsToday) * 2.42);
      
        document.worldometers.elements["current_population"].value = current_population;
        document.worldometers.elements["births_this_year"].value = births_this_year;
        document.worldometers.elements["births_today"].value = births_today;
        document.worldometers.elements["dth1s_this_year"].value = dth1s_this_year;
        document.worldometers.elements["dth1s_today"].value = dth1s_today;
		document.worldometers.elements["absolute_growth"].value = absolute_growth;

     // econ
   




     // enviornment
     forest_loss = string((secsSince) * .36);
     soil_erosion = string((secsSince) * .2);
     topsoil_erosion = string((secsSince) * 747.5);
     co2_emissions = string((secsSince) * 708);
     desert_land_formed = string((secsSince) * .47);
     human_biological_waste = string((secsSince) * 4.123148);
     fish_caught = string((secsSince) * 2.9);
     
     document.worldometers.elements["forest_loss"].value = forest_loss;
     document.worldometers.elements["soil_erosion"].value = soil_erosion;
     document.worldometers.elements["topsoil_erosion"].value = topsoil_erosion;
     document.worldometers.elements["co2_emissions"].value = co2_emissions;
     document.worldometers.elements["desert_land_formed"].value = desert_land_formed;
     document.worldometers.elements["human_biological_waste"].value = human_biological_waste;
     document.worldometers.elements["fish_caught"].value = fish_caught;

     // food

	 dth1_hunger = string((secsToday) * 0.33);
     spending_on_weight_loss = string((secsSince) * 1078);
     

	 document.worldometers.elements["dth1_hunger"].value = dth1_hunger;
     document.worldometers.elements["spending_on_weight_loss"].value = spending_on_weight_loss;
	 
	      // water
     water_consumed = string((secsSince) * .133);
	      water_disax = string((secsSince) * 0.16);
	  nowater_population = string(secsSince * 5.28 + 1300370016);

     
     document.worldometers.elements["water_consumed"].value = water_consumed;
	 document.worldometers.elements["water_disax"].value = water_disax;
     document.worldometers.elements["nowater_population"].value = nowater_population;
     
        // energy
energy_production = string((secsSince) * 377.9);
energy_consumption = string((secsSince) * 358.3);
oil_consumption = string((secsSince) * 138.174);
coal_consumption = string((secsSince) * 114.63);
solar_energy = string((secsSince) * 86899);

document.worldometers.elements["energy_production"].value = energy_production;
document.worldometers.elements["energy_consumption"].value = energy_consumption;
document.worldometers.elements["oil_consumption"].value = oil_consumption;
document.worldometers.elements["coal_consumption"].value = coal_consumption;
document.worldometers.elements["solar_energy"].value = solar_energy;

     // health





     break;
   }
}

        timerID = setTimeout("timeRemaining()", 1);
        timerRunning = true;

}
