\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{uwcsletter}[2004/01/07 v1.0 UWyo CS Dept letterhead]

\LoadClass{letter}
\RequirePackage{graphicx}

\newlength{\uwcs@width}
\setlength{\uwcs@width}{\paperwidth}
\addtolength{\uwcs@width}{-1.26truein}
\newsavebox{\UWCS@lheadhead}%
\sbox{\UWCS@lheadhead}{%
        \begin{minipage}{\uwcs@width}
          \vspace*{-1in}
          \includegraphics[width=2.8truein,height=0.71truein]{uwlogo} \\
          Computer Science \\
          Department  3315 \\
          1000 E. University \\
          Laramie, Wyoming  82071 \\
          \smallskip
          \hrule
        \end{minipage}
  }%

\def\uwcslogo{%
\setlength{\uwcs@width}{\paperwidth}
\addtolength{\uwcs@width}{-\textwidth}
\hspace*{-0.5\uwcs@width}%
\hspace*{0.63truein}%
\usebox{\UWCS@lheadhead}\hfill
}

\def\ps@uwcsfirstpage{%
     \let\@oddhead\uwcslogo
     \def\@oddfoot{\raisebox{-45\p@}[\z@]{%
        \hb@xt@\textwidth{\hspace*{100\p@}%
          \ifcase \@ptsize\relax
             \normalsize
          \or
             \small
          \or
             \footnotesize
          \fi
        \fromlocation \hfill \telephonenum}}\hss}}

\def\ps@uwcsletterhead{%
      \let\@oddhead\uwcslogo
      \def\@oddfoot{}%{\normalfont\hfil\thepage\hfil}
      \def\@evenfoot{}%{\normalfont\hfil-\thepage-\hfil}
      }

\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
  \thispagestyle{uwcsfirstpage}%
    {\raggedleft\@date\par}%
  \else  % home address
    \thispagestyle{uwcsletterhead}%
    {\raggedleft\begin{tabular}{l@{}}\ignorespaces
      \fromaddress \\*[2\parskip]%
      \@date \end{tabular}\par}%
  \fi
  \vspace{2\parskip}%
  {\raggedright \toname \\ \toaddress \par}%
  \vspace{2\parskip}%
  #1\par\nobreak}
