\ProvidesPackage{beamerthemenzcs}[2004/08/30 ver 2.21]
\NeedsTeXFormat{LaTeX2e}[1995/12/01]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2004 by Nigel Stanger <nstanger@infoscience.otago.ac.nz>.
% Based on beamerthemesplit.sty copyright 2003 Till Tantau <tantau@cs.tu-berlin.de>.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Load in the NZCS banner graphic.
%
\pgfdeclareimage[width=12.8cm,height=1.39cm]{banner}{NZCSbanner}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Set up NZCS colours. For some reason the CMYK versions come out looking nothing
% like what they should, so we'll use RGB instead.
%
% \definecolor{nzcsdarkorange}{cmyk}{0.12,0.61,0.97,0}
% \definecolor{nzcslightorange}{cmyk}{0.05,0.45,0.74,0}
% \definecolor{nzcspurple}{cmyk}{0.68,0.97,0.65,0}
\definecolor{nzcsdarkorange}{rgb}{0.878,0.388,0.028}
\definecolor{nzcslightorange}{rgb}{0.945,0.549,0.259}
\definecolor{nzcspurple}{rgb}{0.322,0.031,0.349}

% Set beamer to use NZCS colours where appropriate.
\definecolor{beamerstructure}{rgb}{0.322,0.031,0.349}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Other miscellaneous colours.
%
\definecolor{lavender}{cmyk}{0.48,0.61,0.35,0}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Set up frame footer components.
%
\def\insertfooterleft{}
\def\insertfootercenter{}
\def\insertfooterright{}

\newcommand{\footerleft}[1]{\renewcommand{\insertfooterleft}{#1}}
\newcommand{\footercenter}[1]{\renewcommand{\insertfootercenter}{#1}}
\newcommand{\footerright}[1]{\renewcommand{\insertfooterright}{#1}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Create a frame title that's split over two lines, with the first line
% normal size and the second line small text (used for, e.g., references).
%
\newcommand{\frametitlesub}[2]{%
  \frametitle{\parbox[t]{\textwidth}{#1 \\ \normalfont\tiny #2}}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Highlight a piece of text using the alert colour and also by drawing a
% frame around it. We need to ensure that the "unhighlighted" version is
% drawn in a box of the same height as the "highlighted" version. Thus the
% use of \boxheight, \boxdepth and \boxtotalheight to control things.
%
% We draw the "unhighlighted" version as is. We draw the "highlighted"
% version in a box of the same height by using \raisebox to make TeX think
% that the framed text is actually the same height as the original text
% (we don't raise the text at all).
%
% Since different texts will have different ascenders and descenders, we
% insert a strut to ensure that all the frames come out with the same total
% height.
%
% Note that the frame will always be drawn in the handout, but the alert
% colour won't.
%
\newlength{\boxheight}
\settoheight{\boxheight}{Abdfghjklpqty()}
\newlength{\boxdepth}
\settodepth{\boxdepth}{Abdfghjklpqty()}
\newlength{\boxtotalheight}
\setlength{\boxtotalheight}{\boxheight}
\addtolength{\boxtotalheight}{\boxdepth}

\newcommand<>{\BoxHighlight}[2][beameralert]{%
  \setlength{\fboxsep}{1pt}%
  \alt#3{\textcolor<handout:0>{#1}{\raisebox{0pt}[\boxheight][\boxdepth]{\framebox[\width]{\rule[-\boxdepth]{0pt}{\boxtotalheight}#2}}}}{#2}%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Title page  
%
\usetitlepagetemplate{%
  \vbox{}%
  \vfill%
  \begin{centering}%
    \Large\structure{\inserttitle}%
    \vskip1em\par%
    \normalsize\insertauthor\vskip1em\par%
    {\scriptsize\insertinstitute\par}\par\vskip1em%
    \insertdate\par\vskip1.5em%
    \inserttitlegraphic%
  \end{centering}%
  \vfill%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Frametitles
%
\useframetitletemplate{%
  \vskip8pt%
  {\leftskip-\beamer@leftmargin\advance\leftskip by0.3cm%
   \rightskip-\beamer@rightmargin plus1fil\advance\rightskip by0.3cm\leavevmode%
    \color{beamerstructure}%
    \Large\textbf{\insertframetitle}\par}%
  }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Sections in headline
%
\usesectionheadtemplate%
  {\hfill\color{beamerstructure}\tiny\textbf{\insertsectionhead}}%
  {\hfill\color{nzcsdarkorange!75!beamerstructure}\tiny\textbf{\insertsectionhead}}

\usesubsectionheadtemplate%
  {\color{beamerstructure}\tiny\textbf{\insertsubsectionhead}}%
  {\color{nzcsdarkorange!75!beamerstructure}\tiny\textbf{\insertsubsectionhead}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Entries in table of contents
%
\usetemplatetocsection[40!averagebackgroundcolor]%
  {\color{beamerstructure}\large\inserttocsection}

\usetemplatetocsubsection[40!averagebackgroundcolor]%
  {\leavevmode\leftskip=1.5em\color{beamerstructure}\inserttocsubsection\par}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Head. Draws the NZCS banner across the top of the frame, with sections &
% subsections to the right, separated by a vertical rule. Note that sections
% & subsections are limited to about six of each vertically. Any more and you'll
% overflow the vertical limits of the banner. A good incentive to keep the number
% of sections down :)
%
\newbox\headbox
\useheadtemplate{%
  \vbox{%
    \tiny%
    \setbox\headbox=\hbox to 0.7\paperwidth{%
    	\vbox to 1.39cm{\vfil\insertsectionnavigation{0.35\paperwidth}\vfil}%
        {\color{nzcsdarkorange!75!beamerstructure}\vrule width1pt height1.39cm}%
		\vbox to 1.39cm{\vfil\insertsubsectionnavigation{0.35\paperwidth}\vfil}%
		\hfill%
	}%
    \hbox to\paperwidth{%
      {\hskip-\beamer@leftmargin\rlap{\pgfuseimage{banner}}}%
      \hskip 0.3\paperwidth\box\headbox\hfill\hskip-\beamer@rightmargin%
    }%
  }}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Draw a footer line across the page. Uses a similar shading to the NZCS
% banner graphic.
%
\pgfdeclarehorizontalshading{footershading}{0.35cm}%
  {color(0cm)=(nzcslightorange); color(\paperwidth)=(nzcsdarkorange)}
\newbox\linebox
\def\footerline#1{%
  \hbox{%
    \setbox\linebox=\hbox to0.96\paperwidth{\hskip0.02\paperwidth\tiny{#1}\hskip0.02\paperwidth}%
    \ht\linebox=7pt%
    \dp\linebox=0pt%
    \setbox\linebox=\vbox{\box\linebox\vskip3pt}%
    \hskip-\beamer@leftmargin%
    \rlap{\pgfuseshading{footershading}}%
    \box\linebox%
  }%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Footline
%
\usefoottemplate{%
  \vbox{%
    \footerline{%
      \color{black}%
      \makebox[0.32\paperwidth][l]{\insertfooterleft}%
      \makebox[0.32\paperwidth]{\insertfootercenter}%
      \makebox[0.32\paperwidth][r]{\insertfooterright}%
    }}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Background
%
\usebackgroundtemplate{}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Blocks
%
\useblocktemplate{\medskip{\color{beamerstructure}\large{\insertblockname}}\par}{\medskip}
\usealertblocktemplate{\medskip{\alert{\large{\insertblockname}}}\par}{\medskip}
\useexampleblocktemplate{\medskip\begingroup{\color{beamerstructure!50!green}\large{\insertblockname}}\par%
\color{black!50!green}}{\endgroup\medskip}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Highlighting
%
\usealerttemplate{\color{beameralert}}{}


