\RequirePackage{tikz, datetime, textpos}
\DeclareOption{beteckna}{
	\setsansfont[Ligatures=TeX, 
				 Extension=.ttf,
				 BoldFont=*Bold,
				 ItalicFont=*Italic
				 ]{BetecknaLowerCase}
}
\ProcessOptions
\yyyymmdddate \renewcommand{\dateseparator}{.}

\definecolor{MedianBrown}{RGB}{0,0,0}
\definecolor{MedianLightBrown}{RGB}{222,222,222}
\definecolor{MedianLightBlue}{RGB}{240,173,0}
\definecolor{MedianOrange}{RGB}{83,86,90}
\definecolor{MedianLightOrange}{RGB}{83,86,90}
\definecolor{MedianUltraLightOrange}{RGB}{233,234,235}

\setbeamercolor*{title page header}{fg=white}
\setbeamercolor*{title}{fg=MedianLightBrown}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{item}{fg=MedianOrange}
\setbeamercolor*{frametitle}{fg=MedianBrown}
\setbeamercolor*{block title}{fg=white, bg=MedianOrange}
\setbeamercolor*{block title example}{fg=white, bg=MedianLightOrange}
\setbeamercolor*{block body}{bg=MedianUltraLightOrange}
\setbeamercolor*{block body example}{bg=MedianUltraLightOrange}
\setbeamercolor*{section in toc}{fg=black}
\setbeamercolor*{section page}{fg=white}

\setbeamerfont{section page}{size=\LARGE}
\setbeamerfont{title}{size=\LARGE}
\setbeamerfont{author}{size=\Large}
\setbeamerfont{date}{size=\Large}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{items}[circle]
\setbeamertemplate{itemize item}[circle]
\setbeamertemplate{itemize subitem}[circle]
\setbeamertemplate{sections/subsections in toc}[circle]

\newenvironment{xplainframe}{\bgroup\setbeamertemplate{background}{}\begin{frame}[plain]}{\end{frame}\egroup}

\setbeamertemplate{background}{
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
  \ifnum\thepage>1\relax% Not the title page
	    \fill[color=MedianOrange] (0,8) rectangle(0.8,8.3);
	    \fill[color=MedianLightBlue] (0.9,8) rectangle(\the\paperwidth, 8.3);
  \else% Title page
	  \fill[color=MedianBrown] (0,1.2) rectangle (\the\paperwidth,\the\paperheight);
	  \fill[color=MedianOrange] (0,0.1) rectangle(3.15,1.1);
	  \fill[color=MedianLightBlue] (3.3,0.1) rectangle(\the\paperwidth,1.1); 
	  \node[inner sep=0pt] (logo) at (9.45,6.25)
    		{\includegraphics[width=.6\textwidth]{spirit.png}
	};
  \fi
  \end{tikzpicture}
}
\setbeamertemplate{title page}{
	\begin{textblock*}{12cm}(2.5cm,2.8cm)
    \begin{beamercolorbox}[wd=8cm]{title page header}
      \usebeamerfont{title}\usebeamercolor{title}\inserttitle%
    \end{beamercolorbox}%
    \end{textblock*}
    \begin{textblock*}{9cm}(-0.5cm,5cm)
		\begin{beamercolorbox}{date}
	      \usebeamerfont{date}\insertdate%
	    \end{beamercolorbox}
    \end{textblock*}
    \begin{textblock*}{9cm}(2.5cm,5cm)
	    \begin{beamercolorbox}{author}
	      \usebeamerfont{author}\insertauthor%
    	\end{beamercolorbox}
    \end{textblock*}
}
\newcommand{\sectionframe}{{
	\setbeamertemplate{background}{
		\begin{tikzpicture}
			\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
			\fill[color=MedianOrange] (0,6) rectangle (1.5, 7);
			\fill[color=MedianLightBlue] (1.6, 6) rectangle (\the\paperwidth, 7);
		\end{tikzpicture}
	}
	\frame{\sectionpage}
}}
\setbeamertemplate{section page}{
	\begin{textblock*}{12cm}(0.8cm,-0.9cm)
		\begin{beamercolorbox}{section page}
			\insertsectionhead
		\end{beamercolorbox}
	\end{textblock*}
}
\setbeamertemplate{frametitle}{
	\vspace{0.3cm}
	\begin{beamercolorbox}{frametitle}
		\insertframetitle
	\end{beamercolorbox}
}


\setbeamercolor{page number in head/foot}{fg=MedianOrange}
\renewcommand{\qedsymbol}{\textcolor{black}{\openbox}}