\ProvidesPackage{beamerthemeIST} % this style was created by Rob J Hyndman and is an adapation of i6dv by David Vilar

\ifx\directlua\undefined
  \usepackage[english]{babel}
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
  \usepackage{lmodern}
\else
  \usepackage{polyglossia}
  \setmainlanguage{english}
  \usepackage{fontspec}
\fi

\setbeamertemplate{itemize items}[triangle] % list bullets (triangle, circle, square, ball)
\setbeamertemplate{navigation symbols}{}  % set this to remove navigation symbols on a poster

\usepackage[square, numbers, comma, sort&compress]{natbib}
\bibliographystyle{unsrtnat}  % Use "unsrtnat" BibTeX style ( abbrv, acm, ieeetr, plain)

\usepackage{longtable}
\usepackage{listings}

\lstset{breakatwhitespace,
  basicstyle=\small\ttfamily,
  keywordstyle=\footnotesize\color{black}\ttfamily
  columns=fullflexible,
  keepspaces,
  breaklines,
  tabsize=2, 
  showstringspaces=false,
  extendedchars=true
}

\usepackage{ragged2e} % for justifing text

\usepackage{booktabs}
\usepackage{caption}
\setbeamertemplate{caption}[numbered] % set numbering of tables and figures

\captionsetup[table]{belowskip=12pt,aboveskip=4pt}

\usecolortheme{IST} % use colortheme in beamercolorthemeIST.sty

\setbeamertemplate{bibliography item}[text]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{block begin}{
  \vskip2ex
  \begin{beamercolorbox}[rounded=true,shadow=true,sep=0ex,ht=3.4ex,dp=-0.2ex,colsep=0.9ex]{block title}%
    \usebeamerfont{block title}\textbf{\insertblocktitle}
  \end{beamercolorbox}%
  %{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.0ex,sep=.0ex,vmode]{block body}%
    \ifbeamercolorempty[bg]{block body}{\vskip-.1ex}\vbox{}%
  }
  \setbeamertemplate{block end}{
  \end{beamercolorbox}
}

% setup exampleblock
\setbeamertemplate{block example begin}{
  \vskip2ex
  \begin{beamercolorbox}[rounded=true,shadow=true,sep=0ex,ht=3.4ex,dp=-0.2ex,colsep=0.9ex]{block title example}%
    \usebeamerfont*{block title example}\textbf{\insertblocktitle}
  \end{beamercolorbox}%
  %{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body example}%
  \begin{beamercolorbox}[colsep*=.75ex,sep=.75ex,vmode]{block body example}%
    \ifbeamercolorempty[bg]{block body example}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
  }
  \setbeamertemplate{block example end}{
  \end{beamercolorbox}
}


% setup alertblock
\setbeamertemplate{block alerted begin}{
  \vskip2ex
  \begin{beamercolorbox}[rounded=true,shadow=true,sep=0ex,ht=3.4ex,dp=-0.2ex,colsep=0.9ex]{block title alerted}%
    \usebeamerfont*{block title alerted}\textbf{\insertblocktitle}
  \end{beamercolorbox}%
  %{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body alerted}%
  \begin{beamercolorbox}[colsep*=.75ex,sep=.75ex,vmode]{block body alerted}%
    \ifbeamercolorempty[bg]{block body alerted}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
  }
  \setbeamertemplate{block alerted end}{
  \end{beamercolorbox}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{headline}{  
  \leavevmode

  \begin{beamercolorbox}[wd=\paperwidth]{upper separation line head}
    \rule{0pt}{10pt}
  \end{beamercolorbox}
  
  \begin{beamercolorbox}[wd=\paperwidth]{headline}
    \begin{columns}[t]
      \begin{column}{.02\paperwidth}
      \end{column}
      \begin{column}{.15\paperwidth}
        \begin{center}
          \vskip9ex
          \includegraphics[width=0.96\linewidth]{./images/eNM-logo.eps} % add a logo here
        \end{center}
      \end{column}
      \begin{column}{.68\paperwidth}
        \begin{center}
          \vskip3.5ex
        \vspace*{10pt}
        \usebeamercolor{title in headline}{\color{fg}\textbf{\LARGE{\inserttitle}}\\[1ex]}
        \vspace*{10pt}
        \usebeamercolor{author in headline}{\color{fg}\large{\insertauthor}\\[1ex]}
        \usebeamercolor{institute in headline}{\color{fg}\large{\insertinstitute}\\[1ex]}
        \vspace*{10pt}
        \end{center}
      \end{column}
      \begin{column}{.15\paperwidth}
        \begin{center}
          \vskip8.4ex
          \includegraphics[width=1\linewidth]{./images/ist-logo.eps}\hspace{6em}
        \end{center}
      \end{column}
      \begin{column}{.03\paperwidth}
      \end{column}
    \end{columns}
  \end{beamercolorbox}

  
  \begin{beamercolorbox}[wd=\paperwidth]{lower separation line head}
    \rule{0pt}{10pt}
  \end{beamercolorbox}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{
  \begin{beamercolorbox}[wd=\paperwidth]{upper separation line foot}
    \rule{0pt}{3pt}
  \end{beamercolorbox}
  \begin{beamercolorbox}[ht=0ex,leftskip=1cm,rightskip=1cm]{footline}%
    \begin{columns}[t]
      \begin{column}{.01\paperwidth}
      \end{column}
      \begin{column}{.42\paperwidth}
          \vskip4.4ex
          \small
          {\insertfooter}
      \end{column}
      \begin{column}{.22\paperwidth}
        \begin{center}
          \small
          \justifying
         \texttt{http://enanomapper.net}
         This project has received funding from
         the European Union's Seventh
         Framework Programme for research,
         technological development and
         demonstration under grant agreement
         no 604134.
        \end{center}
      \end{column}
      \begin{column}{.32\paperwidth}
        \begin{center}
          \hfill
          \includegraphics[width=0.30\linewidth]{./images/eNM-logo.eps}\hspace*{1ex}\vspace*{1ex}
          \hskip4ex
          \includegraphics[width=0.52\linewidth]{./images/logo-ce-horizontal-en-quadri.eps}
          \vskip2ex   
        \end{center}       
      \end{column}
      \begin{column}{.01\paperwidth}
      \end{column}
    \end{columns}
  \end{beamercolorbox}
  \begin{beamercolorbox}[wd=\paperwidth]{lower separation line foot}
    \rule{0pt}{3pt}
  \end{beamercolorbox}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mode<all>

\def\footer#1{\def\insertfooter{#1}}
