% Copyright 2007 by Nathanaël COTTIN <www.ncottin.net>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 3.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{polyoutboxes}[2007/09/21 version 0.2.2]

\RequirePackage{imageboxes}

\newboolean{@boximagesenabled}
\@boximagesenabledfalse

\newcommand{\enableboximages}
	{\@boximagesenabledtrue}

\newcommand{\disableboximages}
	{\@boximagesenabledfalse}

\def\@currentboxlabel{}

\let\beginimageboxenvironmentOLD\beginimageboxenvironment
\def\beginimageboxenvironment#1#2#3#4	% #1 = type (block, alertblock, ...), #2 = alt label, #3 = label, #4 = image
	{\if@boximagesenabled
		\beginimageboxenvironmentOLD{#1}{#2}{#3}{#4}
	\else
		\mode<article>{\beginimageboxenvironmentOLD{#1}{#2}{#3}{#4} }% Bracket must be placed here to successfully compile...
		\mode<presentation|trans>{
			\ifthenelse
				{\equal{#2}{}}
				{\def\@currentboxlabel{#3}}
				{\def\@currentboxlabel{#2}}
			\ifthenelse
				{\equal{#1}{exampleblock}}
				{\begin{exampleblock}{\@currentboxlabel}}
				{\ifthenelse
					{\equal{#1}{alertblock}}
					{\begin{alertblock}{\@currentboxlabel}}
					{\begin{block}{\@currentboxlabel}}}}
	\fi}


\let\endimageboxenvironmentOLD\endimageboxenvironment
\def\endimageboxenvironment#1
	{\if@boximagesenabled
		\endimageboxenvironmentOLD{#1}
	\else
		\mode<article>{\endimageboxenvironmentOLD{#1} }% Bracket must be placed here to successfully compile...
		\mode<presentation|trans>{
			\ifthenelse
				{\equal{#1}{exampleblock}}
				{\end{exampleblock}}
				{\ifthenelse
					{\equal{#1}{alertblock}}
					{\end{alertblock}}
					{\end{block}}}}
	\fi}

\endinput
