%( $Id: anclist_months.txt mickroue(a)yahoo.fr 20140127 templ=templm %)

%define;lex_month(xx)
  %apply;nth%with;
    /[*(month)]0/[*(month)]1/[*(month)]2/[*(month)]3/[*(month)]4/[*(month)]5/[*(month)]6/[*(month)]7/[*(month)]8/[*(month)]9/[*(month)]10/[*(month)]11%and;
    xx%end;
%end;

%define;monthsc()
  <span class="s4" style="top:3em;">[*(month)]0</span>
  <span class="s4" style="top:4em;">[*(month)]1</span>
  <span class="s4" style="top:5em;">[*(month)]2</span>
  <span class="s4" style="top:6em;">[*(month)]3</span>
  <span class="s4" style="top:7em;">[*(month)]4</span>
  <span class="s4" style="top:8em;">[*(month)]5</span>
  <span class="s4" style="top:9em;">[*(month)]6</span>
  <span class="s4" style="top:10em;">[*(month)]7</span>
  <span class="s4" style="top:11em;">[*(month)]8</span>
  <span class="s4" style="top:12em;">[*(month)]9</span>
  <span class="s4" style="top:13em;">[*(month)]10</span>
  <span class="s4" style="top:14em;">[*(month)]11</span>
%end;

%define;monthsb(z1,z2)
  %reset_count;
  %foreach;sorted_list_item;
    %if;(prev_item.1 != item.1)
      <div class="s1 bcbg1" style="height:160px;">
      <strong style="margin:3px;">%apply;lex_month(item.1)</strong>
      %apply;monthsc()
    %end;      
    %if;(prev_item.1 != item.1 or prev_item.2 != item.2 or prev_item.3 != item.3)
      %reset_count;%incr_count;
      <a href="%prefix;spouse=on;m=RLM;i%count;=%item.4;;t%count;=%count;;%nn;
    %end;
    %if;(prev_item.1 = item.1 and prev_item.2 = item.2 and prev_item.3 = item.3)
      %incr_count;
      i%count;=%item.4;;t%count;=%count;;%nn;
    %end;
    %if;(next_item.1 != item.1 or next_item.2 != item.2 or next_item.3 != item.3)
      %let;l_top;%expr(item.3 + 2)%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;=z1%apply;lex_month(item.1)--z2%apply;lex_month(item.3)%nn;
      %if;(max_event >= count)
        " class="s5%item.2;" style="top:%l_top;em;border-width:%l_width;px;">%expr(count - 1)</a>
      %else;
        " style="display:none;"></a>
        <span class="s5%item.2;" style="top:%l_top;em;border-width:%l_width;px;">%count;</span>
      %end;
      %if;(next_item.1 != item.1)
        </div>
      %end;
    %end;
  %end;
%end;

%define;monthsa(z1,z2,z3,z4)
  %reset_count;
  %empty_sorted_list;
  %foreach;ancestor_level(l_v)
    %if;(level > 1 and (evar.only != "on" or level = l_v))
      %foreach;ancestor;
        %if;(ancestor.same = "" and z1 != "" and z3 != "")
          %incr_count;
          %apply;add_in_sorted_list(z1,z2,z3,z4)
        %end;
      %end;
    %end;
  %end;
%end;

%define;months()
  %if;(evar.tf2 = "1")
    <h3>[year/month/day]1 [birth] = [year/month/day]1 [birth] [spouse/spouses]0 ?</h3>
    %apply;monthsa("ancestor.birth_date.month","ancestor.spouse.sex","ancestor.spouse.birth_date.month","ancestor.spouse.index")
  %elseif;(evar.tf2 = "2")
    <h3>[year/month/day]1 [birth] = [year/month/day]1 [death] [spouse/spouses]0 ?</h3>
    %apply;monthsa("ancestor.birth_date.month","ancestor.spouse.sex","ancestor.spouse.death_date.month","ancestor.spouse.index")
  %elseif;(evar.tf2 = "3")
    <h3>[year/month/day]1 [death] = [year/month/day]1 [death] [spouse/spouses]0 ?</h3>
    %apply;monthsa("ancestor.death_date.month","ancestor.spouse.sex","ancestor.spouse.death_date.month","ancestor.spouse.index")
  %elseif;(evar.tf2 = "4")
    <h3>[year/month/day]1 [death] = [year/month/day]1 [birth] [spouse/spouses]0 ?</h3>
    %apply;monthsa("ancestor.death_date.month","ancestor.spouse.sex","ancestor.spouse.birth_date.month","ancestor.spouse.index")
  %else;
    <h3>[year/month/day]1 [birth] = [year/month/day]1 [death] ?</h3>
    %apply;monthsa("ancestor.birth_date.month","ancestor.sex","ancestor.death_date.month","ancestor.index")
  %end;
  %let;nb_date;%count;%in;
  <p>[*total] = %count; [person/persons]1</p>
  %let;l_size;%expr(120 / ((30 + nb_date) / 3 / 10))%in;
  %let;l_z1;
    %if;(evar.tf2 = "1" or evar.tf2 = "2")%birth_symbol;
    %elseif;(evar.tf2 = "3" or evar.tf2 = "4")%death_symbol;
    %else;%birth_symbol;
    %end;
  %in;
  %let;l_z2;
    %if;(evar.tf2 = "1" or evar.tf2 = "4")x%birth_symbol;
    %elseif;(evar.tf2 = "2" or evar.tf2 = "3")x%death_symbol;
    %else;%death_symbol;
    %end;
  %in
  %apply;monthsb(l_z1,l_z2)
%end;

%( tf1 = months %)
%let;max_width;180%in;
%let;l_url;%prefix;m=A;t=F;i=%index;;v=%l_v;;only=%evar.only;;maxv=%evar.maxv;%in;
<div class="menu">
  <span><a href="%l_url;;tf1=months;tf2=">%birth_symbol; = %death_symbol; ?</a></span>
  <span><a href="%l_url;;tf1=months;tf2=1">%birth_symbol; = x%birth_symbol; ?</a></span>
  <span><a href="%l_url;;tf1=months;tf2=2">%birth_symbol; = x%death_symbol; ?</a></span>
  <span><a href="%l_url;;tf1=months;tf2=3">%death_symbol; = x%death_symbol; ?</a></span>
  <span><a href="%l_url;;tf1=months;tf2=4">%death_symbol; = x%birth_symbol; ?</a></span>
</div>
%apply;gen()
%apply;months()
