%( $Id: deslist_moon.txt mickroue(a)yahoo.fr 20140913 templ=templm %)

%define;moonb(z1,z2)
  %reset_count;
  %foreach;sorted_list_item;
    %if;(prev_item.2 != item.2)
      %reset_count;%incr_count;
      <a href="%prefix;spouse=on;m=RLM;i%count;=%item.3;;t%count;=%count;;%nn;
    %end;
    %if;(prev_item.2 = item.2)
      %incr_count;
      i%count;=%item.3;;t%count;=%count;;%nn;
    %end;
    %if;(next_item.2 != item.2)
      %let;l_top;%expr(item.2 + z1)%in;
      %let;l_width0;%expr(count * l_size)%in;
      %let;l_width;%if;(l_width0 > max_width)%max_width;%else;%l_width0;%end;%in;
      %incr_count;
      i%count;=%index;;t%count;=z2 = %item.2;%nn;
      %if;(max_event >= count)
        " class="s5%item.1;" style="top:%l_top;em;border-width:%l_width;px;">%expr(count - 1)</a>
      %else;
        " style="display:none;"></a>
        <span class="s5%item.1;" style="top:%l_top;em;border-width:%l_width;px;">%count;</span>
      %end;
    %end;
  %end;
%end;

%define;dmoon(z1)
  %reset_count;%reset_desc_level;%empty_sorted_list;
  %apply;dmoona("z1_date.day","z1_date.date.moon_age",3,0,l_v)
  %let;nb_date;%count;%in;
  %let;l_size;%expr(40 / ((90 + nb_date) / 9 / 10))%in;
  <div class="s1 bcbg2" style="height:20px;">
    <strong class="s2">[*z1]</strong>
    <strong class="s3">%nb_date; [date/dates]1</strong>
  </div>
  %if;(version = "6.08 - exp - mr")
  <div class="s1 bcbg1" style="height:320px;">
    <span class="s4" style="top:1em;">[*moon age/new moon/first quarter/full moon/last quarter]1</span>
    <span class="s4" style="top:8em;">[*moon age/new moon/first quarter/full moon/last quarter]2</span>
    <span class="s4" style="top:16em;">[*moon age/new moon/first quarter/full moon/last quarter]3</span>
    <span class="s4" style="top:24em;">[*moon age/new moon/first quarter/full moon/last quarter]4</span>
    %let;l_legend;[*z1], [moon age/new moon/first quarter/full moon/last quarter]0%in;
    %apply;moonb(0,l_legend)
  </div>
  %end;
  %reset_count;%reset_desc_level;%empty_sorted_list;
  %apply;dmoona("z1_date.day","z1_date.date.week_day",1,0,l_v)
  %let;nb_female;%count;%in;
  %let;l_size;%expr(40 / ((40 + nb_date) / 4 / 10))%in;
  %if;(version = "6.08 - exp - mr")
  <div class="s1 bcbg1" style="height:90px;">
    <span class="s4" style="top:1em;">[*(week day)]0</span>
    <span class="s4" style="top:2em;">[*(week day)]1</span>
    <span class="s4" style="top:3em;">[*(week day)]2</span>
    <span class="s4" style="top:4em;">[*(week day)]3</span>
    <span class="s4" style="top:5em;">[*(week day)]4</span>
    <span class="s4" style="top:6em;">[*(week day)]5</span>
    <span class="s4" style="top:7em;">[*(week day)]6</span>
    %let;l_legend;[*z1], [year/month/day]2%in;
    %apply;moonb(1,l_legend)
  </div>
  %end;
  %reset_count;%reset_desc_level;%empty_sorted_list;
  %apply;dmoona("z1_date.day","z1_date.month",0,0,l_v)
  %let;nb_male;%count;%in;
  %let;l_size;%expr(40 / ((40 + nb_date) / 4 / 10))%in;
  <div class="s1 bcbg1" style="height:140px;">
    <span class="s4" style="top:1em;">[*(month)]0</span>
    <span class="s4" style="top:2em;">[*(month)]1</span>
    <span class="s4" style="top:3em;">[*(month)]2</span>
    <span class="s4" style="top:4em;">[*(month)]3</span>
    <span class="s4" style="top:5em;">[*(month)]4</span>
    <span class="s4" style="top:6em;">[*(month)]5</span>
    <span class="s4" style="top:7em;">[*(month)]6</span>
    <span class="s4" style="top:8em;">[*(month)]7</span>
    <span class="s4" style="top:9em;">[*(month)]8</span>
    <span class="s4" style="top:10em;">[*(month)]9</span>
    <span class="s4" style="top:11em;">[*(month)]10</span>
    <span class="s4" style="top:12em;">[*(month)]11</span>
    %let;l_legend;[*z1], [year/month/day]1%in;
    %apply;moonb(0,l_legend)
  </div>
  <div class="s1 bcbg2" style="height:20px;">
    <strong class="s2" style="color:#4682B4;">%nb_male; [M/F]0</strong>
    <strong class="s3" style="color:#FF69B4;">%nb_female; [M/F]1</strong>
  </div>
%end;

%define;dmoona(z1,z2,z3,curlev,maxlev)
  %if;(z1 != "")
    %let;l_y;%z2;%in;
    %if;(z3 = 3 or sex = z3)
      %incr_count;
    %end;
    %apply;add_in_sorted_list(sex,l_y,index)
  %end;
  %foreach;family;
    %if;(curlev < maxlev and family.desc_level = curlev and has_children)
      %family.set_infinite_desc_level;
      %foreach;child;
        %apply;dmoona("z1","z2","z3",curlev+1,maxlev)
      %end;
    %end;
  %end;
%end;

%( tl1 = moon %)
%let;max_width;180%in;
<p>%apply;togen(l_v)</p>
<table class="moon">
  <tr><td>
    %apply;dmoon("birth")
  </td><td>
    %apply;dmoon("death")
  </td></tr>
</table>
