function toString(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);
        }
        return tempnum;
}

function updateCounterDisplay() {

        var now = new Date();
        var newyears = new Date("January 1, 2000");
        newyears.setFullYear(now.getFullYear());
        var todaysdate = new Date("January 1, "+now.getFullYear().toString() ); //2000");      
        var secsSince;
        
        var seconds_in_2008 = 31622400.0;
        var total_birth_count = 15779;
        var single_mother_birth_count = 9070;
        var teen_birth_count = 2180;
        var child_death_count = 253;
        var infant_death_count = 163;
        var high_school_drop_out_count = 6302;
        var married_family_income = 78570;
        var single_mother_family_income = 21531;
        var income_difference = single_mother_family_income - married_family_income;

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

        total_births = toString((secsSince) * (total_birth_count/seconds_in_2008) );
        $('value_total_births').update(total_births);

        single_mother_births = toString((secsSince) * (single_mother_birth_count/seconds_in_2008) );
        $('value_single_mother_births').update(single_mother_births);

        teen_births = toString((secsSince) * (teen_birth_count/seconds_in_2008) );
        $('value_teen_births').update(teen_births);

        child_death = toString((secsSince) * (child_death_count/seconds_in_2008) );
        $('value_child_death').update(child_death);

        infant_death = toString((secsSince) * (infant_death_count/seconds_in_2008) );
        $('value_infant_death').update(infant_death);

        high_school_drop_outs = toString((secsSince) * (high_school_drop_out_count/seconds_in_2008) );
        $('value_high_school_drop_outs').update(high_school_drop_outs);

        median_married_family_income =  ( secsSince * (married_family_income/seconds_in_2008) ).toFixed(2) ;
        $('value_median_married_family_income').update("$"+(new NumberFormat(median_married_family_income).toFormatted()) );

        median_single_mother_family_income =  ( secsSince * (single_mother_family_income/seconds_in_2008) ).toFixed(2) ;
        $('value_median_single_mother_family_income').update("$"+(new NumberFormat(median_single_mother_family_income).toFormatted()) );
      
      
        family_income_difference =  (median_single_mother_family_income - median_married_family_income).toFixed(2);//( secsSince * (income_difference/seconds_in_2008) ).toFixed(2) ;
        $('value_family_income_difference').update("$"+(new NumberFormat(family_income_difference).toFormatted()) );
      
}
