%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}[1996/12/01]    % LaTeX 2.09 can't be used (nor non-LaTeX)
\ProvidesClass{dyndays}[2004/11/00 v0.1]
\def\class@name{dyndays}%
\GenericInfo{}{\space
 Copyright (c) 2004 ITP TU Berlin.^^J
 Licensed under the LPPL:^^Jhttp://www.ctan.org/tex-archive/macros/latex/base/lppl.txt^^J
 \@gobble
}%
\if@compatibility
  \edef\reserved@a{\errhelp{%
   Change your \string\documentstyle\space statement to
   \string\documentclass\space and rerun.
  }}\reserved@a
  \errmessage{You cannot run \class@name\space in compatability mode}%
  \expandafter\@@end
\fi


%\def\ProvidesPackage#1[#2]{%
% \class@info{Incorporating package #1 [#2].}%
%}%
%%
%% ERRORS AND WARNINGS
%%
\def\class@err#1{\ClassError{\class@name}{#1}\@eha}%
\def\class@warn#1{\ClassWarningNoLine{\class@name}{#1}}%
\def\class@info#1{\ClassInfo{\class@name}{#1}}%
%
%
% Included Packages
%
\LoadClass[10pt]{article}
\RequirePackage{a4}
\RequirePackage[english]{babel}
\RequirePackage{amsmath}
\RequirePackage{amstext}
\RequirePackage{amsfonts}
\RequirePackage{ifthen}
\RequirePackage{fancyheadings}
%
% information corresponding to one specific author
%
\def\@email{}
\def\email#1{%
  \def\@email{not empty} % just a dummy
  \add@info{{Electronic Address: \texttt{#1}}}}
%\def\altaffiliation#1{\add@info{#1}}
%
%
% BUFFERS and corrsponding counters
%
%%%%%%%%%%
%
% the author buffer
%
\def\address{\class@err{Invalid Command -- Please use '\protect\affiliation' instead.}}
\def\@aa@buffer{}
\def\@aa@dummy{}
\def\@aa@buffer@single{}
\newcounter{@aa@count}
\stepcounter{@aa@count}

%
% the address buffer
%
\def\@aff@buffer{}
\def\@aff@buffer@single{}
\def\@aff@buffer@dummy{}
\def\@aa@buffer@dummy{}
\newcounter{@aff@count}
\stepcounter{@aff@count}
\newcounter{@aff@count@dummy}
\stepcounter{@aff@count@dummy}

%
% buffer for additional information
%
\def\@add@buffer{}
\newcounter{@add@count}
\stepcounter{@add@count}
\newcounter{@add@info@count}
\stepcounter{@add@info@count}


\def\speaker#1{\author{\underline{#1}}}
\def\author#1{
  \def\stringA{#1}\def\stringB{count@aff}
  \ifx\stringA\stringB 
  \g@addto@macro\@aa@buffer{\stepcounter{@aa@count}}
  \else

    \def\stringA{#1}\def\stringB{count@add@info}
    \ifx\stringA\stringB 
        % adding sign for email etc.
        \g@addto@macro\@aa@buffer{$^\fnsymbol{@add@count}$}
        \g@addto@macro\@aa@buffer{\stepcounter{@add@count}}  
        \g@addto@macro\@aa@buffer@single{$^\fnsymbol{@add@count}$}
        \g@addto@macro\@aa@buffer@single{\stepcounter{@add@count}}  
    \else
      \ifx\@aa@buffer\empty % at first occurence of author/speaker do
         \def\@aa@dummy{not empty anymore} % yes it's a dummy again
        \g@addto@macro\@aa@buffer{\mbox{#1}$^\arabic{@aa@count}$}
        \g@addto@macro\@aa@buffer@single{\mbox{#1}}
       \else  % if its not the first occurence do (add comma)

         \g@addto@macro\@aa@buffer{, \mbox{#1}$^\arabic{@aa@count}$}
         \g@addto@macro\@aa@buffer@single{, \mbox{#1}}
     \fi
   \fi
 \fi
}



\def\affiliation#1{%
  \g@addto@macro\@aff@buffer@dummy{\stepcounter{@aff@count@dummy}} %% just count
  \g@addto@macro\@aff@buffer%
  {$^\arabic{@aff@count}$ #1 \par\stepcounter{@aff@count}} 
  \g@addto@macro\@aff@buffer@single{#1 \par} 
  \author{count@aff}
}

\def\add@info#1{%
  \g@addto@macro\@add@buffer%
  {$^\fnsymbol{@add@info@count}$ #1 \par\stepcounter{@add@info@count}} 
  \author{count@add@info}
}


\newboolean{invited@topic}
\def\topiclabel{Topic:}
\def\topicname{%
  \textbf{Please specify a valid Topic!}%
  \class@err{No (or invalid) Topic given}}
\newcommand{\topic}[1]{% topic definitions
 \ifthenelse{\equal{#1}{DS}}{\renewcommand{\topicname}{Dynamical Systems}}{}
 \ifthenelse{\equal{#1}{TSA}}{\renewcommand{\topicname}{Time Series Analysis}}{}
 \ifthenelse{\equal{#1}{PF}}{\renewcommand{\topicname}{Pattern Formation}}{}
 \ifthenelse{\equal{#1}{TFD}}{\renewcommand{\topicname}{Turbulence and Fluid Dynamics}}{}
 \ifthenelse{\equal{#1}{STC}}{\renewcommand{\topicname}{Space Time Chaos}}{}
 \ifthenelse{\equal{#1}{CC}}{\renewcommand{\topicname}{Chaos Control}}{}
 \ifthenelse{\equal{#1}{NSP}}{\renewcommand{\topicname}{Noise and Stochastic Processes}}{}
 \ifthenelse{\equal{#1}{CHS}}{\renewcommand{\topicname}{Chaos in  Hamiltonian Systems}}{}
 \ifthenelse{\equal{#1}{QC}}{\renewcommand{\topicname}{Quantum Chaos}}{}
 \ifthenelse{\equal{#1}{NONSP}}{\renewcommand{\topicname}{Non-equilibrium Statistical Physics}}{}
 \ifthenelse{\equal{#1}{GM}}{\renewcommand{\topicname}{Granular Materials}}{}
 \ifthenelse{\equal{#1}{TF}}{\renewcommand{\topicname}{Traffic Flow}}{}
 \ifthenelse{\equal{#1}{EP}}{\renewcommand{\topicname}{Econophysics}}{}
 \ifthenelse{\equal{#1}{SM}}{\renewcommand{\topicname}{Soft Matter}}{}
 \ifthenelse{\equal{#1}{CN}}{\renewcommand{\topicname}{Complex Networks}}{}
 \ifthenelse{\equal{#1}{CSB}}{\renewcommand{\topicname}{Complex Systems in Biology}}{}
 \ifthenelse{\equal{#1}{ND}}{\renewcommand{\topicname}{Neuro-Dynamics}}{}
 \ifthenelse{\equal{#1}{DOS}}{\renewcommand{\topicname}{Nonlinear Dynamics in Optical Systems}}{}
 \ifthenelse{\equal{#1}{AEN}}{\renewcommand{\topicname}{Applications in Engineering and Nanoscience}}{}
 \ifthenelse{\equal{#1}{CGP}}{\renewcommand{\topicname}{Complex Growth and Dispersal}}{}
 \ifthenelse{\equal{#1}{DB}}{\renewcommand{\topicname}{Discrete Breathers}}{}
 \ifthenelse{\equal{#1}{SNS}}{\renewcommand{\topicname}{Synchronization of Nonlinear Systems}}{}
 \ifthenelse{\equal{#1}{TC}}{\renewcommand{\topicname}{Thermal Conductivity}}{}
 \ifthenelse{\equal{#1}{EPI}}{\renewcommand{\topicname}{Epidemiology and population dynamics}}{}
 \ifthenelse{\equal{#1}{OP}}{\renewcommand{\topicname}{Other}}{}
 \ifthenelse{\equal{#1}{Plenary}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{}%
   \renewcommand{\topicname}{Plenary Invited}}{}

 \ifthenelse{\equal{#1}{Reg}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{}%
   \renewcommand{\topicname}{Talk Invited}}{}
                                %
                                % Minisymposia
                                %
 \ifthenelse{\equal{#1}{MSW}}{%
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}
   \renewcommand{\topicname}{Stability of Nonlinear Waves}}{}
 \ifthenelse{\equal{#1}{MPC}}{%
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Patterns and Control}}{}
 \ifthenelse{\equal{#1}{MT} }{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Turbulence}}{}
 \ifthenelse{\equal{#1}{MCC}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Chaos Control}}{}
 \ifthenelse{\equal{#1}{MNP}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Noise-induced Phenomena}}{}
 \ifthenelse{\equal{#1}{MQD}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Nonlinear Quantum Dynamics}}{}
 \ifthenelse{\equal{#1}{MGM}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Granular Media}}{}
 \ifthenelse{\equal{#1}{MMS}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Multi-agent Systems}}{}
 \ifthenelse{\equal{#1}{MDN}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Dynamical Networks}}{}
 \ifthenelse{\equal{#1}{MDB}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Dynamics in Cell Biology}}{}
 \ifthenelse{\equal{#1}{MND}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Neurodynamics}}{}
 \ifthenelse{\equal{#1}{MOS}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Nonlinear Optical Systems}}{}
 \ifthenelse{\equal{#1}{MAP}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Applications in Technological Processes}}{}
 \ifthenelse{\equal{#1}{MCG}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Complex Growth Phenomena}}{}
 \ifthenelse{\equal{#1}{OM}}{
   \setboolean{invited@topic}{true}
   \renewcommand{\topiclabel}{Minisymposium:}%
   \renewcommand{\topicname}{Other Minisymposium}}{}

}

\def\typename{%
  \textbf{Please specify a valid Type/Preference!}
  \class@err{No (or invalid) Type/Preference given (Oral/Poster/Invited)}}
\def\typelabel{}
\newcommand{\type}[1]{%
        \ifthenelse{\equal{#1}{Poster}}{%
          \renewcommand{\typelabel}{Preference:}
          \renewcommand{\typename}{Poster}
        }{}
        \ifthenelse{\equal{#1}{Oral}}{%
          \renewcommand{\typelabel}{Preference:}
          \renewcommand{\typename}{Oral}
        }{}
        \ifthenelse{\equal{#1}{Invited}}{%
          \renewcommand{\typelabel}{}
          \renewcommand{\typename}{Invited Talk}%
        }{}
}

\AtBeginDocument{
  \pagestyle{fancy}
  %% prevent bad vboxes
  \newlength{\prevheadheight}
  \setlength{\prevheadheight}{\headheight}
  \setlength{\headheight}{2.25 \prevheadheight}
}
\def\check@topic@type#1#2{
  % check if oral/poster selected topics for invited talks
  % \ifthenelse{\equal{#2}{Oral}\OR\equal{#2}{Poster}}{
  % on older systems \or is undefined ...
  \ifthenelse{\equal{#2}{Oral}}{
    \ifthenelse{\boolean{invited@topic}}{%
      \class@err{You have choosen a topic reserved for Invited Talks.^^J! Please make another selection !}
      \def\topiclabel{}
      \def\topicname{\textbf{You have choosen a topic reserved for Invited Talks.}}
      \def\typelabel{}
      \def\typename{}
      }{}
    }{}
  \ifthenelse{\equal{#2}{Poster}}{
    \ifthenelse{\boolean{invited@topic}}{%
      \class@err{You have choosen a topic reserved for Invited Talks.^^J! Please make another selection !}
      \def\topiclabel{}
      \def\topicname{\textbf{You have choosen a topic reserved for Invited Talks.}}
      \def\typelabel{}
      \def\typename{}
      }{}
    }{}

  
  % check if invited people have selected topics for normal talks
  \ifthenelse{\equal{#2}{Invited Talk}}{
    \ifthenelse{\boolean{invited@topic}}{}{
      \class@err{^^J! If you are invited, please select a minisymposium or plenary.^^J! Please make another selection !}
      \def\topiclabel{}
      \def\topicname{\textbf{If you are invited, please select a minisymposium or plenary.}}
      \def\typelabel{}
      \def\typename{}
      }
  }{}
}


\AtEndDocument{
  \check@topic@type\topicname\typename
  \class@info{Found topic '\topicname'}
  \class@info{Found type '\topicname'}
  \chead[]{\bf\large Abstract for Dynamics Days Crete 2006\\}
  \lhead[]{\topiclabel\ \topicname}
  \rhead[]{\typelabel\ \typename}
  \cfoot[]{}
  \lfoot[]{}
  \rfoot[]{}
}
%
%
% FORMATTING THE TITLE
%
\def\maketitle{
   %
   % some error handling at maketitle time
   %
  \ifx\@email\empty\class@err{Please give at least one email address!}\fi
  \ifx\@aff@buffer\empty\class@err{Please give at least one affiliation!}\fi
  \ifx\@aa@dummy\empty\class@err{Please give at least one speaker/author!}\fi

\begin{center}
  \@aff@buffer@dummy\relax
  \@aa@buffer@dummy\relax

%  \ifnum\value{@aff@count@dummy}>1
%       \class@err{author}
%  \fi

  {\bf\large \@title \par}       
  \vskip 1em                         % Vertical space after title.
  \ifnum\value{@aff@count@dummy}>2   % more than one address
    \@aa@buffer\relax
    \vskip 1em                      
    \@aff@buffer\relax
    \ifx\@add@buffer\empty \relax \else \@add@buffer\fi
  \else
    \@aa@buffer@single\relax
    \vskip 1em                      % Vertical space after title.
    \@aff@buffer@single\relax
    \ifx\@add@buffer\empty \relax \else\@add@buffer\fi
  \fi
\end{center} \par


\gdef\@aa@buffer{}
\gdef\@aff@buffer{}
\gdef\@aa@buffer@single{}
\gdef\@aff@buffer@single{}
}

%
%
%  now some document wide length's
%
%
% LISTS
%
\let\orig@Itemize =\itemize            
\let\orig@Enumerate =\enumerate
\let\orig@Description =\description
% Zero the vertical spacing parameters
\def\MySpacing{\itemsep=0.25ex\topsep=0.25ex\partopsep=0.25ex\parskip=0.25ex\parsep=0.25ex}
% Redefine the environments in terms of the original values
\renewenvironment{itemize}{\orig@Itemize\MySpacing}{\endlist}
\renewenvironment{enumerate}{\orig@Enumerate\MySpacing}{\endlist}
\renewenvironment{description}{\orig@Description\MySpacing}{\endlist}
% Redefine the environments to the original values
%  \renewenvironment{itemize}{\orig@Itemize}{\endlist}
%  \renewenvironment{enumerate}{\orig@Enumerate}{\endlist}
%  \renewenvironment{description}{\orig@Description}{\endlist}
%
%
% THE BIBLIOGRAPHY
%
\renewenvironment{thebibliography}[1]
{
  \kern 1ex 
  \centerline{\vrule width 0.5\textwidth height 0.1pt}
  \kern 1ex 
  \list{\@biblabel{\@arabic\c@enumiv}}%
  {
    % \itemsep=0ex\topsep=0ex\partopsep=0ex\parskip=0ex\parsep=0ex %
                                % zero space
     \itemsep=1ex\topsep=0ex\partopsep=0ex\parskip=0ex\parsep=0ex %
    \settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \@openbib@code
    \usecounter{enumiv}%
    \let\p@enumiv\@empty
    \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  \sloppy
  \clubpenalty4000
  \@clubpenalty \clubpenalty
  \widowpenalty4000%
  \sfcode`\.\@m}
{\def\@noitemerr
  {\@latex@warning{Empty `thebibliography' environment}}%
  \endlist}
%
%
% FOOTNOTES
%
%
