<!--  Union complet -->

%(
  Copie des fonctions qui se trouvent dans perso.txt dont la SEULE
  modification est que la phrase NE commence PAS par une majuscule.
%)

%define;loc_married_to(sexx, date_place)
  %if;(sexx = 0 or sexx = 2)
    %if;are_married;[married%t to:::date_place]0%nn;
    %elseif;are_not_married;[relationship%t to:::date_place]0%nn;
    %elseif;are_engaged;[engaged%t to:::date_place]0%nn;
    %elseif;is_no_sexes_check;[relationship%t to:::date_place]0%nn;
    %elseif;is_no_mention;date_place [with]%nn;
    %end;
  %else;
    %if;are_married;[married%t to:::date_place]1%nn;
    %elseif;are_not_married;[relationship%t to:::date_place]1%nn;
    %elseif;are_engaged;[engaged%t to:::date_place]1%nn;
    %elseif;is_no_sexes_check;[relationship%t to:::date_place]1%nn;
    %elseif;is_no_mention;date_place [with]%nn;
    %end;
  %end;
%end;

%define;loc_long_married(xx)
  %apply;loc_married_to%with;%xx.sex%and;
    %if;(marriage_place = "")
      %if;(on_marriage_date = "")
      %else; <em>%on_marriage_date;
        %if;wedding_birthday; ([happy birthday to them!])%end;
        </em>
      %end;
    %else;
      %if;(on_marriage_date = "")<em>, %marriage_place;, </em>
      %else; <em>%on_marriage_date;
        %if;wedding_birthday; ([happy birthday to them!])%end;
        , %marriage_place, </em>
      %end;
    %end;
  %end;
%end;

%( 
   ATTENTION: on n'utilise pas max_desc_level parce que c'est extremement
   gourmand sur les gros arbre puisqu'on calcule toute la descendance.
   Hors on n'a besoin de seulement savoir s'il y a des arrière petits
   enfant, d'où le code ci-dessous : 
   1 si on a des enfants
   2 si on a des petits enfants
   3 si on a des arrières petits endants
%)
%reset_count;
%if;has_children;
  %incr_count;
  %foreach;family;
    %foreach;child;
      %foreach;family;
        %if;child.has_children;
          %if;(count<2)
            %incr_count;
          %end;
          %foreach;child;
            %foreach;family;
              %if;child.has_children;
                %if;(count<3)
                  %incr_count;
                %end;
              %end;
            %end;
          %end;
        %end;
      %end;
    %end;
  %end;
%end;


%if;has_families;
  <h3 class="highlight">[*marriage/marriages]1%nn;
    %if;(count>0 and count>1)
      , [child/children]1%nn;
      %if;(count>1 and count>2)
        <span style="font-size: 90%%">, [the grandchildren]</span>
      %else
        <span style="font-size: 90%%"> [and::the grandchildren]</span>
      %end;
      %if;(count>2)
        <span style="font-size: 80%%"> [and::the great-grandchildren]</span>
      %end;
    %else;
      %if;has_children; [and::child/children]1%end;
    %end;
  </h3>
  <ul class="marriage_perso">
    %( On remet les compteurs à zéro et on commence à compter à 1 %)
    %reset_count; %incr_count;
    %foreach;family;
      %apply;li_SD("spouse")
        %if;(wizard)
          <a href="%prefix;m=MOD_FAM;i=%family.index;;ip=%index;">
            <img src="%image_prefix;/picto_molette.png" width="13" height="13" alt="[modify]" title="[modify::family/families]0"%/>%nn;
          </a>
        %end;
        %apply;long_married("self")%sp;
        %apply;long_display_person("spouse")%sp;
        %if;spouse.has_parents;
          <span style="font-size: 90%%"><em> ([*parents] :
            %apply;image_MF("spouse.father","13")
            %apply;short_display_person("spouse.father")
            &nbsp;&amp;&nbsp;
            %apply;image_MF("spouse.mother","13")
            %apply;short_display_person("spouse.mother"))</em>%nn;
          </span>
        %end;
        %if;has_witnesses;
          &nbsp;([witness/witnesses]w :
          %foreach;witness;
            %if;not is_first;, %end;
            %apply;image_MF("witness","13")
            %apply;short_display_person("witness")%nl;
          %end;)
        %end;
        %if;((wizard or friend or bvar.no_note_for_visitor="" or bvar.no_note_for_visitor="no") and has_comment) 
          ([see] <a href="#note-wed-%count;" name="wed-note-%count;" id="wed-note-%count;">[note/notes]0</a>)
          %incr_count;
        %end;
        %if;are_divorced;, [divorced]0%divorce_date;%sp;%end;
        %if;are_separated;, [separated]0%sp;%end;
        %if;has_children;[having as children]0
          %( On sauvegarde l'ancienne valeur de count %)
          %let;prev_count;%count;%in;
          <ul>
            %foreach;child;
              %apply;li_SDC("child")
                %apply;image_MF("child","13")
                %apply;short_display_person("child")
                %if;child.has_families;
                  %foreach;child.family;
                    %if;(family_cnt!=1)
                      <img width="13" height="13"%sp;
                        src="%image_prefix;/1pixel.png"  alt=""%/>%sp;
                      <em>%child;%child.title;%child.dates;</em>
                    %end;
                    <em>&nbsp;%apply;loc_long_married("child")</em>
                    %apply;short_display_person("spouse")
                    %if;(nb_children!=0)
                      &nbsp;[having as children]0
                      <div style="font-size: 90%%">
                        <ul>
                          %foreach;child;
                            %apply;li_SDC("child")
                              %apply;image_MF("child","11")
                              %apply;short_display_person("child")
                              %if;child.has_families;
                                %foreach;child.family;
                                  %if;(family_cnt!=1)
                                    <br%/><img width="10" height="10"%sp;
                                            src="%image_prefix;/1pixel.png" alt=""%/>
                                    <em>%child;%child.title;%child.dates;</em>%nl;
                                  %end;
                                  <em>&nbsp;%apply;loc_long_married("child")</em>
                                  %apply;short_display_person("spouse")
                                  %if;(nb_children!=0)
                                    &nbsp;[having as children]0 :
                                    <div style="font-size: 90%%">%nn;
                                      <ul>
                                        %foreach;child;
                                          %apply;li_SDC("child")
                                            %apply;image_MF("child","10")
                                            %apply;short_display_person("child")
                                          </li>
                                        %end;
                                      </ul>
                                    </div>
                                  %end;
                                %end;
                              %end;
                            </li>
                          %end;
                        </ul>
                      </div>
                    %else;
                     <br/>
                    %end;
                  %end;
                %end;
              </li>
            %end;
          </ul>
          %( On rétablie l'ancienne valeur de count %)
          %apply;init_count(prev_count)
        %end;
        %if;(evar.opt = "from" and wizard)<em>(%origin_file;)</em><br%/>%nl;%end;
      </li>
    %end;
  </ul>
%end;
