function startcount() {
        timeRemaining();
}


// make the number into a string

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, 2007");
        var todaysdate = new Date("January 1, 2007");
        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 popcount
// NOTE: if you startup more than 20, they go too slow

switch (document.title) {
   case 'Solution to overpopulation in 3rd world countries is Family Planning':
   {    
        // population
        current_population = string(secsSincePop * 2.69 + 5965370016);
        births_this_year = string((secsSince) * 4.11);
	births_unwanted_this_year = string((secsSince) * 1.03);
        births_today = string((secsToday) * 4.11);
        deaths_this_year = string((secsSince) * 1.69);
        deaths_today = string((secsToday) * 1.69);
      
        document.popcount.elements["current_population"].value = current_population;
        document.popcount.elements["births_this_year"].value = births_this_year;
	document.popcount.elements["births_unwanted_this_year"].value = births_unwanted_this_year;
        document.popcount.elements["births_today"].value = births_today;
        document.popcount.elements["deaths_this_year"].value = deaths_this_year;
        document.popcount.elements["deaths_today"].value = deaths_today;
        break;
   }

 case 'Dangers of 3rd World Overpopulation. Diseases, Pollution, Terrorism':
   {
     // environment  2.47 acres per hectare
     forest_loss = string(((secsSince) * .36) * 2.47);
     soil_erosion = string(((secsSince) * .2) * 2.47) ;
     topsoil_erosion = string((secsSince) * 747.5);
     co2_emissions = string((secsSince) * 708);
     desert_land_formed = string((secsSince) * .47); 
     //earth_travel = string((secsSince) * 18.5);
     //weight_of_earth = string(6575000+ (secsSince * .0012));
     //age_of_earth = string((secsSince * .000000031)+4500642531);
     //lightning_strikes = string((secsSince) * 100);
     human_biological_waste = string((secsSince) * 4.123148);
     fish_caught = string((secsSince) * 2.9);
     
     document.popcount.elements["forest_loss"].value = forest_loss;
     document.popcount.elements["soil_erosion"].value = soil_erosion;
     document.popcount.elements["topsoil_erosion"].value = topsoil_erosion;
     document.popcount.elements["co2_emissions"].value = co2_emissions;
     document.popcount.elements["desert_land_formed"].value = desert_land_formed;
     //document.popcount.elements["earth_travel"].value = earth_travel;
     //document.popcount.elements["weight_of_earth"].value = weight_of_earth;
     //document.popcount.elements["age_of_earth"].value = age_of_earth;
     //document.popcount.elements["lightning_strikes"].value = lightning_strikes;
     document.popcount.elements["human_biological_waste"].value = human_biological_waste;
     document.popcount.elements["fish_caught"].value = fish_caught;
     break;
   }



}

        timerID = setTimeout("timeRemaining()", 1);
        timerRunning = true;

}
