\ProvidesPackage{beamerthemeJUB}[2014/03/20]

\definecolor{JOrange}{RGB}{249,142,42}
\definecolor{JBlue}{RGB}{0,67,115}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Outer theme
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useoutertheme[width=.15\paperwidth]{sidebar}
\setlength{\beamer@headheight}{.165\paperheight}
\pgfdeclareimage[width=.33\paperwidth]{large-corner}{large-corner}
\pgfdeclareimage[height=\beamer@headheight]{small-corner}{small-corner}
\setbeamertemplate{sidebar left}{%
\vskip7pt
\insertverticalnavigation{\beamer@sidebarwidth}%
}

\setbeamertemplate{footline}[text line]{%
\insertshortauthor\strut\hfill\insertshorttitle\hfill\insertshortdate\hspace{1em}\insertframenumber/\inserttotalframenumber}

\addtobeamertemplate{frametitle}{}{%
\begin{pgfpicture}
\pgf@relevantforpicturesizefalse
\pgftransformxshift{-\Gm@lmargin}
\pgftransformyshift{\beamer@headheight+18pt}
\pgftext[at=\pgfpoint{\paperwidth}{-\beamer@headheight},right,base]{\pgfuseimage{small-corner}}
\pgfpathmoveto{\pgfpoint{.15\paperwidth}{0pt}}
\pgfpathlineto{\pgfpoint{.15\paperwidth}{-\beamer@headheight}}
\pgfsetlinewidth{3.5pt}
\pgfsetinnerlinewidth{1pt}
\pgfsetinnerstrokecolor{JOrange}
\pgfsetcolor{white}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{.15\paperwidth}{-.23\paperheight}}
\pgfpathlineto{\pgfpoint{.15\paperwidth}{-.97\paperheight}}
\pgfsetlinewidth{1pt}
\pgfsetinnerlinewidth{0pt}
\pgfsetcolor{JOrange}
\pgfusepath{stroke}
\end{pgfpicture}%
\vskip-25pt%
}

\addtobeamertemplate{title page}{%
\usebeamertemplate{title background}%
\vskip .2\paperheight%
}
{}

\newcommand\DoPurpleBackground{%
\pgfpathmoveto{\pgfpointorigin}
\pgfpathrectanglecorners{\pgfpoint{0pt}{0pt}}{\pgfpoint{\paperwidth}{-\paperheight}}
\pgfsetfillcolor{JBlue}
\pgfusepath{fill}
}

\setbeamertemplate{title background}{%
\begin{pgfpicture}
\pgf@relevantforpicturesizefalse
\pgftransformxshift{-\Gm@lmargin}
\pgftransformyshift{5.5pt}
\pgfusepath{fill}
\DoPurpleBackground

% Logo

\end{pgfpicture}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inner Theme
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useinnertheme{rectangles}
\setbeamertemplate{navigation symbols}{}

\setlength{\leftmargini}{.5em}
\setlength{\leftmarginii}{1.0em}
\setlength{\leftmarginiii}{1.5em}
\setlength{\leftmarginiv}{2.0em}
\setlength{\leftmarginv}{2.5em}
\setlength{\leftmarginvi}{3.0em}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colours
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usecolortheme[named=JOrange]{structure}
\usecolortheme{rose}
\setbeamercolor{title page}{fg=white}
\setbeamercolor{logo}{bg=JOrange}
\setbeamercolor{frametitle}{fg=JOrange,bg=JBlue}
\setbeamercolor{section in sidebar}{fg=JOrange}
\setbeamerfont{section in sidebar}{series=\bfseries}
\setbeamercolor{block title}{bg=JBlue!28!white,fg=JBlue}
\setbeamercolor{block body}{bg=JOrange!15!white}

\newcommand\ThankYouFrame{
\begin{frame}[plain,t]
\begin{pgfpicture}
\pgf@relevantforpicturesizefalse
\pgftransformxshift{-\Gm@lmargin}
\pgftransformyshift{5.5pt}
\DoPurpleBackground
\end{pgfpicture}
\end{frame}
}
