\ProvidesPackage{beamerthemeFAB}[2017/09/27]

\RequirePackage{ifthen}

\newif\ifbeamer@serif \beamer@seriffalse
\newif\ifbeamer@boxed \beamer@boxedfalse
\newif\ifbeamer@sb@subsection \beamer@sb@subsectiontrue
\newif\ifbeamer@FAB@footline \beamer@FAB@footlinefalse
\newif\ifbeamer@FABcolour \beamer@FABcolourfalse
\newif\ifbeamer@Instlogo \beamer@Instlogofalse

\newcommand{\instlogo}{}
\newcommand{\FABouter}{FABsimple}
\newcommand{\FABcolour}{UFG}

\DeclareOptionBeamer{FABserif}{\beamer@seriftrue}
\DeclareOptionBeamer{FABboxed}{\beamer@boxedtrue}
\DeclareOptionBeamer{FABnosub}{\beamer@sb@subsectionfalse}
\DeclareOptionBeamer{FABfootline}{\beamer@FAB@footlinetrue}
\DeclareOptionBeamer{compress}{\beamer@compresstrue}
\DeclareOptionBeamer{FABnice}{\renewcommand{\FABouter}{FABnice}}
\DeclareOptionBeamer{FABstruct}{\renewcommand{\FABouter}{FABstruct}}
\DeclareOptionBeamer{FABouter}[nice]{%
  \renewcommand{\FABouter}{#1}%
  \ifthenelse{\equal{#1}{simple}}{\renewcommand{\FABouter}{FABsimple}}{}%
  \ifthenelse{\equal{#1}{nice}}{\renewcommand{\FABouter}{FABnice}}{}%
  \ifthenelse{\equal{#1}{struct}}{\renewcommand{\FABouter}{FABstruct}}{}}
\DeclareOptionBeamer{UFGcolour}{\beamer@FABcolourtrue}
\DeclareOptionBeamer{FABcolour}[UFG]{%
  \beamer@FABcolourtrue%
  \ifthenelse{\equal{#1}{false}}{\beamer@FABcolourfalse}{}%
  \ifthenelse{\equal{#1}{none}}{\beamer@FABcolourfalse}{}%
  \renewcommand{\FABcolour}{#1}}
\DeclareOptionBeamer{UFGlogo}{\beamer@Instlogotrue%
	\renewcommand{\instlogo}{logo-ufg.png}}
\DeclareOptionBeamer{MBIlogo}{\beamer@Instlogotrue%
	\renewcommand{\instlogo}{logo-judaistik.jpg}}
\DeclareOptionBeamer{FABlogo}[UFG]{%
  \beamer@Instlogotrue%
  \renewcommand{\instlogo}{#1}%
  \ifthenelse{\equal{#1}{false}}{\beamer@Instlogofalse}{}%
  \ifthenelse{\equal{#1}{none}}{\beamer@Instlogofalse}{}%
  \ifthenelse{\equal{#1}{UFG}}{\renewcommand{\instlogo}{logo-ufg.png}}{}%
  \ifthenelse{\equal{#1}{MBI}}{\renewcommand{\instlogo}{logo-judaistik.jpg}}{}
  \ifthenelse{\equal{#1}{UK}}{\renewcommand{\instlogo}{logo-UK.png}}{}}
\ProcessOptionsBeamer

\mode<presentation>

\setbeamersize{text margin left= .4in, text margin right= .4in}

\usefonttheme[onlylarge]{structurebold}
% \usefonttheme[onlylarge]{structuresmallcapsserif}
\usefonttheme{professionalfonts}
\ifbeamer@serif%
	\usefonttheme[stillsansseriflarge,stillsansserifsmall]{serif}%
\else%
	\usefonttheme[onlymath]{serif}%
\fi

\usepackage{fixmath,upgreek} %nur mit CM als Mathematikschrift
\usepackage[nomath]{lmodern} %[variablett,lighttt]
\renewcommand*{\rmdefault}{bch} %Charter, serif for screen and low resolution
\newcommand*{\tsc}[1]{\caps{{#1}}}
\renewcommand*{\ttdefault}{cmtt} %CModern TT weniger dünn als LModern
\renewcommand{\bfdefault}{bx}

\setbeamertemplate{sidebar right}{}
\ifbeamer@FAB@footline
	\setbeamertemplate{sidebar left}{\vfill\hspace*{1mm}\insertlogo\vspace*{0.5mm}}
	\setbeamertemplate{sidebar right}{\vfill\llap{%
	  \usebeamerfont{footline}\usebeamercolor[fg]{date in head/foot}%
	  \insertframenumber\,/\,\inserttotalframenumber\hspace*{1mm}}\vspace*{0.5mm}}
	\defbeamertemplate*{footline}{FAB theme}{\leavevmode\hbox{%
	\begin{beamercolorbox}[wd=.3\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
	  \usebeamerfont{author in head/foot}\insertshortauthor
	\end{beamercolorbox}%
	\begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
	  \usebeamerfont{title in head/foot}\insertshorttitle
	\end{beamercolorbox}%
	\begin{beamercolorbox}[wd=.3\paperwidth,ht=2.25ex,dp=1ex,center]{institute in head/foot}%
	  \usebeamerfont{institute in head/foot}\insertshortinstitute
	\end{beamercolorbox}}%
	\vskip0pt}
\else
	\setbeamertemplate{sidebar left}{\vfill\hspace*{1mm}\insertlogo\vspace*{1mm}}
\fi
\ifbeamer@FABcolour\usecolortheme{\FABcolour}\fi
\useoutertheme{\FABouter}

\ifbeamer@sb@subsection%
  \AtBeginSection[]{%
	\begin{frame}<beamer>
	\frametitle{\insertsection}
	\tableofcontents[currentsection,hideothersubsections]
	\end{frame}}%
\else%
  \AtBeginSection[]{}
  \let\subsubsection\subsection
  \renewcommand*{\subsection}[2][]{}
\fi

\setbeamerfont*{button}{size=\footnotesize}
\setbeamertemplate{caption}{\footnotesize\raggedright\insertcaption\par}
\setbeamertemplate{navigation symbols}{}

\mode<all>
