\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gitoyen}
\RequirePackage[french]{babel}
\RequirePackage[autolanguage]{numprint}
\RequirePackage[T1]{fontenc}
\RequirePackage[latin1]{inputenc}
\RequirePackage{newcent}
\RequirePackage{color}
\RequirePackage{eurosym}
\RequirePackage{graphicx}
\RequirePackage[headheight=2cm]{geometry}
\RequirePackage{url}
\RequirePackage{booktabs}
\RequirePackage{fancyhdr}
\RequirePackage{lastpage}
\RequirePackage{geometry}
\RequirePackage[colorlinks=true,linkcolor=gitoyenlink]{hyperref}
\RequirePackage{sectsty}
\RequirePackage{tabularx}

% General purpose commands
\definecolor{gitoyendark}{rgb}{0.6,0.2,0.2}
\definecolor{gitoyenlink}{cmyk}{1,0,0,0.2}
\newcommand{\Gitoyen}{\textsf{Gitoyen}}

\geometry{a4paper,hmargin=1in,tmargin=2in,bmargin=1.5in,headheight=2cm}
\allsectionsfont{\sffamily}

\def\Gfootersingle{%
{\scriptsize\sf\color{gitoyendark}Gitoyen\hfill
   16, rue de Cachy, 80090 Amiens, France\hfill
   Gitoyen, association sans but lucratif r\'egie par la loi du 1er Juillet 1901\par}}
\def\Gfooter{%
  \Gfootersingle
  \centering \thepage/\pageref{LastPage}%
}

\fancypagestyle{cover}{
  \fancyhf{}%
  \lhead{\includegraphics[height=2cm]{gitoyen-logo}}%
  \lfoot{\Gfooter}
}

\fancypagestyle{single}{
  \fancyhf{}%
  \lhead{\includegraphics[height=2cm]{gitoyen-logo}}%
  \cfoot{\Gfootersingle}
}

\fancypagestyle{normal}{
  \fancyhf{}
  \cfoot{\thepage/\pageref{LastPage}}%
}

\let\headrule\empty
% Do nice titles
\def\docnum#1{\gdef\@docnum{#1}}
\def\@docnum{\@latex@error{No \noexpand\docnum given}}

\renewcommand{\maketitle}{%
\pagestyle{normal}
\thispagestyle{cover}
\begin{flushright}
\texttt{\@docnum}, le \@date
\vskip 1em\sf{\color{gitoyendark}\Huge \@title}
\end{flushright}
}

\newcommand{\signatures}{%
\parindent 0pt
\vskip 3em
\ifx\GSignataire\undefined
  \def\GSignataire{Philippe Le Brouster}%
\fi
\ifx\GPoste\undefined
  \def\GPoste{Président}%
\fi
\begin{tabularx}{\linewidth}{XX}
\toprule
Pour \Nom	& Pour \textsf{Gitoyen}
\\\midrule
Nom \Signataire & Nom \GSignataire\\
Titre \Poste	& Titre \GPoste\\
Date \Date	& Date \Date \\
\midrule
Signature et cachet&Signature et cachet
\\[1.5in]\bottomrule
\end{tabularx}%
}
