\mode<presentation>

\usepackage{ifthen}

\setbeamertemplate{background}{
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);

  \node[rectangle, anchor=south west, left color=footgradleft, right color=footgradright, minimum width=\paperwidth, minimum height=0.08\paperheight] at (0, 0){}; % alsó színátmenetes csík

  % címoldal
  \ifnum\thepage=1\relax
  	\node[anchor=south west] at (0.02\paperwidth, 0.088\paperheight) {\includegraphics[height=0.14\paperheight]{theme_media/logo_fekete_4sor_\languagename.pdf}}; % nagy MIT-logó
  	\node[anchor=south east] at (\paperwidth - 0.02\paperwidth, 0.088\paperheight) {\includegraphics[height=0.14\paperheight]{theme_media/bme_logo.pdf}}; % nagy BME-logó
  	\node[anchor=south east] at (\paperwidth - 0.003\paperwidth, -0.003\paperheight) {\includegraphics[height=0.06\paperheight]{theme_media/vik_logo_feher_hatter_nelkul.pdf}}; % VIK logó
  	\fill[color=gray!20] (0.2\paperwidth,0.25\paperheight) rectangle ++(0.6\paperwidth, 0.005\paperheight); % szürke elválasztó
  \fi
  
  % NEM címoldal
  \ifnum\thepage>1\relax%
   	% BME-logó
    \node[anchor=south west] at (0.005\paperwidth, 0) {\includegraphics[height=0.06\paperheight]{theme_media/bme_logo_feher.pdf}};
    
    % MIT-logó
    \node[anchor=south east] at (\paperwidth - 0.005\paperwidth, 0) {\includegraphics[height=0.06\paperheight]{theme_media/logo_szoveg_nelkul_feher_hatter_nelkul.pdf}};
  \fi
  \end{tikzpicture}
}

% Title page
\defbeamertemplate*{title page}{mit}[1][]
{ 
    \begin{beamercolorbox}[center, wd=\paperwidth]{title page title}
    	\vskip0.2em
    	{\huge\textbf{\inserttitle}\par}
    	\vskip0.9em
    \end{beamercolorbox}%
    %
    \vskip0.5cm%
    \begin{beamercolorbox}[center]{author}
      	\Large \insertauthor\\
      	\vskip0.5em
      	\ifdefined\supervisor
	      	\textcolor{MITgray1}{\large{K}\scriptsize{ONZULENS}}\\
    	  	\supervisor
    	\fi
    \end{beamercolorbox}
	%
    \vskip0.5cm%
    \begin{beamercolorbox}[center]{date}
      	\insertdate%
    \end{beamercolorbox}
  \vfill
}

% dia címe
\defbeamertemplate*{frametitle}{mit}[1][]
{
	\vskip0.005\paperheight
	\begin{beamercolorbox}[wd=\paperwidth, ht=0.1\paperheight, center]{frame title} 
	\parbox[t][0.09\paperheight][c]{\paperwidth}{
		\LARGE \hskip0.5em \insertframetitle
	}
	\vskip\fill
	\end{beamercolorbox}
}

% dia lábléce 
\defbeamertemplate*{footline}{mit}[1][]
{
	\begin{beamercolorbox}[wd=\paperwidth,ht=0.1\paperheight]{footer} 
	\parbox[t][0.03\paperheight][c]{\the\paperwidth}{
		\ifnum\thepage>1
			\vskip-0.035\paperheight
			\hskip0.2\paperwidth\parbox{0.7\paperwidth}{
				\textbf{\inserttitle}\hfill\insertauthor\newline
				\insertsectionhead
				\hfill\insertframenumber/\insertmainframenumber
			}
		\else
			\vskip-0.035\paperheight
			\hskip0.01\paperwidth\parbox[t]{0.5\paperwidth}{
				\begingroup
				\fontsize{0.02\paperheight}{0.01\paperwidth}\selectfont
				\ifthenelse{\equal{\languagename}{\string english}}{
					Budapest University of Technology and Economics (BME)\newline
					Faculty of Electrical Engineering and Informatics (VIK)\newline
					Dept. of Artificial Intelligence and Systems Engineering (MIT)
				}{
					Budapesti Műszaki és Gazdaságtudományi Egyetem (BME)\newline
					Villamosmérnöki és Informatikai Kar (VIK)\newline
					Mesterséges Intelligencia és Rendszertervezés Tanszék (MIT)
				}
				\endgroup
			}
		\fi	
	}
	\vskip0.005\paperheight
	\end{beamercolorbox}
}

% szakaszcím-dia
\setbeamertemplate{section page}
{
	\begin{center}
		\begin{beamercolorbox}[wd=\paperwidth,sep=12pt,center]{part title}
			\usebeamerfont{section title}\thesection\quad\insertsection\par
		\end{beamercolorbox}
	\end{center}
}


\mode<all>