% ------------------------------------------------------------------------------
% This is file temls.cls
% Michael Plexousakis <plex@tem.uoc.gr>
% ------------------------------------------------------------------------------
%
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesClass{temls}[2010/08/31 Letter class for TEM v2.0]
%
% ------------------------------------------------------------------------------
% Declare the color and bw options for this class. Also define the boolean
% variable @havecolor for later use.
% ------------------------------------------------------------------------------
%
\RequirePackage{ifthen}
\newboolean{@havecolor}
%
\DeclareOption{color}{\setboolean{@havecolor}{true}\newcommand{\temlogo}{temLogoColor}}
\DeclareOption{bw}{\setboolean{@havecolor}{false}\newcommand{\temlogo}{temLogoBW}}
%
% ------------------------------------------------------------------------------
% All other options are passed to the letter class which is loaded with the
% a4paper option
% ------------------------------------------------------------------------------
%
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions\relax
\LoadClass[a4paper]{letter}
%
% ------------------------------------------------------------------------------
% Require the graphicx package for including the letterhead, the geometry
% package for the page layout and the color package for colored text.
% ------------------------------------------------------------------------------
%
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage[a4paper,hmargin=16.1mm,top=16.1mm,bottom=32mm,
                nomarginpar,includeheadfoot]{geometry}
%
% ------------------------------------------------------------------------------
% Commands providing name, title, phone number, fax, email, www and the sigfile
% ------------------------------------------------------------------------------
%
\newcommand{\fax}[1]{\renewcommand{\@fax}{#1}}
\newcommand{\email}[1]{\renewcommand{\@email}{#1}}
\newcommand{\www}[1]{\renewcommand{\@www}{#1}}
\newcommand{\sigfile}[1]{\def\@sigfile{#1}}
%
\newcommand{\@fax}{}
\newcommand{\@email}{}
\newcommand{\@www}{}
\sigfile{}
%
% ------------------------------------------------------------------------------
% The footer entries appear in 8 pt Helvetica font. If havecolor = true then
% some parts appear in a light blue color
% ------------------------------------------------------------------------------
%
\newcommand{\@iix}{\fontsize{8}{12}\usefont{T1}{phv}{m}{n}}
\ifthenelse{\boolean{@havecolor}}{%
   \definecolor{lblue}{rgb}{0.2,0.45,1}}{\definecolor{lblue}{rgb}{0,0,0}}
%
% ------------------------------------------------------------------------------
% The letterhead box
% ------------------------------------------------------------------------------
%
\newsavebox{\@tlh}
\sbox{\@tlh}{\parbox[b]{\textwidth}{\includegraphics[height=1in]{\temlogo}}}
%
% ------------------------------------------------------------------------------
% Redefine the firstpage page style
% ------------------------------------------------------------------------------
%
\renewcommand{\ps@firstpage}{%
   \setlength{\headheight}{73pt}\setlength{\headsep}{25pt}\setlength{\footskip}{40pt}%
   \renewcommand{\@oddhead}{\usebox{\@tlh}}%
   \renewcommand{\@oddfoot}{\parbox[b]{\textwidth}{%
      \hrule\vskip6pt{\@iix\textcolor{lblue}{Email} \@email{} $|$ %
      \textcolor{lblue}{Tel} \telephonenum{} $|$ \textcolor{lblue}{Fax} \@fax{} $|$ %
      University of Crete, Department of Applied Mathematics, Knossos Ave.,
      Heraklion 71409 Greece $|$ \textcolor{lblue}{\@www}}}%
   }%
   \renewcommand{\@evenhead}{}%
   \renewcommand{\@evenfoot}{}%
}
%
% ------------------------------------------------------------------------------
% Redefine the headings page style
% ------------------------------------------------------------------------------
%
\renewcommand{\ps@headings}{%
   \setlength{\headheight}{12pt}\setlength{\headsep}{25pt}%
   \renewcommand{\@oddhead}{%
      \parbox{\textwidth}{\slshape\headtoname{} \toname\hfill\@date\hfill\pagename{} \thepage}}%
   \renewcommand{\@evenhead}{\@oddhead}%
   \renewcommand{\@oddfoot}{}\renewcommand{\@evenfoot}{}%
}
%
% ------------------------------------------------------------------------------
% Redefine the opening command
% ------------------------------------------------------------------------------
%
\renewcommand{\opening}[1]{%
   \thispagestyle{firstpage}%
   {\raggedleft%
    \begin{tabular}{r@{}}\ignorespaces
    \ifx\@empty\fromname\else\fromname \\\fi
    \\*[\parskip]%
    \@date\end{tabular}\par%
   }
   \toname\\\toaddress\\*[2\parskip]%
   #1\par\nobreak
}
%
% ------------------------------------------------------------------------------
% Redefine the closing command
% ------------------------------------------------------------------------------
%
\renewcommand{\closing}[1]{%
   \par\nobreak\vspace{2\parskip}%
   \stopbreaks\noindent
   \parbox{\textwidth}{\raggedright
      \ignorespaces #1\\
      \ifx\@empty\@sigfile\vspace{6\medskipamount}\else\includegraphics{\@sigfile}\\\fi
      \ifx\@empty\fromsig\@fromname\else\fromsig\fi\strut}%
   \par\vspace{2\parskip}%
}
% ------------------------------------------------------------------------------
% Define the pagestyle as headings
% ------------------------------------------------------------------------------
%
\ps@headings
\raggedbottom
%
% end tls.cls
