var monthdays={'January':31,'February':28,'March':31,'April':30,'May':31,'June':30,'July':31,'August':31,'September':30,'October':31,'November':30,'December':31};function isleapyear(n_year){return(n_year%4?0:(n_year%100?1:(n_year%400?0:1)))};var TREE_ITEMS_GEN=[];function gen_dates(n_startyear,n_years){var n_curyear=n_startyear,n_items=0,n_leafs=0,a_curday,n_curday,a_curmonth,a_curyear;var a_root=['Tree demonstration',0,0];while(n_years){a_curyear=[n_curyear,0,0];for(var s_month in monthdays){a_curmonth=[s_month,0,0];n_days_at_month=monthdays[s_month];if(n_days_at_month==28)n_days_at_month+=isleapyear(n_curyear);n_curday=1;while(n_curday<=n_days_at_month){a_curday=['Day '+n_curday];a_curmonth[a_curmonth.length]=a_curday;n_items++;n_curday++;n_leafs++}a_curyear[a_curyear.length]=a_curmonth;n_items++}a_root[a_root.length]=a_curyear;n_curyear++;n_years--;n_items++}n_items++;var s_temp='This tree contains '+n_items+' items and '+n_leafs+' leafs.';var a_temp={'tt':s_temp,'sb':s_temp};a_root[2]=a_temp;TREE_ITEMS_GEN[TREE_ITEMS_GEN.length]=a_root;return n_items};
