%% LaTeX-Beamer template for KIT design
%% by Erik Burger, Christian Hammer
%% title picture by Klaus Krogmann
%%
%% version 2.0
%%
%% mostly compatible to KIT corporate design v2.0
%% http://intranet.kit.edu/gestaltungsrichtlinien.php
%%
%% Problems, bugs and comments to
%% burger@kit.edu

\usepackage{templates/beamerthemekitbase}
\usepackage{lastpage}

%\setbeamertemplate{title page}
%{
%\thispagestyle{empty}

%middle block with name of institute
%\begin{textblock*}{\paperwidth}(1mm,42mm)
%\begin{pgfpicture}{0mm}{0mm}{\paperwidth-2mm}{6mm}
%	\color{black!50}
%	\pgfpathrectangle{\pgfpoint{0mm}{0mm}}{\pgfpoint{\paperwidth-2mm}{6mm}}
%	\pgfusepath{fill}
%	\pgftext[at=\pgfpoint{5mm}{3mm},left,center]{\textcolor{white}{\tiny\uppercase\expandafter{\insertinstitute}}}
%\end{pgfpicture}
%\end{textblock*}


%elements on title page

%KIT logo
%\begin{textblock*}{24mm}(6mm,5mm)
%\iflanguage{english}{%
%\includegraphics[width=23mm]{logos/kitlogo_en_rgb} 
%}{%
%\includegraphics[width=23mm]{logos/kitlogo_de_rgb}
%}%
%\end{textblock*}

%funding logo
%\begin{textblock*}{13mm}(129,5mm)
%\includegraphics[width=13mm]{logos/\@titlefundinglogo} 
%\end{textblock*}

%institute logo
%\begin{textblock*}{39mm}(116mm,5mm)
%\includegraphics[width=13mm]{logos/\@titlelogoc}%
%\includegraphics[width=13mm]{logos/\@titlelogob}%
%\includegraphics[width=13mm]{logos/\@titlelogoa} 
%\end{textblock*}

%title
%\begin{textblock*}{120mm}(6mm,16mm)
%\begin{beamercolorbox}[wd=118mm,ht=14mm,dp=3mm,left]{white}%
%\Large\textbf{\inserttitle}
%\end{beamercolorbox}
%\end{textblock*}

%subtitle
%\begin{textblock*}{120mm}(6mm,33mm)
%\scriptsize \insertsubtitle
%\end{textblock*}

%author
%\begin{textblock*}{120mm}(6mm,37mm)
%\scriptsize\insertauthor~\textbar~\insertshortdate
%\end{textblock*}

%legal KIT text
%\begin{textblock*}{80mm}[0,1](6mm,88.5mm)
%\fontsize{4pt}{6pt}\selectfont
%\iflanguage{english}{
%KIT -- University of the State of Baden-W{\"u}rttemberg and National Laboratory of the Helmholtz Association}
%{KIT -- Die Forschungsuniversität der Helmholtz Gemeinschaft}
%\end{textblock*}

%\begin{textblock*}{16mm}(144mm,87.mm)
%\fontsize{8pt}{8pt}\selectfont
%\bfseries
%\textcolor{white}{
%	\href{http://www.kit.edu}{www.kit.edu}
%}
%\end{textblock*}

% title image

%\begin{textblock*}{\paperwidth}(1.1mm,48.1mm)
%\begin{overpic}[width=157.8mm,height=38.0mm]{logos/\@titleimage}
%\put(-6,-3){
	%mask curve for lower left corner of title image
%	\begin{pgfpicture}{0mm}{0mm}{3mm}{3mm}
%		\pgfpathqmoveto{0mm}{0mm}
%		\pgfpathlineto{\pgfpoint{3mm}{0mm}}
%		\pgfpathlineto{\pgfpoint{3mm}{1mm}}

%		{\pgfsetcornersarced{\pgfpoint{2mm}{2mm}} 
%		\pgfpathlineto{\pgfpoint{1mm}{1mm}}
%		\pgfpathlineto{\pgfpoint{1mm}{3mm}}}

%		\pgfpathmoveto{\pgfpoint{1mm}{3mm}}
%		\pgfpathlineto{\pgfpoint{0mm}{3mm}}
%		\pgfpathlineto{\pgfpoint{0mm}{0mm}}
%		\pgfpathclose

%		\color{black!15}
%		\pgfusepath{fill}
%	\end{pgfpicture}
%}
%\end{overpic}
%\end{textblock*}
%}

%background for pages
%CH: for plain frames
\newlength{\kitbottom}
\usebackgroundtemplate{
	\setlength{\kitbottom}{\ifbeamer@plainframe1mm\else4mm\fi}%
\begin{pgfpicture}{0mm}{0mm}{\paperwidth}{\paperheight}

	{\pgfsetcornersarced{\pgfpoint{2mm}{2mm}}
	\pgfpathmoveto{\pgfpoint{\paperwidth-1mm}{\kitbottom}}
	\pgfpathlineto{\pgfpoint{1mm}{\kitbottom}}
	\pgfpathlineto{\pgfpoint{1mm}{\paperheight-1mm}}}

	{\pgfsetcornersarced{\pgfpoint{2mm}{2mm}}
	\pgfpathmoveto{\pgfpoint{1mm}{\paperheight-1mm}}
	\pgfpathlineto{\pgfpoint{\paperwidth-1mm}{\paperheight-1mm}}
	\pgfpathlineto{\pgfpoint{\paperwidth-1mm}{\kitbottom}}}

	\color{white} %couleur du fond
	\pgfusepath{fill}

\end{pgfpicture}%
}

%frametitle
\setbeamertemplate{frametitle}{
\vspace{2mm} %\hspace*{-4mm}
%\vbox{\hsize=9cm\bfseries\insertframetitle}
\vbox{\hsize=15cm\bfseries\insertframetitle}
%\begin{textblock*}{15mm}(142mm,4mm)
%\iflanguage{english}{%
%\includegraphics[width=14mm]{logos/kitlogo_en_rgb} 
%}{%
%\includegraphics[width=14mm]{logos/kitlogo_de_rgb} 
%}%
%\end{textblock*}
}

%\setbeamercolor{section in foot}{fg=white, bg=indigo}

%footer
\setbeamertemplate{footline}{
\vskip.4mm
\begin{beamercolorbox}[leftskip=.5em,ht=1mm,dp=1.3mm]{section in foot}
% \color{white}{ \hspace{1.3em}\usebeamerfont{author in head/foot}%
%  \insertshorttitle \hspace*{1mm} - \hspace*{1mm} \insertshortauthor
%  \hfill\insertshortdate\hspace{30pt}\insertframenumber{}/\inserttotalframenumber}\hspace{4mm}
 \color{white}{\hspace{.2cm}\insertsectionhead \hfill \insertframenumber{}/\inserttotalframenumber}\hspace{4mm} 
\end{beamercolorbox}}




%\newcommand{\backupbegin}{
%   \newcounter{finalframe}
%   \setcounter{finalframe}{\value{framenumber}}
%}
%\newcommand{\backupend}{
%   \setcounter{framenumber}{\value{finalframe}}
%}
\newcommand{\backupbegin}{
  \newcounter{framenumberappendix}
  \setcounter{framenumberappendix}{\value{framenumber}}
  \setbeamertemplate{footline}{}
}
\newcommand{\backupend}{
  \addtocounter{framenumberappendix}{-\value{framenumber}}
  \addtocounter{framenumber}{\value{framenumberappendix}}
  \setbeamertemplate{footline}{
    \vspace{-1cm}\small{\insertframenumber/\inserttotalframenumber}
  }
}