%\iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% aeb_pro.sty package,                  2006-9-08      %%
%% Copyright (C) 2006  D. P. Story                      %%
%%   dpstory@acrotex.net                                %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01]
%<package>\ProvidesPackage{aeb_pro}
%<package> [2007/04/25 v0.8a aeb_pro: A support package (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[dviwindo,colorlinks,hyperindex]{hyperref}
%\pdfstringdefDisableCommands{\let\\\textbackslash}
%\EnableCrossrefs \CodelineIndex
\begin{document}
  \GetFileInfo{aeb_pro.sty}
  \title{aeb\_pro\\as suggested by J\"{u}rgen Gilg}
  \author{D. P. Story\\
    Email: \texttt{dpstory@acrotex.net}}
  \date{processed \today}
  \maketitle
  \tableofcontents
  \let\Email\texttt
  \DocInput{aeb_pro.dtx}
  \PrintIndex
\end{document}
%</driver>
% \fi
% \MakeShortVerb{|}
% \StopEventually{}
%
% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
% \DoNotIndex{\space,\@empty,\special}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% \section{Introduction}
%
% The \texttt{aeb\_pro} package uses JavaScript methods and techniques
% that require Acrobat~7.0 Professional for document assembly, and
% assumes the PDF document is created using the Acrobat~7.0 distiller
% application. It is also, what I call, the AeB Control Central. You can use
% \texttt{aeb\_pro} to load all your Acro\negthinspace\TeX packages in the correct order. If you don't use
% Acrobat Pro and distiller, then there is a \texttt{nopro} option, so you can still use the
% AeB Control Central feature, if you wish.
%
% \section{Declare Options}
%    \begin{macrocode}
%    \end{macrocode}
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% \subsection{AeB Control Central}
%    \begin{macro}{web}
%    \begin{macro}{exerquiz}
%    \begin{macro}{dljslib}
%    \begin{macro}{eforms}
%    \begin{macro}{insdljs}
%    \begin{macro}{eq2db}
%    \begin{macro}{aebxmp}
%    \begin{macro}{hyperref}
% AeB control central are simply a set of options for including the other members
% of the AeB family.  This assures that the package are loaded in the correct order.
% The values of teach of these option keys are the options of the packages they reference.
%    \begin{macrocode}
\@tfor\aeb@pcks:={web}{exerquiz}{dljslib}%
{eforms}{insdljs}{eq2db}{aebxmp}{hyperref}\do
{%
    \edef\aeb@pack@def{%
        \noexpand\define@key{aeb_pro.sty}{\aeb@pcks}[]%
        {%
            \expandafter\def\csname aeb@\aeb@pcks @opts\endcsname{##1}%
            \noexpand\PassOptionsToPackage{##1}{\aeb@pcks}%
        }%
    }\aeb@pack@def
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{driver}
% We provide a convenient way to pass the driver used, dvips or dvipsone.
% If the user chooses the web option, then he/she might have a \texttt{web.cfg}
% file, so using this option may not be needed, in this case.
%    \begin{macrocode}
\define@choicekey+{aeb_pro.sty}{driver}%
    {dvipsone,dvips,pdftex,dvipdfm,textures}{%
    \def\aeb@driver{#1}\ifx\aeb@driver\@empty\else
        \PassOptionsToPackage{#1}{web}
        \PassOptionsToPackage{#1}{exerquiz}
        \PassOptionsToPackage{#1}{hyperref}
        \PassOptionsToPackage{#1}{insdljs}
        \PassOptionsToPackage{#1}{eforms}
    \fi
}{\PackageWarning{aeb}{Bad choice for the driver, permissible values
   are dvipsone and dvips. Try again}}
\let\aeb@driver\@empty
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{uselayers} option}
%    \begin{macro}{uselayers}
% The document author wishes to use Optional Content Groups, a.k.a., layers.
%    \begin{macrocode}
\DeclareOptionX{uselayers}{\AtEndOfPackage{\aeb@InputAeBLayers}}
\def\aeb@InputAeBLayers{\InputIfFileExists{aeblayers.def}%
    {\typeout{aeb_pro: Inputting code for uselayers option}}%
    {\typeout{aeb_pro: Cannot find aeblayers.def.
        Reinstall or refresh your file name database.}}}
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{nopro} option}
%    \begin{macro}{nopro}
% The \texttt{pro} option for \textsf{aeb\_pro} will bring in all the code that would require the use of
% the Distiller and Acrobat Pro, this is the default. The \texttt{nopro} cancels out the pro option. If the
% author wants to use AeB Control Central feature only.
%    \begin{macrocode}
% \DeclareOptionX{pro}{\AtEndOfPackage{\@inputAeBPro}}
\def\aeb@InputAeBPro{\InputIfFileExists{aebpro.def}%
    {\typeout{aeb_pro: Inputting code for the pro option}}%
    {\typeout{aeb_pro: Cannot find aebpro.def.
        Reinstall or refresh your file name database, as needed.}}}
\AtEndOfPackage{\aeb@InputAeBPro}
\DeclareOptionX{nopro}{%
    \let\aeb@InputAeBPro\@empty
    \PackageWarningNoLine{aeb_pro}{%
    The nopro option was taken.\MessageBreak
    Page and document events, fullscreen\MessageBreak
    and attachments are not available.\MessageBreak
    If you wish some of these features,\MessageBreak
    remove the nopro option}%
}
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{gopro} option}
%    \begin{macro}{gopro}
% Some of the components of AeB have the pro option. Use \texttt{gopro} to
% pass the \texttt{pro} option to all components that take it.
%    \begin{macrocode}
\DeclareOptionX{gopro}{\PassOptionsToPackage{pro}{web}}
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{attachsource} option}
%    \begin{macro}{attachsource}
% A simple interface to attaching the source file(s) of \cs{jobname}.
%    \begin{macrocode}
\DeclareOptionX{attachsource}{\def\aeb@attachsource{#1}}
\let\aeb@attachsource\@empty
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{attachments} option}
%    \begin{macro}{attachments}
% A general routine for attaching files other than the \cs{jobname}.
%    \begin{macrocode}
\DeclareOptionX{attachments}{\def\aeb@attachments{#1}}
\let\aeb@attachments\@empty
%    \end{macrocode}
%    \end{macro}
% \subsection{\texttt{linktoattachments} and \texttt{latin1} option}
%    \begin{macro}{linktoattachments}
%    \begin{macro}{latin1}
% A general routine for linking to attached PDF files. The latin1 option
% is only available if you take the \texttt{linktoattachments} options.
%    \begin{macrocode}
\def\@aeb@InputUnicodes{\InputIfFileExists{unicodes.def}%
    {\typeout{aeb_pro: Inputting code for the linktoattachments option}}%
    {\typeout{aeb_pro: Cannot find unicodes.def.
        Reinstall or refresh your file name database, as needed.}}}
\let\aeb@InputUnicodes\@empty
\def\aeb@InputUnicodesi{\InputIfFileExists{unicodes1.def}%
    {\typeout{aeb_pro: Inputting code for the latin1 option}}%
    {\typeout{aeb_pro: Cannot find unicodes1.def.
        Reinstall or refresh your file name database, as needed.}}}
\DeclareOptionX{linktoattachments}{%
    \let\aeb@InputUnicodes\@aeb@InputUnicodes
    \AtEndOfPackage{\aeb@InputUnicodes}%
}
\DeclareOptionX{latin1}{%
    \AtEndOfPackage{%
    \ifx\aeb@InputUnicodes\@empy\else
        \aeb@InputUnicodesi\fi
    }}
\DeclareOptionX{childof}{%
    \def\aeb@childof{#1}%
    \AtEndOfPackage{\InputIfFileExists{\aeb@childof_xref.cut}{}{}}%
}
\let\aeb@childof\@empty
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
% Check for correct driver if the pro option is still in effect.
%    \begin{macrocode}
\let\aeb@continue\relax
\ifx\aeb@InputAeBPro\@empty
\else
    \ifx\aeb@driver\@empty % no driver specified
    \else
        \def\aeb@testdriver{dvips}%
        \ifx\aeb@testdriver\aeb@driver % ok to continue
        \else
            \def\aeb@testdriver{dvipsone}%
            \ifx\aeb@testdriver\aeb@driver % ok to continue
            \else
                \PackageError{aeb_pro}{%
                   You have not specified the dvips or dvipsone driver.%
                   \MessageBreak The pro option requires one of these
                   two drivers
                }{%
                   Specify dvips or dvipsone as the value of the driver
                   key\MessageBreak or specify the nopro option
                }%
                \let\aeb@continue\endinput
            \fi
        \fi
    \fi
\fi
\aeb@continue
%    \end{macrocode}
% \section{Package requirements}
% AeB builds on the \textsf{web} package to a certain extent, hence requires \textsf{insdljs}.
%    \begin{macrocode}
\@ifpackageloaded{web}{}
{%
    \def\getargs#1#2{\def\aeb@argi{#1}\def\aeb@argii{#2}}
    \@ifundefined{aeb@web@opts}{}
    {\RequirePackage{web}}%
}
\@ifpackageloaded{exerquiz}{}
{%
    \@ifundefined{aeb@exerquiz@opts}{}
    {\RequirePackage{exerquiz}}%
}
\@ifpackageloaded{hyperref}{}
{%
    \@ifundefined{aeb@hyperref@opts}{}
    {\usepackage{hyperref}}%
}
\@ifpackageloaded{eq2db}{}
{%
    \@ifundefined{aeb@eq2db@opts}{}
    {\RequirePackage{eq2db}}%
}
\@ifpackageloaded{dljslib}{}
{%
    \@ifundefined{aeb@dljslib@opts}{}
    {\RequirePackage{dljslib}}%
}
\@ifpackageloaded{insdljs}{\let\execjs=y}
{%
    \RequirePackage[execJS]{insdljs}%
}
\@ifpackageloaded{eforms}{\let\execjs=y}
{%
    \@ifundefined{aeb@eforms@opts}{}
    {\RequirePackage[execJS]{eforms}}%
}
\@ifpackageloaded{aebxmp}{}
{%
    \@ifundefined{aeb@aebxmp@opts}{}
    {\RequirePackage{aebxmp}}%
}
\let\execjs=y
\RequirePackage{comment}
\RequirePackage{calc}
\RequirePackage{eso-pic}
%    \end{macrocode}
% The following write command is used by both the layers stuff, and the attachments routines.
%    \begin{macrocode}
\def\aeb@IWVO{\immediate\write\verbatim@out}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%<*aeblayers>
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
% \section{Support for OCG}
% We place PostScript code in the document that supports OCG.
% \subsection{Initialization}
%    \begin{macrocode}
\newif\ifaeb@ocOn \aeb@ocOntrue
\ifaeb@ocOn
\AtBeginDocument{%
\headerps@out{%
{/OCProcSet /ProcSet findresource} stopped not
{/initialize get exec}
{
/BeginOC /pop load def
/EndOC {} def
/SimpleOC /pop load def
/SetOCGInitState {pop pop} bind def
/OCEndPage {} def
/SetOCGIntent {pop pop} bind def
/SetOCGUsage {pop pop} bind def
/AddASEvent {pop pop pop} bind def
}
ifelse
}
}\fi
\ifaeb@ocOn
    \AtEndDocument{\literalps@out{{/OCProcSet /ProcSet findresource
    /terminate get exec} stopped pop}}
\fi
%    \end{macrocode}
% \subsection{Supporting commands for OCG}
% In this section we install the necessary code creating and
% navigating through PDF layers.
% \subsubsection{Document JavaScript in support of OCG}
%    \begin{macrocode}
\begin{insDLJS}[getxBld]{aebocg}{AeB Pro: OCG Support}
var ocgs = this.getOCGOrder();
var xBlds = new Array();
console.println("Reindexing ocgs and creating xBlds");
if ( ocgs != null ) {
    var l = ocgs.length;
    for ( i=0; i<l; i++ ) {
        if (ocgs[0].name.substring(0,3) == "xb." )
            xBlds.push(ocgs.shift());
        else ocgs.push(ocgs.shift());
    }
}
var assocxLayers = new Array();
if ( xBlds != null ) {
    for ( var i=0; i<xBlds.length; i++)
        assocxLayers[xBlds[i].name]=i;
}
function getxBld (name) {
    var i = assocxLayers["xb."+name];
    return ( i == undefined ) ? null : xBlds[i];
}
function toggleHelp (name)
{
    var o = getxBld(name);
    if ( o != null ) o.state = (event.name.indexOf("Enter") != -1);
}
function toggleSetThisLayer(name, bState) {
    var oLayer = getxBld(name);
    if ( oLayer != null )
        oLayer.state = (arguments.length > 1) ? bState : !oLayer.state;
}
function getLayerState(name) {
    var oLayer = getxBld(name);
    return ( oLayer != null ) ? oLayer.state : null;
}
\end{insDLJS}
%    \end{macrocode}
% \subsubsection{Macros for creating rollovers}
% The following commands were taken from the \textsf{APB} package, and slightly modified.
%    \begin{macrocode}
\newsavebox{\aebsavehelp}
\newcommand{\texHelpIndicator}[1]{#1\thinspace${}^{\mbox
    {\footnotesize\negthinspace\ding{109}}\raisebox{.225ex}
    {\llap{\color{webblue}\tiny?\hspace{1.3ex}}}}$}
\newcommand{\texHelp}[2]{%
    \sbox{\aebsavehelp}{\texHelpIndicator{#2}}%
    \makebox[0pt][l]{\pushButton[\S{S}\BG{}\BC{}\H{N}
    \AA{\AAMouseEnter{\JS{toggleHelp("#1")}}%
    \AAMouseExit{\JS{toggleHelp("#1");}}}]{#1}{\wd\aebsavehelp}{11bp}}%
    \usebox{\aebsavehelp}%
}
\newcommand{\pdfHelpIndicator}[1]{#1\thinspace${}^{\mbox
    {\footnotesize\negthinspace\ding{109}}%
    \raisebox{.225ex}{\llap{\color{webblue}\tiny?\hspace{1.3ex}}}}$}
\newcommand{\pdfHelp}[3]{%
    \sbox{\aebsavehelp}{\pdfHelpIndicator{#3}}%
    \makebox[0pt][l]{\makespecialJS\pushButton[\S{S}\BG{}\BC{}\H{N}
    \TU{#2}]{#1}{\wd\aebsavehelp}{11bp}}\usebox{\aebsavehelp}%
}
\newif\ifaeb@SimpleOCOn \aeb@SimpleOCOnfalse
\newcommand{\@SOC}[2][false]{\global\aeb@SimpleOCOntrue%
    \ifaeb@ocOn\literalps@out{(#2) SimpleOC (#2) #1 SetOCGInitState}\fi}
\newcommand{\b@OC}[2][false]{\ifaeb@SimpleOCOn\@aebSimpleNesterror\fi
    \ifaeb@ocOn\literalps@out{(#2) BeginOC (#2) #1 SetOCGInitState}\fi}
\newcommand{\e@OC}{\ifaeb@ocOn\literalps@out{EndOC}\fi}
\newcommand{\xBld}[2][false]{\b@OC[#1]{xb.#2}}
\let\eBld=\e@OC
\def\@aebSimpleNesterror{\PackageWarning{aeb}
{The scope of the last \string\Bld\space command
\MessageBreak includes the scope of the nested Bld.
\MessageBreak Executing \protect\ocOff\space to correct this.
\MessageBreak The problem occurs}\ocOff}
%    \end{macrocode}
% \subsubsection{The behavior of the rollovers}
%    \begin{macro}{\defineRC}
%    \begin{macro}{\insertRC}
% RC stands for rollover content. \cs{defineRC} is used to define the content of the rollover
% so the content can be used for the \texttt{rollover} and the \texttt{printRollover} environments.
% These two environments are comment environments that are included or excluded depending on various
% conditions.
%    \begin{macrocode}
\long\def\defineRC#1#2{\expandafter\def\csname RC#1\endcsname{#2}}
\def\insertRC#1{\csname RC#1\endcsname}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \begin{environment}{rollover}
%    \begin{environment}{printRollover}
%    \begin{macro}{\definePR}
%    \begin{macro}{\insertPR}
% Depending on the switches \cs{ifeqforpaper} and \cs{ifeq@proofing}, the comment environments
% \texttt{rollover} and \texttt{printRollover} are included or excluded. Also defined here are the
% two commands \cs{definePR} and \cs{insertPR} (PR stands for print rollover). These two commands
% are set equal to either \cs{defineRC} and \cs{insertRC}, or \cs{relax}, depending on the switches.
%
% If \textsf{exerquiz} is not loaded, then the switch \cs{ifeq@proofing} is undefined. We must
% define this switch in this case, and set it to \texttt{false}.
%    \begin{macrocode}
\@ifundefined{ifeqforpaper}{\newif\ifeqforpaper \eqforpaperfalse}{}
\@ifundefined{ifeq@proofing}{\newif\ifeq@proofing \eq@proofingfalse}{}
\ifeqforpaper
    \ifeq@proofing
        \includecomment{rollover}
        \includecomment{printRollover}
        \let\definePR\defineRC
        \long\def\definePR#1#2{%
            \expandafter\def\csname PR#1\endcsname{#2}}
        \def\insertPR#1{\csname PR#1\endcsname
            \expandafter\let\csname PR#1\endcsname\relax}
    \else
        \includecomment{printRollover}
        \excludecomment{rollover}
        \let\definePR\defineRC
        \long\def\definePR#1#2{%
            \expandafter\def\csname PR#1\endcsname{#2}}
        \def\insertPR#1{\csname PR#1\endcsname
            \expandafter\let\csname PR#1\endcsname\relax}
    \fi
\else
    \ifeq@proofing
        \includecomment{rollover}
        \includecomment{printRollover}
        \let\definePR\defineRC
        \long\def\definePR#1#2{%
            \expandafter\def\csname PR#1\endcsname{#2}}
        \def\insertPR#1{\csname PR#1\endcsname
            \expandafter\let\csname PR#1\endcsname\relax}
    \else
        \excludecomment{printRollover}
        \includecomment{rollover}
        \let\definePR\relax
        \let\insertPR\@gobble
    \fi
\fi
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{environment}
%    \end{environment}
%    \begin{macro}{\texPrintHelp}
% The \cs{texPrintHelp} command reduces to \cs{texHelp} or typesets its second argument.
%    \begin{macrocode}
\def\texPrintHelp#1#2{%
    \ifeqforpaper
        \ifeq@proofing
            \texHelp{#1}{#2}\marginpar{#1}%
        \else
            #2%
        \fi
    \else
        \texHelp{#1}{#2}\ifeq@proofing\marginpar{#1}\fi
    \fi
}
%    \end{macrocode}
%    \end{macro}
% \subsection{In Support of Anime using Layers}
% Using layers, it is possible to create a sort of animation (anime).  The following
% are some rudimentary methods for creating anime. An example can be found below,
% as well as in \texttt{aebpro\_ex4.tex}.
%
% \subsubsection{\protect\LaTeX{} Support}
%    \begin{macro}{\animeBld}
%    \begin{macro}{\DeclareAnime}
% The command \cs{animeBld} increments \texttt{ocSeq}, and names
% the layer so that the JS can run through the layers in an orderly way.
%
% \cs{DeclareAnime} takes three arguments, the anime base name, the speed at which
% you wish the anime to be played, and the number of frames of this animation. It
% saves these three parameters in macros, and creates \cs{animBldName}, which is used
% in the creation of the anime. See example file \texttt{aebpro\_ex4.tex}.
%    \begin{macrocode}
\newcommand{\animeBld}[1][false]{\stepcounter{ocSeq}%
    \xBld[#1]{\animBldName}}
\newcounter{ocSeq}
\newcommand{\DeclareAnime}[3]
{%
    \setcounter{ocSeq}{0}%
    \gdef\animBaseName{#1}%
    \gdef\animSpeed{#2}%
    \gdef\nFrames{#3}%
    \gdef\animBldName{\animBaseName\#\theocSeq}%
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{\backAnimeBtn}
%    \begin{macro}{\clearAnimeBtn}
%    \begin{macro}{\forwardAnimeBtn}
% The command \cs{animeBld} increments \texttt{ocSeq}, and names
% the layer so that the JS can run through the layers in an orderly way.
%
% \cs{DeclareAnime} takes three arguments, the anime base name, the speed at which
% you wish the anime to be played, and the number of frames of this animation. It
% saves these three parameters in macros, and creates \cs{animBldName}, which is used
% in the creation of the anime. See example file \texttt{aebpro\_ex4.tex}.
% \begin{itemize}
%    \item \texttt{\#1}: This is an optional parameter for changing the appearance
%           of the button, See the \textsf{eforms} package documentation.
%    \item \texttt{\#2}: width of the button
%    \item \texttt{\#3}: height of the button
% \end{itemize}
%    \begin{macrocode}
\newcommand{\backAnimeBtn}[3][]
{%
    \pushButton[\textFont{Wingdings3}\CA{�}\TU{Reverse}#1\A{\JS{%
        aebAnimeLayersBackward(\animSpeed,\nFrames,"\animBaseName");
    }}]{\animBaseName BtnBack}{#2}{#3}%
}
\newcommand{\clearAnimeBtn}[3][]
{%
    \pushButton[\textFont{Wingdings}\CA{n}\TU{Clear}#1\A{\JS{%
        aebAnimeLayersClear(\animSpeed,\nFrames,"\animBaseName");
    }}]{\animBaseName BtnClear}{#2}{#3}%
}
\newcommand{\forwardAnimeBtn}[3][]
{%
    \pushButton[\textFont{Wingdings3}\CA{�}\TU{Graph It!}#1\A{\JS{%
        aebAnimeLayersForward(\animSpeed,\nFrames,"\animBaseName");
    }}]{\animBaseName BtnForward}{#2}{#3}%
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
% Here is a simple example if anime, using the above commands. The code
% below uses the \textsf{pstricks-add} and \textsf{fp} packages.
%\begin{verbatim}
%\begin{center}
%\DeclareAnime{sinegraph}{10}{40}
%\def\thisframe{\animeBld\psplot[linecolor=red]{0}{\xi}{sin(x)}\eBld}
%\psset{llx=-12pt,lly=-12pt,urx=12pt,ury=12pt}
%\begin{psgraph*}[arrows=->](0,0)(-.5,-1.5)(6.5,1.5){164pt}{70pt}
%    \psset{algebraic=true}%
%    \rput(4,1){$y=\sin(x)$}
%    \FPdiv{\myDelta}{\psPiTwo}{\nFrames}%
%    \def\xi{0}%
%    \multido{\i=1+1}{\nFrames}{\FPadd{\xi}{\xi}{\myDelta}\thisframe}
%\end{psgraph*}
%
%\backAnimeBtn{24bp}{12bp}\kern1bp\clearAnimeBtn{24bp}{12bp}\kern1bp
%\forwardAnimeBtn{24bp}{12bp}
%\end{center}
%\end{verbatim}
% \subsubsection{JavaScript Support}
%    \begin{macrocode}
\begin{insDLJS}[_animeLayers]{animelayers}{AeB Pro: JS in Support of Anime}
var _animeLayers = true;
var aebAnimeTimeOutF = new Object();
var aebAnimeTimeOutB = new Object();
var aebAnimeTimeOutC = new Object();
function aebAnimeLayersForward(animSpeed,nFrames,baseName)
{
    var timeinterval = animSpeed;
    aebAnimeTimeOutF = app.setInterval("aebAnimeTimeOutF.count++;"
        + "if (aebAnimeTimeOutF.count > " + nFrames +" ) app.clearInterval(aebAnimeTimeOutF);\r"
        + "else { if (aebAnimeTimeOutF.count == 1 ) getxBld('"+baseName+"\#1').state=true;\t"
        + "else { getxBld('"+baseName+"\#'+(aebAnimeTimeOutF.count-1)).state=false;\t"
        + "getxBld('"+baseName+"\#'+aebAnimeTimeOutF.count).state=true;}}", timeinterval);
    aebAnimeTimeOutF.start = 1;
    aebAnimeTimeOutF.count=0;
}
function aebAnimeLayersBackward(animSpeed,nFrames,baseName)
{
    var timeinterval = animSpeed;
    aebAnimeTimeOutB = app.setInterval("aebAnimeTimeOutB.count++;\r"
        + "if (aebAnimeTimeOutB.count > "+nFrames+") app.clearInterval(aebAnimeTimeOutB);\r"
        + "else { if (aebAnimeTimeOutB.count == "+nFrames+") getxBld('"+baseName+"\#1').state=false;\r"
        + "else { getxBld('"+baseName+"\#'+(aebAnimeTimeOutB.start-aebAnimeTimeOutB.count+1)).state=false;\r"
        + "getxBld('"+baseName+"\#'+(aebAnimeTimeOutB.start-aebAnimeTimeOutB.count)).state=true;}}", timeinterval);
    aebAnimeTimeOutB.start = nFrames;
    aebAnimeTimeOutB.count=0;
}
function aebAnimeLayersClear(animSpeed,nFrames,baseName)
{
    var timeinterval = animSpeed;
    aebAnimeTimeOutC = app.setInterval("aebAnimeTimeOutC.count++;\r"
        + "if (aebAnimeTimeOutC.count > "+nFrames+") app.clearInterval(aebAnimeTimeOutC);\r"
        + "else { getxBld('"+baseName+"\#'+(aebAnimeTimeOutC.start-aebAnimeTimeOutC.count+1)).state=false;}", timeinterval);
    aebAnimeTimeOutC.start = nFrames;
    aebAnimeTimeOutC.count=0;
}
\end{insDLJS}
%    \end{macrocode}
%    \begin{macrocode}
%</aeblayers>
%<*aebpro>
%    \end{macrocode}
% \section{Initial View}
%  Supported preferences are \texttt{HideToolbar}, \texttt{HideMenubar}, \texttt{FitWindow},
% \texttt{CenterWindow}, \texttt{DisplayDocTitle},
%  \texttt{NonFullScreenPageMode} (\texttt{UseNone}, \texttt{UseOutlines}, \texttt{UseThumbs},
% \texttt{UseOC}, \texttt{UseAttachments})
%
% \subsection{Window Options}
%
%    \begin{macrocode}
\@tfor\aeb@windowopts:={{fit}{FitWindow}}{{center}{CenterWindow}}%
    {{fullscreen}{FullScreen}}{{showtitle}{DisplayDocTitle}}\do
{%
    \expandafter\getargs\aeb@windowopts
    \edef\temp@expand@def{%
            \noexpand\define@key{aebWindowOpts}{\aeb@argi}[true]{%
            \noexpand\def\csname aeb@windowopts\aeb@argii\endcsname{/\aeb@argii\space##1}%
        }%
    }\temp@expand@def
    \expandafter\let\csname aeb@windowopts\aeb@argii\endcsname\@empty
}
%    \end{macrocode}
%    \begin{macro}{\setWindowOptions}
% Set the User Window options on the Initial View tab of the Document Properties dialog box.
%    \begin{macrocode}
\newcommand{\setWindowOptions}[1]{\setkeys{aebWindowOpts}{#1}}
%    \end{macrocode}
%    \end{macro}
% \subsection{User Interface Options}
%    \begin{macrocode}
\@tfor\aeb@uiopts:={{hidetoolbar}{HideToolbar}}{{hidemenubar}{HideMenubar}}%
    {{hidewindowui}{HideWindowUI}}\do
{%
    \expandafter\getargs\aeb@uiopts
    \edef\temp@expand@def{%
        \noexpand\define@key{aebUIOpts}{\aeb@argi}[true]%
        {%
            \noexpand\edef\csname aeb@uiopts\aeb@argii\endcsname{/\aeb@argii\space##1}%
        }%
    }\temp@expand@def
    \expandafter\let\csname aeb@uiopts\aeb@argii\endcsname\@empty
}
%    \end{macrocode}
%    \begin{macro}{\setUIOptions}
% Set the User Interface options on the Initial View tab of the Document Properties dialog box.
%    \begin{macrocode}
\newcommand{\setUIOptions}[1]{\setkeys{aebUIOpts}{#1}}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Layout and Magnification}
%
% \subsubsection{Navigation Tab (Page Mode)}
% Supported keys
%\begin{itemize}
% \item \texttt{UseNone}: Page Only
% \item \texttt{UseOutlines}: Bookmarks Panel and Page
% \item \texttt{UseThumbs}: Pages Panel and Page
% \item \texttt{FullScreen}: Fullscreen mode
% \item \texttt{UseOC}: Layers Panel and Page
% \item \texttt{UseAttachments}: Attachments Panel and Page
%\end{itemize}
%    \begin{macrocode}
\define@choicekey+{aebLayoutMag}{navitab}{UseNone,UseOutlines,UseThumbs,FullScreen,%
    UseOC,UseAttachments}[UseNone]{%
        \def\aeb@layoutMagNaviTab{#1}%
}{\PackageWarning{aeb}{Bad choice for PageLayout, permissible values
   are UseNone, UseOutlines, UseThumbs, FullScreen,%
    UseOC, UseAttachments. Try again}}
\let\aeb@layoutMagNaviTab\@empty
%    \end{macrocode}
% \subsubsection{Page Layout}
% Supported keys are
%\begin{itemize}
%   \item \texttt{SinglePage}: Single page
%   \item \texttt{OneColumn}: Single page continuous
%   \item \texttt{TwoPageLeft}: Two-Up (Facing)
%   \item \texttt{TwoColumnLeft}: Two-Up Continuous (Facing)
%   \item \texttt{TwoPageRight}: Two-Up (Cover Page)
%   \item \texttt{TwoColumnRight}: Two-Up Continuous (Cover Page)
%\end{itemize}
%    \begin{macrocode}
\define@choicekey+{aebLayoutMag}{pagelayout}{SinglePage,OneColumn,%
    TwoColumnLeft,TwoColumnRight,TwoPageLeft,TwoPageRight}[SinglePage]{%
        \def\aeb@layoutMagPageLayout{#1}%
}{\PackageWarning{aeb}{Bad choice for PageLayout, permissible values
   are SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight,
   TwoPageLeft,TwoPageRight. Try again}}
\let\aeb@layoutMagPageLayout\@empty
%    \end{macrocode}
% \subsubsection{Magnification}
%\begin{verbatim}
% Actual Size <</D[1 0 R/XYZ -32768 -32768 1.0]/S/GoTo>>
% Fit Page <</D[1 0 R/Fit]/S/GoTo>>
% Fit Width <</D[21 0 R/FitH -32768]/S/GoTo>>
% Fit Height <</D[1 0 R/FitV -32768]/S/GoTo>>
% Fit Visible <</D[21 0 R/FitBH -32768]/S/GoTo>>
% 25% <</D[21 0 R/XYZ -32768 -32768 0.25]/S/GoTo>>
%\end{verbatim}
%    \begin{macrocode}
\define@choicekey+{aebLayoutMag}{mag}[\val\nr]%
    {ActualSize,FitPage,FitWidth,FitHeight,FitVisible}[FitPage]%
{%
    \ifcase\nr\relax
        \def\aeb@layoutMagMag{/XYZ -32768 -32768 1.0}%
    \or
        \def\aeb@layoutMagMag{/Fit}%
    \or
        \def\aeb@layoutMagMag{/FitH -32768}%
    \or
        \def\aeb@layoutMagMag{/FitV -32768}%
    \or
        \def\aeb@layoutMagMag{/FitBH -32768}%
    \fi
}{\edef\aeb@layoutMagMag{/XYZ -32768 -32768 \val\space 100 div}}
\let\aeb@layoutMagMag\@empty
%    \end{macrocode}
% \subsubsection{Open to page}
%    \begin{macrocode}
\define@key{aebLayoutMag}{openatpage}[1]{\def\aeb@openatpageChoice{#1}%
    \def\aeb@layoutMagPage{Page#1}}
\let\aeb@openatpageChoice\@empty
\let\aeb@layoutMagPage\@empty
%    \end{macrocode}
%    \begin{macro}{\setInitLayout}
% Set the User Interface options on the Initial View tab of the Document Properties dialog box.
%    \begin{macrocode}
\newcommand{\setLayoutMag}[1]{\edef\temp@expand@sets{%
    \noexpand\setkeys{aebLayoutMag}{\ifx\aeb@openatpageChoice\@empty
        openatpage=1\else openatpage=\aeb@openatpageChoice\fi}}%
    \temp@expand@sets\setkeys{aebLayoutMag}{#1}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\DeclareInitView}
% This command is the ultimate holder of the Initial View data. It has three keys
% layoutmag, windowoptions and uioptions. The values for each of these three are
% key values for the commands defined above: \cs{setLayoutMag}, \cs{setWindowOptions} and \cs{setUIOptions}.
%    \begin{macrocode}
\define@key{aebDeclareInitView}{layoutmag}
    {\def\aebDeclareInitView@layoutmag{#1}}
\let\aebDeclareInitView@layoutmag\@empty
\define@key{aebDeclareInitView}{windowoptions}
    {\def\aebDeclareInitView@windowoptions{#1}}
\let\aebDeclareInitView@windowoptions\@empty
\define@key{aebDeclareInitView}{uioptions}
    {\def\aebDeclareInitView@uioptions{#1}}
\let\aebDeclareInitView@uioptions\@empty
\newcommand{\DeclareInitView}[1]{%
    \setkeys{aebDeclareInitView}{#1}%
    \edef\temp@expand@sets{%
        \noexpand\setLayoutMag{\aebDeclareInitView@layoutmag}%
        \noexpand\setWindowOptions{\aebDeclareInitView@windowoptions}%
        \noexpand\setUIOptions{\aebDeclareInitView@uioptions}%
    }\temp@expand@sets
}
%    \end{macrocode}
%    \end{macro}
% Additional Open action
%    \begin{macro}{\addtionalOpenAction}
%    \begin{macro}{\requiresVersion}
%    \begin{macro}{\alternateDocumentURL}
%    \begin{macro}{\requiredVersionMsg}
%    \begin{macro}{\requiredVersionMsgRedirect}
%    \begin{macro}{\afterRequirementPassedJS}
% \cs{additionalOpenAction} can be used to add in additional action that is performed with the
% document is opened. This is different from the actions that may be performed when the first page
% is opened.  In fact, this action is independent of what what page is initially opened.
%
% \cs{requiresVersion} can be used to put a version condition on viewing the document. \cs{requiresVersion}
% uses \cs{additionalOpenAction}. If you want to combine several actions, including a version requirement
% you''l have to use \cs{additionalOpenAction}. Usage:
%\begin{verbatim}
%\requiresVersion{7}
%\end{verbatim}
% \cs{requireVersionMsg} is the message that is displayed when the version condition is not met.
%    \begin{macrocode}
\let\aeb@additionalOpenAction\@empty
\newcommand{\addtionalOpenAction}[1]{%
    \def\aeb@additionalOpenAction{/Next {aebAdditionalOpenAction}}%
    \setLayoutMag{}%
    \literalps@out{[/_objdef {aebAdditionalOpenAction} /type/dict /OBJ pdfmark
    [ {aebAdditionalOpenAction} << #1 >> /PUT pdfmark}%
}
\newcommand{\requiresVersion}[1]{%
    \def\requiredVersionNumber{#1}\addtionalOpenAction{\JS{%
    if(app.viewerVersion < #1 ) {
    try {
        if (this.external) {
            app.alert("\aeb@requiredVersionMsgRedirect");
            if (app.viewerVersion >= 7.0)
                app.launchURL("\aebAlternateDocumentURL");
            else
                this.getURL("\aebAlternateDocumentURL",false);
        } else {
            app.alert("\aeb@requiredVersionMsg");
%            waitToLoad=app.setTimeOut("app.clearInterval(waitToLoad);"
%            + "this.closeDoc(true);",250);
            this.closeDoc(true);
        }
    } catch(e) {};
    } else {
        \aeb@ViewerPassedRequirementJS
    }
}}}
\def\requiredVersionNumber{7}
\newcommand{\alternateDocumentURL}[1]{\def\aebAlternateDocumentURL{#1}}
\alternateDocumentURL{http://www.acrotex.net/}
\newcommand{\requiredVersionMsg}[1]{\def\aeb@requiredVersionMsg{#1}}
\requiredVersionMsg{This document requires Adobe Reader or Acrobat,
    version \requiredVersionNumber\space or later. The document is now
    closing.}
\newcommand{\requiredVersionMsgRedirect}[1]{%
    \def\aeb@requiredVersionMsgRedirect{#1}}
\requiredVersionMsgRedirect{%
    This document requires Adobe Reader or Acrobat,
    version \requiredVersionNumber\space or later.
    Redirecting browser to an alternate page.}
\newcommand{\afterRequirementPassedJS}[1]{%
    \def\aeb@ViewerPassedRequirementJS{#1}}
\let\aeb@ViewerPassedRequirementJS\@empty
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
% Now let's put it all together.
%    \begin{macrocode}
\def\aeb@SetCatalog{\literalps@out{%
[ {Catalog} <</ViewerPreferences<<%
    \ifx\aeb@windowoptsFitWindow\@empty\else
        \aeb@windowoptsFitWindow\fi
    \ifx\aeb@windowoptsCenterWindow\@empty\else
        \aeb@windowoptsCenterWindow\fi
    \ifx\aeb@windowoptsDisplayDocTitle\@empty\else
        \aeb@windowoptsDisplayDocTitle\fi
    \ifx\aeb@uioptsHideToolbar\@empty\else
        \aeb@uioptsHideToolbar\fi
    \ifx\aeb@uioptsHideMenubar\@empty\else
        \aeb@uioptsHideMenubar\fi
    \ifx\aeb@uioptsHideWindowUI\@empty\else
        \aeb@uioptsHideWindowUI\fi
    \ifx\aeb@layoutMagNaviTab\@empty\else
        /NonFullScreenPageMode/\aeb@layoutMagNaviTab\fi
    >>%
    \ifx\aeb@layoutMagPageLayout\@empty\else
        /PageLayout/\aeb@layoutMagPageLayout%
    \fi
    \ifx\aeb@windowoptsFullScreen\@empty
        \ifx\aeb@layoutMagNaviTab\@empty\else
            /PageMode/\aeb@layoutMagNaviTab%
        \fi
    \else
        /PageMode/FullScreen%
    \fi
    \ifx\aeb@layoutMagPage\@empty
        \ifx\aeb@layoutMagMag\@empty
        \else
            /OpenAction<</D[{Page1}\aeb@layoutMagMag]/S/GoTo\aeb@additionalOpenAction>>%
        \fi
    \else
        \ifx\aeb@layoutMagMag\@empty
            /OpenAction<</D[{\aeb@layoutMagPage}/Fit]/S/GoTo\aeb@additionalOpenAction>>%
        \else
            /OpenAction<</D[{\aeb@layoutMagPage}\aeb@layoutMagMag]/S/GoTo\aeb@additionalOpenAction>>%
        \fi
    \fi
>> /PUT pdfmark}}
\AtBeginDocument{\aeb@SetCatalog}
%    \end{macrocode}
% \section{Fullscreen and Transitions}
% \subsection{\texorpdfstring{\cs{setDefaultFS}}{\textbackslash setDefaultFS}}
%    \begin{macro}{\setDefaultFS}
% Use \cs{setDefaultFS} to set the defaults for fullscreen
% mode in the Adobe Reader or Acrobat.
%    \begin{macrocode}
\newcommand{\setDefaultFS}[1]
{%
    \setkeys{aebDefFS}{Trans=Replace}\setkeys{aebDefFS}{#1}%
    \makeatletter
    \InputIfFileExists{fsprodef.js}{}{\PackageWarning{aeb}
        {Cannot find fsdef.js, please run aeb.ins again}}
    \makeatother
}
\@onlypreamble\setDefaultFS
%    \end{macrocode}
%    \end{macro}
%
% Definitions of key-values for supported transitions;  these are set using the command
% \cs{setDefaultFS}.
%
%    \begin{macrocode}
%\define@key{aebDefFS}{Trans}[]{%
%    \def\aeb@arg{#1}\ifx\aeb@arg\@empty
%    \let\aeb@fsTran=\@empty\else
%    \def\aeb@fsTran{app.fs.defaultTransition = "#1";^^J}\fi}
%\let\aeb@fsTran=\@empty
\def\aeb@NoTransition{NoTransition}
\define@choicekey+{aebDefFS}{Trans}
{NoTransition,UncoverLeft,UncoverRight,UncoverDown,UncoverUp,%
UncoverLeftDown,UncoverLeftUp,UncoverRightDown,UncoverRightUp,%
CoverLeft,CoverRight,CoverDown,CoverUp,CoverLeftDown,CoverLeftUp,%
CoverRightDown,CoverRightUp,PushLeft,PushRight,PushDown,PushUp,%
PushLeftDown,PushLeftUp,PushRightDown,PushRightUp,FlyInRight,%
FlyInLeft,FlyInDown,FlyInUp,FlyOutRight,FlyOutLeft,FlyOutDown,%
FlyOutUp,FlyIn,FlyOut,Blend,Fade,Random,Dissolve,%
GlitterRight,GlitterDown,GlitterRightDown,BoxIn,BoxOut,%
BlindsHorizontal,BlindsVertical,SplitHorizontalIn,%
SplitHorizontalOut,SplitVerticalIn,SplitVerticalOut,WipeLeft,%
WipeRight,WipeDown,WipeUp,WipeLeftDown,WipeLeftUp,%
WipeRightDown,WipeRightUp,Replace,ZoomInDown,ZoomInLeft,%
ZoomInLeftDown,ZoomInLeftUp,ZoomInRight,ZoomInRightDown,%
ZoomInRightUp,ZoomInUp,ZoomOutDown,ZoomOutLeft,ZoomOutLeftDown,%
ZoomOutLeftUp,ZoomOutRight,ZoomOutRightDown,ZoomOutRightUp,%
ZoomOutUp,CombHorizontal,CombVertical}[Replace]{%
    \def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@fsTran=\@empty\else
    \ifx\aeb@arg\aeb@NoTransition
        \def\aeb@fsTran{app.fs.defaultTransition = "";^^J}
    \else
    \def\aeb@fsTran{app.fs.defaultTransition = "#1";^^J}\fi\fi}
{\PackageWarning{aeb}{Bad choice, try again. Meanwhile,
    will use the default, Replace}%
    \def\aeb@fsTran{app.fs.defaultTransition = "Replace";^^J}}
\define@key{aebDefFS}{bgColor}[]{%
    \def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@fsBGColor=\@empty\else
    \def\aeb@fsBGColor{app.fs.backgroundColor = #1;^^J}\fi}
\let\aeb@fsBGColor=\@empty
\define@key{aebDefFS}{timeDelay}[]{%
    \def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@fstimeDelay=\@empty\else
    \def\aeb@fstimeDelay{app.fs.timeDelay = #1;^^J}\fi}
\let\aeb@fstimeDelay=\@empty
\define@boolkey{aebDefFS}{loop}[true]{%
    \def\aeb@fsLoop{app.fs.loop = #1;^^J}}
\let\aeb@fsLoop=\@empty
\define@choicekey+{aebDefFS}{cursor}{hidden,delay,visible}{%
    \def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@fscursor=\@empty\else
    \def\aeb@fscursor{app.fs.cursor = cursor.#1;^^J}\fi
}{\PackageWarning{aeb}{Bad choice for cursor, permissible values
   are hidden, delay and visible. Try again}}
\let\aeb@fscursor=\@empty
\define@boolkey{aebDefFS}{escape}[true]{%
    \def\aeb@fsEscape{app.fs.escapeExits = #1;^^J}}
\let\aeb@fsEscape=\@empty
\define@boolkey{aebDefFS}{clickAdv}[true]{%
    \def\aeb@fsclickAdv{app.fs.clickAdvances = #1;^^J}}
\let\aeb@fsclickAdv=\@empty
\define@boolkey{aebDefFS}{fullscreen}[true]{%
%    \hypersetup{pdfpagemode=FullScreen}
        \def\aeb@windowoptsFullScreen{true}%
%    \def\aeb@fsFS{app.fs.isFullScreen = #1;^^J}
}
\let\aeb@fsFS=\@empty
\define@boolkey{aebDefFS}{useTimer}[true]{%
    \def\aeb@fsuseTimer{app.fs.useTimer = #1;^^J}}
\let\aeb@fsuseTimer=\@empty
\define@boolkey{aebDefFS}{usePageTiming}[true]{%
    \def\aeb@fsusePageTiming{app.fs.usePageTiming = #1;^^J}}
\let\aeb@fsusePageTiming=\@empty
%    \end{macrocode}
% \subsection{\texorpdfstring{\cs{setPageTransition}}{\textbackslash setPageTransition}}
%    \begin{macro}{\setPageTransition}
% By setting the \texttt{aebTrans} family of keys, you can change the transition
% effect of the next slide.
%    \begin{macrocode}
\newcommand{\setPageTransition}[1]{%
    \begingroup
    \setkeys{aebTrans}{TransDur,Speed}%
    \setkeys{aebTrans}{#1}%
    \ifx\aeb@TranChoice\@empty\else
    \literalps@out{ [ {ThisPage} << \aeb@Page@Dur
        /Trans <<\aeb@Trans@Dur\aeb@TranChoice>> >> /PUT pdfmark}%
    \fi
    \endgroup
}
\newcommand{\setPageTransitionAt}[2]{%
    \begingroup
    \setkeys{aebTrans}{#2}%
    \ifx\aeb@TranChoice\@empty\else
        \expandafter\aebp@rse\expandafter{#1}%
        \edef\shakeandbake{%
            \noexpand\@for\noexpand\@mytoks:=\the\aeb@parsetoks}%
        \shakeandbake \do {%
            \literalps@out{ [ {Page\@mytoks} << \aeb@Page@Dur
            /Trans <<\aeb@Trans@Dur\aeb@TranChoice>> >> /PUT pdfmark}%
        }%
    \fi
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
% There are the 50 transitions effects as listed by
% \texttt{app.fs.transitions} plus one more called
% ``\texttt{NoTransition}''. The \texttt{pdfmark} code accurately
% represents each of this options.
%    \begin{macrocode}
\define@choicekey+{aebTrans}{Trans}
{NoTransition,UncoverLeft,UncoverRight,UncoverDown,UncoverUp,%
UncoverLeftDown,UncoverLeftUp,UncoverRightDown,UncoverRightUp,%
CoverLeft,CoverRight,CoverDown,CoverUp,CoverLeftDown,CoverLeftUp,%
CoverRightDown,CoverRightUp,PushLeft,PushRight,PushDown,PushUp,%
PushLeftDown,PushLeftUp,PushRightDown,PushRightUp,FlyInRight,%
FlyInLeft,FlyInDown,FlyInUp,FlyOutRight,FlyOutLeft,FlyOutDown,%
FlyOutUp,FlyIn,FlyOut,Blend,Fade,Random,Dissolve,%
GlitterRight,GlitterDown,GlitterRightDown,BoxIn,BoxOut,%
BlindsHorizontal,BlindsVertical,SplitHorizontalIn,%
SplitHorizontalOut,SplitVerticalIn,SplitVerticalOut,WipeLeft,%
WipeRight,WipeDown,WipeUp,WipeLeftDown,WipeLeftUp,%
WipeRightDown,WipeRightUp,Replace,ZoomInDown,ZoomInLeft,%
ZoomInLeftDown,ZoomInLeftUp,ZoomInRight,ZoomInRightDown,%
ZoomInRightUp,ZoomInUp,ZoomOutDown,ZoomOutLeft,ZoomOutLeftDown,%
ZoomOutLeftUp,ZoomOutRight,ZoomOutRightDown,ZoomOutRightUp,%
ZoomOutUp,CombHorizontal,CombVertical}[Replace]%
    {\edef\aeb@TranChoice{\csname aeb@Trans@#1\endcsname}%
}{\PackageWarning{aeb}{Bad choice, try again}}
\let\aeb@TranChoice=\@empty
\define@key{aebTrans}{TransDur}[]{\def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@Trans@Dur=\@empty\else\def\aeb@Trans@Dur{/D #1}\fi}
\let\aeb@Trans@Dur=\@empty
%    \end{macrocode}
% Length of duration of transition effect: Slow, Medium, Fast
%    \begin{macrocode}
\define@choicekey+{aebTrans}{Speed}[\val\nr]%
    {Slow,Medium,Fast}[Slow]{%dps/change 02/27/07
    \ifcase\nr\relax
        \let\aeb@Trans@Speed\@empty\or
        \def\aeb@Trans@Speed{/D 0.666656}\or
        \def\aeb@Trans@Speed{/D 0.333328}
    \fi
}{\PackageWarning{aeb}{Bad choice for Speed, permissible values
   are Slow, Medium and Fast. Try again}}
\let\apb@apbTrans@Speed\@empty
%    \end{macrocode}
%    \begin{macrocode}
\define@key{aebTrans}{PageDur}[]{\def\aeb@arg{#1}\ifx\aeb@arg\@empty
    \let\aeb@Page@Dur=\@empty\else\def\aeb@Page@Dur{/Dur #1}\fi}
%    \end{macrocode}
%    \begin{macrocode}
\let\aeb@Page@Dur=\@empty
\def\aeb@Trans@NoTransition{}
\def\aeb@Trans@SplitHorizontalIn{/Dm/H/M/I/S/Split}
\def\aeb@Trans@SplitHorizontalOut{/Dm/H/M/O/S/Split}
\def\aeb@Trans@SplitVerticalIn{/Dm/V/M/I/S/Split}
\def\aeb@Trans@SplitVerticalOut{/Dm/V/M/O/S/Split}
\def\aeb@Trans@BlindsHorizontal{/Dm/H/S/Blinds}
\def\aeb@Trans@BlindsVertical{/Dm/V/S/Blinds}
\def\aeb@Trans@BoxIn{/M/I/S/Box}
\def\aeb@Trans@BoxOut{/M/O/S/Box}
\def\aeb@Trans@WipeLeft{/Di 180/S/Wipe}
\def\aeb@Trans@WipeRight{/Di 0/S/Wipe}
\def\aeb@Trans@WipeDown{/Di 270/S/Wipe}
\def\aeb@Trans@WipeUp{/Di 90/S/Wipe}
\def\aeb@Trans@Dissolve{/S/Dissolve}
\def\aeb@Trans@GlitterRight{/Di 0/S/Glitter}
\def\aeb@Trans@GlitterDown{/Di 270/S/Glitter}
\def\aeb@Trans@GlitterRightDown{/Di 315/S/Glitter}
\def\aeb@Trans@Replace{/S/R}
\def\aeb@Trans@FlyInRight{/Di 0/M/I/S/Fly}
\def\aeb@Trans@FlyInLeft{/Di 180/M/I/S/Fly}
\def\aeb@Trans@FlyInDown{/Di 270/M/I/S/Fly}
\def\aeb@Trans@FlyInUp{/Di 90/M/I/S/Fly}
\def\aeb@Trans@FlyOutRight{/Di 0/M/O/S/Fly}
\def\aeb@Trans@FlyOutLeft{/Di 180/M/O/S/Fly}
\def\aeb@Trans@FlyOutDown{/Di 270/M/O/S/Fly}
\def\aeb@Trans@FlyOutUp{/Di 90/M/O/S/Fly}
\def\aeb@Trans@FlyIn{/M/I/S/Fly}
\def\aeb@Trans@FlyOut{/M/O/S/Fly}
\def\aeb@Trans@PushLeft{/Di 180/S/Push}
\def\aeb@Trans@PushRight{/Di 0/S/Push}
\def\aeb@Trans@PushDown{/Di 270/S/Push}
\def\aeb@Trans@PushUp{/Di 90/S/Push}
\def\aeb@Trans@CoverLeft{/Di 180/S/Cover}
\def\aeb@Trans@CoverRight{/Di 0/S/Cover}
\def\aeb@Trans@CoverDown{/Di 270/S/Cover}
\def\aeb@Trans@CoverUp{/Di 90/S/Cover}
\def\aeb@Trans@CoverLeftDown{/Di 225.0/S/Cover}
\def\aeb@Trans@CoverLeftUp{/Di 135.0/S/Cover}
\def\aeb@Trans@CoverRightDown{/Di 315.0/S/Cover}
\def\aeb@Trans@CoverRightUp{/Di 45.0/S/Cover}
\def\aeb@Trans@UncoverLeft{/Di 180/S/Uncover}
\def\aeb@Trans@UncoverRight{/Di 0/S/Uncover}
\def\aeb@Trans@UncoverDown{/Di 270/S/Uncover}
\def\aeb@Trans@UncoverUp{/Di 90/S/Uncover}
\def\aeb@Trans@UncoverLeftDown{/Di 225.0/S/Uncover}
\def\aeb@Trans@UncoverLeftUp{/Di 135.0/S/Uncover}
\def\aeb@Trans@UncoverRightDown{/Di 315.0/S/Uncover}
\def\aeb@Trans@UncoverRightUp{/Di 45.0/S/Uncover}
\def\aeb@Trans@Fade{/S/Fade}
\def\aeb@Trans@Random{/S/Random}
\def\aeb@Trans@Blend{/S/Blend}
%    \end{macrocode}
% New Transitions for Acrobat 8.0
%    \begin{macrocode}
\def\aeb@Trans@PushLeftDown{%
    /S/Push/Directional/BiDir/Di 225.0/Curve/Easy}
\def\aeb@Trans@PushLeftUp{%
    /S/Push/Directional/BiDir/Di 135.0/Curve/Easy}
\def\aeb@Trans@PushRightDown{%
    /S/Push/Directional/BiDir/Di 315.0/Curve/Easy}
\def\aeb@Trans@PushRightUp{%
    /S/Push/Directional/BiDir/Di 45.0/Curve/Easy}
\def\aeb@Trans@WipeLeftDown{%
    /S/Wipe/Directional/BiDir/Di 225/Curve/Easy}
\def\aeb@Trans@WipeLeftUp{%
    /S/Wipe/Directional/BiDir/Di 135/Curve/Easy}
\def\aeb@Trans@WipeRightDown%
    {/S/Wipe/Directional/BiDir/Di 315/Curve/Easy}
\def\aeb@Trans@WipeRightUp{%
    /S/Wipe/Directional/BiDir/Di 45/Curve/Easy}
\def\aeb@Trans@ZoomInDown{%
    /S/ZoomIn/Directional/BiDir/Di 270.0/Curve/Easy}
\def\aeb@Trans@ZoomInLeft{%
    /S/ZoomIn/Directional/BiDir/Di 180.0/Curve/Easy}
\def\aeb@Trans@ZoomInLeftDown{%
    /S/ZoomIn/Directional/BiDir/Di 225.0/Curve/Easy}
\def\aeb@Trans@ZoomInLeftUp{%
    /S/ZoomIn/Directional/BiDir/Di 135.0/Curve/Easy}
\def\aeb@Trans@ZoomInRight{%
    /S/ZoomIn/Directional/BiDir/Di 0.0/Curve/Easy}
\def\aeb@Trans@ZoomInRightDown{%
    /S/ZoomIn/Directional/BiDir/Di 315.0/Curve/Easy}
\def\aeb@Trans@ZoomInRightUp{%
    /S/ZoomIn/Directional/BiDir/Di 45.0/Curve/Easy}
\def\aeb@Trans@ZoomInUp{%
    /S/ZoomIn/Directional/BiDir/Di 90.0/Curve/Easy}
\def\aeb@Trans@ZoomOutDown{%
    /S/ZoomOut/Directional/BiDir/Di 270.0/Curve/Easy}
\def\aeb@Trans@ZoomOutLeft{%
    /S/ZoomOut/Directional/BiDir/Di 180.0/Curve/Easy}
\def\aeb@Trans@ZoomOutLeftDown{%
    /S/ZoomOut/Directional/BiDir/Di 225.0/Curve/Easy}
\def\aeb@Trans@ZoomOutLeftUp{%
    /S/ZoomOut/Directional/BiDir/Di 135.0/Curve/Easy}
\def\aeb@Trans@ZoomOutRight{%
    /S/ZoomOut/Directional/BiDir/Di 0.0/Curve/Easy}
\def\aeb@Trans@ZoomOutRightDown{%
    /S/ZoomOut/Directional/BiDir/Di 315.0/Curve/Easy}
\def\aeb@Trans@ZoomOutRightUp{%
    /S/ZoomOut/Directional/BiDir/Di 45.0/Curve/Easy}
\def\aeb@Trans@ZoomOutUp{%
    /S/ZoomOut/Directional/BiDir/Di 90.0/Curve/Easy}
\def\aeb@Trans@CombHorizontal{%
    /S/Comb/Directional/BiDir/Dm/H/Curve/Easy}
\def\aeb@Trans@CombVertical{%
    /S/Comb/Directional/BiDir/Dm/V/Curve/Easy}
%    \end{macrocode}
%    \begin{macrocode}
%</aebpro>
%<*fsdefjs>
%    \end{macrocode}
% \subsection{JS for Fullscreen Support}
%  The ``Presentation Defaults'' are used in conjunction with the
%  \cs{setDefaultFS} for setting the defaults of the application. These
%  settings can be viewed under the \texttt{Edit > Preferences >
%  General > Full Screen}. This script save the viewers preferences,
%  sets them according the needs of the document author, and upon
%  closing the document, resets the original preferences. The last task
%  is performed by the \texttt{willClose} environment.
%    \begin{macrocode}
\begin{insDLJS}[_fsDefaults]{fsdef}{AeB Pro: Presentation Defaults}
var _fsDefaults = true;
%if ( typeof global.fsexec == "undefined" )
if ( typeof fsexec == "undefined" )
{
    try {
        var fsexec = true;
%        global.fsexec = true;
        var aebdefaultTransition = app.fs.defaultTransition;
        var aebbackgroundColor = app.fs.backgroundColor;
        var aebloop = app.fs.loop;
        var aebtimeDelay = app.fs.timeDelay;
        var aebuseTimer = app.fs.useTimer
        var aebusePageTiming = app.fs.usePageTiming;
        var aebclickAdvances = app.fs.clickAdvances;
        var aebcursor = app.fs.cursor;
        var aebescapeExits = app.fs.escapeExits;
\aeb@fsTran%
\aeb@fsBGColor%
\aeb@fsLoop%
\aeb@fsclickAdv%
\aeb@fscursor%
\aeb@fstimeDelay%
\aeb@fsuseTimer%
\aeb@fsusePageTiming%
\aeb@fsEscape%
\aeb@fsFS%
    } catch(e) {}
}
\end{insDLJS}
%    \end{macrocode}
% This is a series of script lines that will be inserted into the \texttt{willClose}
% section of the document. These will attempt to restore the user's full screen
% defaults.
%    \begin{macrocode}
\begin{fs@willClose}
try {
    delete global.fsexec;
    app.fs.defaultTransition = aebdefaultTransition;
    app.fs.backgroundColor = aebbackgroundColor;
    app.fs.loop = aebloop;
    app.fs.timeDelay = aebtimeDelay;
    app.fs.useTimer = aebuseTimer;
    app.fs.usePageTiming = aebusePageTiming;
    app.fs.clickAdvances = aebclickAdvances;
    app.fs.cursor = aebcursor;
    app.fs.escapeExits = aebescapeExits;
} catch(e) { console.println("Could not reset on of the defaults"); }
\end{fs@willClose}
%    \end{macrocode}
%    \begin{macrocode}
%</fsdefjs>
%<*aebpro>
%    \end{macrocode}
% \section{Set Page Actions}
%    \begin{environment}{addJSToPageOpen}
%    \begin{environment}{addJSToPageOpenAt}
%    \begin{environment}{addJSToPageClose}
%    \begin{environment}{addJSToPageCloseAt}
% The document author can add to the default page open action through
% this environment. Use this environment between slides, effective
% the next slide. The first slide (possibly generated by
% \cs{maketitle}) is a special case: When setting the open and close
% page actions for the first page, these environments \emph{must go}
% in the preamble.
%    \begin{macrocode}
\def\canceleveryPageOpen{\global\@everyPageOpenfalse
    \global\let\every@PageOpen\@empty}
\def\canceleveryPageClose{\global\@everyPageClosefalse
    \global\let\every@PageClose\@empty}
\newenvironment{everyPageOpen}[1][]
{\global\@everyPageOpentrue\@defineJS[#1]{\every@PageOpen}}
{\end@defineJS}
\newenvironment{everyPageClose}[1][]
{\global\@everyPageClosetrue\@defineJS[#1]{\every@PageClose}}
{\end@defineJS}
\let\every@PageOpen\@empty
\let\every@PageClose\@empty
\newenvironment{addJSToPageOpen}[1][]
{\@defineJS[#1]{\addJST@PageOpen}}
{\end@defineJS
    \ifnum\value{page}=1\relax
    \gdef\myAddtoOpenJS{\OpenAction{\JS{\addJST@PageOpen}}}%
    \expandafter\aftergroup\expandafter\myAddtoOpenJS\fi
}
\newenvironment{addJSToPageOpenAt}[2][]
{\@@defineJS[#1]{addJST@PageOpenAt}{#2}}
{\end@@defineJS}
\newenvironment{addJSToPageClose}[1][]
{\@defineJS[#1]{\addJST@PageClose}}
{\end@defineJS
    \ifnum\value{page}=1\relax
    \gdef\myAddtoCloseJS{%
        \gdef\@CloseAction{/C << \JS{\addJST@PageClose} >>}}%
    \expandafter\aftergroup\expandafter\myAddtoCloseJS\fi
}
\newenvironment{addJSToPageCloseAt}[2][]
{\@@defineJS[#1]{addJST@PageCloseAt}{#2}}
{\end@@defineJS}
\let\addJST@PageOpen=\@empty
\let\addJST@PageClose=\@empty
%    \end{macrocode}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \begin{macro}{\aeb@addToPageOpenCloseActions}
% This command gets expanded by \cs{AddToShipoutPicture} for each page. Here we
% define how our page actions are to be inserted.
%    \begin{macrocode}
\def\aeb@addToPageOpenCloseActions{%
    \@ifundefined{addJST@PageOpenAt\the\c@page}%
        {\def\thisOpenPageActionAt{\@empty}}%
        {\def\thisOpenPageActionAt{%
            \csname addJST@PageOpenAt\the\c@page\endcsname}}%
    \@ifundefined{addJST@PageCloseAt\the\c@page}%
        {\gdef\thisClosePageActionAt{\@empty}}%
        {\gdef\thisClosePageActionAt{%
            \csname addJST@PageCloseAt\the\c@page\endcsname}}%
    \aebPageAction{\thisOpenPageActionAt\addJST@PageOpen}%
        {\thisClosePageActionAt\addJST@PageClose}%
    \global\let\addJST@PageOpen\@empty\global\let\addJST@PageClose\@empty
}
\AddToShipoutPicture{\aeb@addToPageOpenCloseActions}
%    \end{macrocode}
%    \end{macro}
% \cs{@@defineJS} is a variation of \cs{@defineJS}, as defined in the \textsf{insdljs} package.
% This version, at the end of the environment, calls the \cs{aebp@rse} command to parse the
% complex command argument, then makes a series of definitions to be used in the open/close
% page events.
%    \begin{macrocode}
\newenvironment{@@defineJS}[3][]
{%
    \gdef\argType{#2}%
    \gdef\defineJSArg{#3}\JStoks={}%
    \def\verbatim@processline
        {%
            \xdef\JS@temp{\the\JStoks\the\verbatim@line\defineJSjsR}%
            \global\JStoks=\expandafter{\JS@temp}%
        }%
    \let\do\@makeother\dospecials\catcode`\^^M\active
    #1%
    \verbatim@start
}{%
    \expandafter\aebp@rse\expandafter{\defineJSArg}%
    \edef\shakeandbake{\noexpand\@for\noexpand\@mytoks:=\the\aeb@parsetoks}%
    \aeb@parsecnt=0 \shakeandbake \do {%
        \ifnum\aeb@parsecnt=0
            \edef\firsttok{\@mytoks}%
            \expandafter\xdef\csname\argType\@mytoks\endcsname{\the\JStoks}%
        \else
            \edef\letsmakelet{\global\let\expandafter\noexpand\csname\argType\@mytoks\endcsname=\expandafter\noexpand\csname\argType\firsttok\endcsname}%
            \letsmakelet
        \fi
        \advance\aeb@parsecnt1
    }%
}
%    \end{macrocode}
%    \begin{macrocode}
\newif\ifaeb@PageOpen
\newif\ifaeb@PageClose
\newif\if@everyPageOpen\@everyPageOpenfalse
\newif\if@everyPageClose\@everyPageClosefalse
%    \end{macrocode}
%    \begin{macro}{\aebPageAction}
% This is use internally, but can be used by the document author. The commands creates the code
% to set an open page and a close page action. The first (optional) argument is a the page number (base 1),
% this optional argument defaults to the current page if no page number is given. The second and third
% arguments are the open and closed JavaScript actions.
%
% If the document author uses this command, he my overwrite actions created by the \texttt{addJSTo...}
% environments. See \cs{aeb@addToPageOpenCloseActions} for usage by this package.
%    \begin{macrocode}
\newcommand\aebPageAction[3][ThisPage]{%
    \let\ispageactions=0\aeb@PageOpenfalse\aeb@PageOpenfalse
    \def\@aebOpen{#2}%
    \if1\@aebOpen1%
        \if@everyPageOpen
            \aeb@PageOpentrue\let\ispageactions=1%
            \def\@aebOpen{/O << \JS{\every@PageOpen#2} >>}%
        \fi
    \else
        \let\ispageactions=1%
        \aeb@PageOpentrue
        \def\@aebOpen{/O << \JS{\every@PageOpen#2} >>}%
    \fi
    \def\@aebClose{#3}%
    \if1\@aebClose1%
        \if@everyPageClose
            \aeb@PageClosetrue\let\ispageactions=1%
            \def\@aebClose{/C << \JS{\every@PageClose#3} >>}%
        \fi
    \else
        \let\ispageactions=1%
        \aeb@PageClosetrue
        \def\@aebClose{/C << \JS{\every@PageClose#3} >>}%
    \fi
    \if@everyPageOpen\aeb@PageOpentrue\let\ispageactions=1\fi
    \if@everyPageClose\@everyPageClosetrue\let\ispageactions=1\fi
    \if\ispageactions1%
    \literalps@out{[ {#1} << /AA
        << \ifaeb@PageOpen\@aebOpen\space\fi
           \ifaeb@PageClose\@aebClose\space\fi >> >> /PUT pdfmark}%
    \fi
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\atPage}
% \cs{atPage} is a modification of \cs{pageref}, so its value will always be an integer.
% returned in the token register \cs{aeb@parsetoks}. Used in the arguments of such environments
% as \texttt{addJSToPageOpenAt} and \texttt{addJSToPageCloseAt}.
%    \begin{macrocode}
\def\aeb@exiii{\expandafter\expandafter\expandafter}
\let\ahrefexafter\aeb@exiii
\def\atPage#1{\@ifundefined{r@#1}{1}
    {\aeb@exiii\@secondoffive\csname r@#1\endcsname}}
\def\labelRef#1{\@ifundefined{r@#1}{Doc-Start}
    {\aeb@exiii\@fourthoffive\csname r@#1\endcsname}}
%    \end{macrocode}
%    \end{macro}
% The command \cs{aebp@rse} parses such arguments as
%\begin{verbatim}
%   {1,3,4-6,8-12,15,\atPage{firstlabel}-\atPage{secondlabel},30-}
%\end{verbatim}
% The expanded list is returned in the token register \cs{aeb@parsetoks}.
%    \begin{macrocode}
\newtoks\aeb@parsetoks
\newcount\aeb@parsecnt
\def\aeb@removelastcomma#1,\@nil{\aeb@parsetoks={#1}}
\def\aebp@rse#1{\aeb@parsetoks={}\aeb@parse#1,\relax}
\def\aeb@parse{\@ifnextchar\relax
    {\expandafter\aeb@removelastcomma\the\aeb@parsetoks\@nil}
    {\aeb@@parse}}
\def\aeb@@parse#1,{\aeb@@@parse#1-\@nil}
\def\aeb@@@parse#1-#2\@nil{%
    \def\argi{#2}\ifx\argi\@empty\def\aeb@next{\aeb@@@@parse{#1}}\else
        \def\aeb@next{\aeb@@@@@parse#1-#2}\fi\aeb@next
}
\def\aeb@@@@parse#1{%single page #1
    \aeb@parsecnt=#1
    \edef\edefaeb@parsetoks{\the\aeb@parsetoks\the\aeb@parsecnt,}%
    \aeb@parsetoks=\expandafter{\edefaeb@parsetoks}%
%    \par
    \aeb@parse}
\def\aeb@@@@@parse#1-#2-{\def\aeb@lowerlimit{#1}\def\aeb@upperlimit{#2}%
    % range argument from #1 to \csname aebLastPage\endcsname
    \ifx\aeb@upperlimit\@empty
        \@ifundefined{aebLastPage}{\aeb@parsecnt=#1}
            {\expandafter\aeb@parsecnt\expandafter=\csname aebLastPage\endcsname}%
    \else % page range #1 to #2, switch the two if #2 < #1
        \aeb@parsecnt=\aeb@lowerlimit
        \edef\aeb@lowerlimit{\the\aeb@parsecnt}
        \aeb@parsecnt=\aeb@upperlimit
        \ifnum\aeb@parsecnt<\aeb@lowerlimit\relax
            \aeb@parsecnt=\aeb@lowerlimit
            \def\aeb@lowerlimit{#2}%
            \def\aeb@upperlimit{#1}%
        \fi
    \fi
       \advance\aeb@parsecnt1
       \edef\aeb@upperlimit{\the\aeb@parsecnt}%
       \aeb@parsecnt=\aeb@lowerlimit
    \loop
        \edef\edefaeb@parsetoks{\the\aeb@parsetoks\the\aeb@parsecnt,}%
        \aeb@parsetoks=\expandafter{\edefaeb@parsetoks}%
        \advance\aeb@parsecnt1
    \ifnum\aeb@parsecnt < \aeb@upperlimit\repeat
%    \par
    \aeb@parse}
%    \end{macrocode}
% \section{Set Document Actions}
%    \begin{environment}{willClose}
%    \begin{environment}{willSave}
%    \begin{environment}{didSave}
%    \begin{environment}{willPrint}
%    \begin{environment}{didPrint}
% We add a \texttt{willClose} environment, not really meant for the document
% author to use. This environment is used with \cs{setDefaultFS} for saving
% setting and restoring the application preferences for full screen.
%    \begin{macrocode}
\newenvironment{willClose}
{\@defineJS{\will@Close}}
{\end@defineJS}
\let\will@Close=\@empty
\newenvironment{fs@willClose}
{\@defineJS{\fs@will@Close}}
{\end@defineJS}
\let\fs@will@Close\@empty
\newenvironment{willSave}
{\@defineJS{\will@Save}}
{\end@defineJS}
\let\will@Save=\@empty
\newenvironment{didSave}
{\@defineJS{\did@Save}}
{\end@defineJS}
\let\did@Save=\@empty
\newenvironment{willPrint}
{\@defineJS{\will@Print}}
{\end@defineJS}
\let\will@Print=\@empty
\newenvironment{didPrint}
{\@defineJS{\did@Print}}
{\end@defineJS}
\let\did@Print=\@empty
%    \end{macrocode}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
% Now put the \texttt{willClose} JS into the document \texttt{Catalog}.
%    \begin{macrocode}
\newcommand\@setDocActions{\literalps@out{%
[ {Catalog} << /AA <<
   \ifx\will@Close\@empty\else/WC << /S/JavaScript/JS(\fs@will@Close\will@Close) >>\fi
   \ifx\will@Save\@empty\else/WS << /S/JavaScript/JS(\will@Save) >>\fi
   \ifx\did@Save\@empty\else/DS << /S/JavaScript/JS(\did@Save) >>\fi
   \ifx\will@Print\@empty\else/WP << /S/JavaScript/JS(\will@Print) >>\fi
   \ifx\did@Print\@empty\else/DP << /S/JavaScript/JS(\did@Print) >>\fi
    >> >>
    /PUT pdfmark}%
}
\AtBeginDocument{\@setDocActions}
%    \end{macrocode}
% \section{In support of attachments}
%
% \subsection{Processing the \texttt{attachsource} and \texttt{attachments} key}
%
% If the value of either the attachsource or attachments keys are non empty, the
% values are contained in the macros \cs{aeb@attachsource} and \cs{aeb@attachments}.
% If either of these text macros is different from \cs{empty}, we need to write out
% a cut file that lists the requested attachments, then input the cut file back
% in at the end of the package.
%    \begin{macro}{\aref}
% This command, whose argument is \textit{delimited by parentheses}, is to be used with \cs{inputDataObject}, defined below, to
% expand the value of the \texttt{cName} key, when the label is defined by \cs{labelName}. It is also
% used by this package to set the description of the attachment.
%    \begin{macrocode}
\def\aref(#1){\csname aeb@aName@#1\endcsname}
%    \end{macrocode}
%    \end{macro}
% The next command \cs{aeb@initAttachWrite} we prepare to write by opening a stream, and
% starting the \texttt{execJS} environment, but only if we have an attachment request.
%    \begin{macrocode}
\def\aeb@initAttachWrite{%
    \newwrite \aeb@attachmentswrite
    \immediate\openout \aeb@attachmentswrite \jobname_attach.cut
    \let\verbatim@out\aeb@attachmentswrite
%    \aeb@IWVO{\string\begin{execJS}{attachments}}%
    \aeb@IWVO{\string\begin{execJS}{\jobname_attach}}%
    {\lccode`P=`\{\lowercase{\aeb@IWVO{try P}}}%
}
%    \end{macrocode}
% If either the two attachments keys were used, execute \cs{aeb@initAttachWrite}.
%    \begin{macrocode}
\ifx\aeb@attachsource\@empty
    \ifx\aeb@attachments\@empty
    \else\aeb@initAttachWrite\fi
\else
    \@ifundefined{aeb@attachmentswrite}
    {\aeb@initAttachWrite}{}
\fi
%    \end{macrocode}
% If \cs{aeb@attachsource} is non empty, go through the comma delimited list, and write to the
% cut file we just opened.
%
%    \begin{macrocode}
\ifx\aeb@attachsource\@empty\else
    \edef\temp@expand{\noexpand\@for\noexpand\@@tmp:=\aeb@attachsource}
    \temp@expand\do
    {%
        \aeb@IWVO{\space\space\space\space\string\importDataObject({cName: "\jobname.\@@tmp", cDIPath: "\jobname.\@@tmp"});}%
        \expandafter\edef\csname aeb@aName@\@@tmp\endcsname{\jobname.\@@tmp}
    }
\fi
%    \end{macrocode}
% Similarly, if \cs{aeb@attachments} is non empty, go through the comma delimited list, and write to the
% cut file we just opened.
%
% The attachments are listing in a comma-delimited list. If there is a space following a comma, it may appear
% as part of the path of the next attachment. So, we'll get JavaScript to strip away any leading spaces to
% avoid the need to instruct the user to insert a \texttt{\%} if the attachment list is on multiple lines.
%    \begin{macrocode}
\def\jsstrsps{replace(/^\string\s*/, "")}
%    \end{macrocode}
%    \begin{macrocode}
\ifx\aeb@attachments\@empty\else
    \aeb@parsecnt=0
    \edef\temp@expand{\noexpand\@for\noexpand\@@tmp:=\aeb@attachments}
    \temp@expand\do
    {%
        \advance\aeb@parsecnt1
        \aeb@IWVO{\space\space\space\space\string\importDataObject({cName:"\string\aref(attach\the\aeb@parsecnt)", cDIPath: "\@@tmp".\jsstrsps});}
        \expandafter\xdef\csname aeb@aName@attach\the\aeb@parsecnt\endcsname{AeB Attachment \the\aeb@parsecnt}
    }
\fi
%    \end{macrocode}
% Now, if \cs{aeb@attachmentswrite} is defined, which means we have attachments and we opened a stream,
% we'll close off the environment, and close the file.
%    \begin{macrocode}
\@ifundefined{aeb@attachmentswrite}{}
{%
    {\lccode`P=`\}\def\jsMsg{"Attachments error: " + e.toString()}\lowercase{\aeb@IWVO{P catch(e) { console.println( \jsMsg\space); }}}}%
    \aeb@IWVO{\string\end{execJS}}
    \immediate\closeout \aeb@attachmentswrite
}
%    \end{macrocode}
% Create a little macro to input the file \cs{jobname\_attach.cut} at the end of the package.
%    \begin{macrocode}
\def\aeb@inputAttachments{\@ifundefined{aeb@attachmentswrite}{}
    {\InputIfFileExists{\jobname_attach.cut}%
    {\typeout{Inputting attachments file}}%
    {\typeout{Cannot find attachments file}}}%
}
%    \end{macrocode}
% \subsection{Creating a PDF Package}
% Beginning with Version 8, there is a special "Package" interface to access attachments.
% The commands in this section support creating a PDF Package using the specified attachments.
%
%    \begin{macrocode}
\define@choicekey+{aebpdfpack}{viewmode}[\val\nr]{details,tile,hidden}
{%
    \ifcase\nr\relax
        \def\aeb@pdfpack@viewmode{/D}%
    \or
        \def\aeb@pdfpack@viewmode{/T}%
    \or
        \def\aeb@pdfpack@viewmode{/H}%
    \fi
}{}
\define@key{aebpdfpack}{initview}[]{\def\aeb@pdfpack@initview{#1}}
\let\aeb@pdfpack@initview\@empty
%    \end{macrocode}
%    \begin{macro}{\makePDFPackage}
% Use this command to package the attachments to the parent document.
%    \begin{macrocode}
\newcommand{\makePDFPackage}[1]{%
    \setkeys{aebpdfpack}{viewmode=details}%
    \setkeys{aebpdfpack}{#1}%
    \ifx\aeb@pdfpack@initview\@empty
        \let\aeb@pdfpackage@initview\@empty
    \else
        {\obeyspaces\sanitize@attach\gdef\aeb@pdfpackage@initview{/D<\aeb@exiii\stringiiUnicode\aref(\aeb@pdfpack@initview)\relax>}}%
    \fi
    \def\aeb@setPDFPackage{%
        \literalps@out{[ {Catalog} <<
            /PageMode/UseAttachments
            /Collection<</Type/Collection\aeb@pdfpackage@initview/View\aeb@pdfpack@viewmode>>
        >>/PUT pdfmark}%
    }%
%    \AtBeginDocument{\aeb@setPDFPackage}%
}
\@onlypreamble\makePDFPackage
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</aebpro>
%<*package>
\AtEndOfPackage{\csname aeb@inputAttachments\endcsname}
\AtBeginDocument{\csname aeb@setPDFPackage\endcsname}
%</package>
%<*unicode>
%    \end{macrocode}
% \section{Support for linking to attachments.}
%
% \subsection{{\protect\LaTeX} Support: \cs{ahyperref}, \cs{ahyperlink}, \cs{ahyperextract}}
%
% The \cs{ahyperref} command is for linking between parent and child, or
% between child and child. \cs{ahyperref} takes three arguments, the first optional
% and the second two required.
%\begin{verbatim}
%   \ahyperref[<optargs>]{<label>}{<text>}
%\end{verbatim}
% where \texttt{<label>} is one defined by either \cs{autolabelNum} or \cs{labelName}. The
% \texttt{<text>} is the text to be typeset around the link. The optional arguments are defined
% and described below.
% \begin{itemize}
%   \item \verb!goto=p2c,c2p,c2c!: The type of jump, parent to child, child to parent, and child to
%         child. The default is \texttt{p2c}
%   \item \texttt{page=<number>}: the page of the embedded document to jump to. Default is \texttt{0}
%   \item \texttt{view=<value>}: the view to be used for the jump. Default is \texttt{Fit}
%   \item \texttt{dest=<string>}: jump to a named destination. When this key has a value, the values
%         of the keys \texttt{page} and \texttt{view} are ignored.
%   \item \verb!open=usepref|new|existing!: open the attachment according to the user preferences,
%         a new window, or the existing window. The default is \texttt{userpref}
%   \item \verb!border=visible|invisible!: Determines whether a visible rectangle appears around the
%         link. The default is \texttt{invisible}
%   \item \verb!highlight=none|invert|outline|insert!: How the viewer highlights the link when the
%         link is clicked.  The default is \texttt{invert}.
%   \item \texttt{bordercolor=r g b}: The color of the border when it is visible. The default is black.
%   \item \verb!linestyle=solid|dashed|underlined!: The line style of the border when it is visible.
%         The default is \texttt{solid}
%   \item \verb!linewidth=thin|medium|thick!: The line width when the border is visible. When invisible,
%         this is set to a width of zero. The default is \texttt{thin}
%   \item \texttt{preset=\cs{presetCommand}}: A convenience key. You can define some preset values, like so
%\begin{verbatim}
%\def\preseti{bordercolor={0 0 1},highlight=outline,border=visible,%
%             linestyle=dashed}
%\end{verbatim}
%           Then you can say, for example,
%\begin{verbatim}
%\ahyperref[dest=\labelRef{target1-s:intro},preset=\preseti]{target1}{Jump!}
%\end{verbatim}
% \end{itemize}
%
% The following are the key-values of the optional first argument of \cs{ahyperref}.
%    \begin{macrocode}
\define@key{ahref}{page}[0]{\def\ahref@page{#1}}
\def\ahref@page{0}
%    \end{macrocode}
% The key \texttt{view} represents an ``explicit destination,'' as termed by the PDF Ref, \S8.2.1.
%\begin{itemize}
%   \item \texttt{/XYZ left top zoom}
%   \item \texttt{/Fit}
%   \item \texttt{/FitH top}
%   \item \texttt{/FitV left}
%   \item \texttt{/FitR left bottom right}
%   \item \texttt{/FitB}
%   \item \texttt{/FitBH top}
%   \item \texttt{/FitBV left}
%\end{itemize}
% For the view key, enter view=Fit or view=XYB null null null, for example. The forward slash
% is added later.
%
% Each of these is preceded by a page number. The page number is entered via the \texttt{page}
% key.
%
% If a named destination is given with the dest key, then the \texttt{view} and \texttt{page} are ignored.
%    \begin{macrocode}
\define@key{ahref}{view}[Fit]{\def\ahref@view@keyvalue{/#1}}
\def\ahref@view@keyvalue{/Fit}
\define@key{ahref}{dest}[]{\def\ahref@dest{#1}}
\let\ahref@dest\@empty
\define@choicekey{ahref}{open}[\val\nr]{userpref,new,existing}
{%
        \ifcase\nr\relax
            \let\ahref@open@keyvalue\@empty
        \or
            \def\ahref@open@keyvalue{/NewWindow true }%
        \or
            \def\ahref@open@keyvalue{/NewWindow false }%
        \fi
}{}
\define@choicekey{ahref}{border}[\val\nr]{visible,invisible}
{%
    \ifcase\nr\relax
        \def\ahref@border{0 0 1}%
        \def\ahef@invisible@border{1}%
    \or
       \def\ahref@border{0 0 0}% W = 0 also?
       \let\ahef@invisible@border\@empty
    \fi
}{}

\define@choicekey{ahref}{highlight}[\val\nr]{none,invert,outline,insert}
{%
    \ifcase\nr\relax
        \let\ahref@highlight\@empty
    \or
        \def\ahref@highlight{/H/I}%
    \or
        \def\ahref@highlight{/H/O}%
    \or
        \def\ahref@highlight{/H/P}%
    \fi
}{}
\let\ahref@open@keyvalue\@empty
\define@key{ahref}{bordercolor}[]{\def\ahref@bordercolor{#1}} % r g b
\define@choicekey{ahref}{linestyle}[\val\nr]{solid,dashed,underlined}
{%
    \ifcase\nr\relax
        \def\ahref@linestyle@keyvalue{/S/S}%
    \or
        \def\ahref@linestyle@keyvalue{/S/D}% % Dashed [0 0 1[3.0]]
    \or
        \def\ahref@linestyle@keyvalue{/S/U}%
    \fi
}
\def\ahref@dashedlinetyle{/S/D}
\define@choicekey{ahref}{linewidth}[\val\nr]{thin,medium,thick}
{%
    \ifcase\nr\relax
        \def\ahref@linewidth{1}%
    \or
        \def\ahref@linewidth{2}%
    \or
        \def\ahref@linewidth{3}%
    \fi
}
\define@choicekey{ahref}{goto}[\val\nr]{p2c,c2p,c2c}
{%
    \ifcase\nr\relax
        \global\let\targetDictionary\targetDictionary@pc
    \or
        \global\let\targetDictionary\targetDictionary@cp
    \or
        \global\let\targetDictionary\targetDictionary@cc
    \fi
}{}
\define@choicekey{ahref}{launch}[\val\nr]{save,view,viewnosave}
    {\edef\ahref@launch@type{\nr}}{}
\def\ahref@launch@type{0}%
\define@key{ahref}{preset}[]{\def\ahref@preset{#1}}
\let\ahref@preset\@mpty
%    \end{macrocode}
%    \begin{macro}{\ahrefcolor}
% Color of the link text.
%    \begin{macrocode}
\def\ahrefcolor{red}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\def\targetDictionary@pc#1{/T<</N<\aeb@exiii\stringiiUnicode\aref(#1)\relax>/R/C>>}
%\def\targetDictionary@pc#1{/T<</N<\aeb@exiii\stringiiUnicode\csname aeb@aName@#1\endcsname\relax>/R/C>>}
\def\targetDictionary@cp#1{/T<</R/P>>}
\def\targetDictionary@cc#1{/T<</R/P/T<</N<\aeb@exiii\stringiiUnicode\aref(#1)\relax>/R/C>>>>}
%    \end{macrocode}
%    \begin{macro}{\factory@ahyperref@defaults}
%    \begin{macro}{\setahyperrefDefaults}
%    \begin{macro}{\resetahyperrefDefaults}
% The defaults, \cs{factory@ahyperref@defaults}, of \cs{ahyperref}, as indicated above in the descriptions of the keys.  Can be redefined, I suppose.
% Perhaps the better approach is to use \cs{setahyperrefDefaults} to set the defaults, possibly overwriting the factory defaults.
% Use \cs{resetahyperrefDefaults} to cancel out the user defined defaults. You can also use the \texttt{preset} key for conveniently changing
% the attributes of the link.
%    \begin{macrocode}
\def\factory@ahyperref@defaults{goto=p2c,page,dest,open=userpref,view,%
    border=invisible,highlight=invert,linestyle=solid,linewidth=thin,%
    bordercolor,preset}
\newcommand{\setahyperrefDefaults}[1]{\def\aeb@setahyperrefDefaults{#1}}
\let\aeb@setahyperrefDefaults\@empty
\newcommand{\resetahyperrefDefaults}{\let\aeb@setahyperrefDefaults\@empty}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{\ahyperref}
%    \begin{macro}{\ahyperlink}
% The \cs{ahyperref} command links a parent to its embedded children, or a child to a child. Cool.
%    \begin{macrocode}
\def\aeb@initahref#1{%
    \ifx\aeb@setahyperrefDefaults\@empty
        \edef\expand@setkeys{\noexpand\setkeys{ahref}{\factory@ahyperref@defaults}}%
    \else\expand@setkeys{\noexpand\setkeys{ahref}{\factory@ahyperref@defaults,\aeb@setahyperrefDefaults}}%
    \fi\expand@setkeys
    \setkeys{ahref}{#1}%
    \ifx\ahref@preset\@empty\else\edef\expand@setkeys{\noexpand\setkeys{ahref}{\ahref@preset}}\expand@setkeys\fi
    \let\ahref@dasharray\@empty
    \ifx\ahref@linestyle@keyvalue\ahref@dashedlinetyle
        \def\aeb@border@parameters{0 0 \ahref@linewidth[3.0]}%
        \def\ahref@dasharray{/D[3.0]}%
    \else
        \edef\aeb@border@parameters{\ahref@border}%
    \fi
    \ifx\ahef@invisible@border\@empty\def\ahref@linewidth{0}\fi
    \def\ahref@BS@Dict{/BS<<\ahref@dasharray\ahref@linestyle@keyvalue/W \ahref@linewidth>>
    \ifx\ahref@bordercolor\@empty\else/C[\ahref@bordercolor]\fi\ahref@highlight}%
}
\newcommand{\ahyperref}[3][]{%
    \begingroup
    \def\u{\string\\u}%
    \aeb@initahref{#1}%
    \ifx\ahref@dest\@empty
        \def\ahref@dest@keyvalue{/D[\ahref@page\space\ahref@view@keyvalue]}%
    \else
        \edef\ahref@dest@keyvalue{/D(\labelRef{\ahref@dest})}%
    \fi
    \aeb@ahref@setlink{#2}{#3}%
}
\newcommand{\ahyperlink}[3][]{%
    \begingroup
    \def\u{\string\\u}%
    \aeb@initahref{#1}%
    \ifx\ahref@dest\@empty
        \def\ahref@dest@keyvalue{/D[\ahref@page\space\ahref@view@keyvalue]}%
    \else
        \def\ahref@dest@keyvalue{/D(\ahref@dest)}%
    \fi
    \aeb@ahref@setlink{#2}{#3}%
}
\def\aeb@ahref@setlink#1#2{%
    \setLinkText[\Border{\aeb@border@parameters}\rawPDF{\ahref@BS@Dict}%
    \A{\ahref@dest@keyvalue/S/GoToE\ahref@open@keyvalue\targetDictionary{#1}}]%
    {\textcolor{\ahrefcolor}{#2}}%
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{\ahyperextract}
% The \cs{aextract} command links a parent to its embedded children, or a child to a child. Cool.
%    \begin{macrocode}
\newcommand{\ahyperextract}[3][]
{%
    \begingroup
    \def\u{\string\\u}%
    \aeb@initahref{#1}%
    \setLinkText[\Border{\aeb@border@parameters}\rawPDF{\ahref@BS@Dict}%
    \A{\JS{this.exportDataObject({cName: "\aref(#2)", nLaunch: \ahref@launch@type})}}]%
    {\textcolor{\ahrefcolor}{#3}}%
    \endgroup
}
%    \end{macrocode}
%    \end{macro}
% \subsection{Unicodes}
%    \begin{macro}{\convertChriiUnicode}
% A simple command for mapping a character to its unicode
%    \begin{macrocode}
\def\convertChriiUnicode#1#2{%
    \expandafter\gdef\csname uni@#1\endcsname{#2}%
}%
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\convertChriiUnicode\space{0020}
\convertChriiUnicode{!}{0021}
%\convertChriiUnicode{"}{0022}   % not available, but use \u0022 instead
\convertChriiUnicode{#}{0023}
\convertChriiUnicode{$}{0024}
{\@makeother\%
\convertChriiUnicode{%}{0025}}
\convertChriiUnicode{&}{0026}
\convertChriiUnicode{'}{0027}
\convertChriiUnicode{(}{0028}
\convertChriiUnicode{)}{0029}
\convertChriiUnicode{*}{002A}
\convertChriiUnicode{+}{002B}
\convertChriiUnicode{,}{002C}
\convertChriiUnicode{-}{002D}
\convertChriiUnicode{.}{002E}
\convertChriiUnicode{/}{002F}
\convertChriiUnicode{0}{0030}
\convertChriiUnicode{1}{0031}
\convertChriiUnicode{2}{0032}
\convertChriiUnicode{3}{0033}
\convertChriiUnicode{4}{0034}
\convertChriiUnicode{5}{0035}
\convertChriiUnicode{6}{0036}
\convertChriiUnicode{7}{0037}
\convertChriiUnicode{8}{0038}
\convertChriiUnicode{9}{0039}
\convertChriiUnicode{:}{003A}
\convertChriiUnicode{;}{003B}
\convertChriiUnicode{<}{003C}
\convertChriiUnicode{=}{003D}
\convertChriiUnicode{>}{003E}
\convertChriiUnicode{?}{003F}
\convertChriiUnicode{@}{0040}
\convertChriiUnicode{A}{0041}
\convertChriiUnicode{B}{0042}
\convertChriiUnicode{C}{0043}
\convertChriiUnicode{D}{0044}
\convertChriiUnicode{E}{0045}
\convertChriiUnicode{F}{0046}
\convertChriiUnicode{G}{0047}
\convertChriiUnicode{H}{0048}
\convertChriiUnicode{I}{0049}
\convertChriiUnicode{J}{004A}
\convertChriiUnicode{K}{004B}
\convertChriiUnicode{L}{004C}
\convertChriiUnicode{M}{004D}
\convertChriiUnicode{N}{004E}
\convertChriiUnicode{O}{004F}
\convertChriiUnicode{P}{0050}
\convertChriiUnicode{Q}{0051}
\convertChriiUnicode{R}{0052}
\convertChriiUnicode{S}{0053}
\convertChriiUnicode{T}{0054}
\convertChriiUnicode{U}{0055}
\convertChriiUnicode{V}{0056}
\convertChriiUnicode{W}{0057}
\convertChriiUnicode{X}{0058}
\convertChriiUnicode{Y}{0059}
\convertChriiUnicode{Z}{005A}
\convertChriiUnicode{[}{005B}
%\convertChriiUnicode{\}{005C} % not available, use unicode \u005C
\convertChriiUnicode{]}{005D}
\convertChriiUnicode{^}{005E}
\convertChriiUnicode{_}{005F}
\convertChriiUnicode{`}{0060}
\convertChriiUnicode{a}{0061}
\convertChriiUnicode{b}{0062}
\convertChriiUnicode{c}{0063}
\convertChriiUnicode{d}{0064}
\convertChriiUnicode{e}{0065}
\convertChriiUnicode{f}{0066}
\convertChriiUnicode{g}{0067}
\convertChriiUnicode{h}{0068}
\convertChriiUnicode{i}{0069}
\convertChriiUnicode{j}{006A}
\convertChriiUnicode{k}{006B}
\convertChriiUnicode{l}{006C}
\convertChriiUnicode{m}{006D}
\convertChriiUnicode{n}{006E}
\convertChriiUnicode{o}{006F}
\convertChriiUnicode{p}{0070}
\convertChriiUnicode{q}{0071}
\convertChriiUnicode{r}{0072}
\convertChriiUnicode{s}{0073}
\convertChriiUnicode{t}{0074}
\convertChriiUnicode{u}{0075}
\convertChriiUnicode{v}{0076}
\convertChriiUnicode{w}{0077}
\convertChriiUnicode{x}{0078}
\convertChriiUnicode{y}{0079}
\convertChriiUnicode{z}{007A}
%\convertChriiUnicode{{}{007B}     % not available, use unicode \u007B
\convertChriiUnicode{|}{007C}
%\convertChriiUnicode{}}{007D}     % not available, use unicode \u007D
{\@makeother~
\convertChriiUnicode{~}{007E}}
%    \end{macrocode}
%    \begin{macro}{\EURO}
%    \begin{macro}{\BSLASH}
%    \begin{macro}{\LBRACE}
%    \begin{macro}{\RBRACE}
%    \begin{macro}{\DQUOTE}
% These characters are entered into the description parameter of \cs{autolabelNum}
% or \cs{labelName} as either as literal characters or as its unicode \cs{uXXXX}.
% When \cs{u} is detected \cs{@stringiiUnicode}, the command that converts the string
% to all unicode hex, it calls \cs{getRawUnicode} to get the next four characters, which
% should be XXXX, place them in the stream, followed by \cs{@stringiiUnicode} so as to
% continue the processing of the next character in the description string. I've placed
% an \cs{expandafter} in the definition of \cs{getRawUnicode} to allow the commands below
% to be used. Thus instead of using \cs{u20AC}, which might necessitate the user to
% look up the code, \verb!\u\EURO! can be used instead.  Additional shortcut commands
% like these can be created. Except for \cs{EURO}, these are the ones \TeX{} has trouble
% processing.
%    \begin{macrocode}
\def\EURO{20AC}
\def\BSLASH{005C}
\def\LBRACE{007B}
\def\RBRACE{007D}
\def\DQUOTE{0022}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%
% Display the Unicode encoding of a character
%
%    \begin{macrocode}
\def\displayUnicode#1{\csname uni@#1\endcsname}
%    \end{macrocode}
%    \begin{macro}{\stringiiUnicode}
% This is the primary command for converting a string, which
% may contain \cs{uXXXX} control sequences into unicode encoding.
% The first four hex digits must be \texttt{FEFF} to signal that
% the hex represents unicode.
%    \begin{macrocode}
\def\stringiiUnicode{FEFF\expandafter\@stringiiUnicode}
\def\@stringiiUnicode#1{%
    \ifx#1\relax\else
        \ifx#1\u\aeb@exiii\getRawUnicode
        \else
            \displayUnicode{#1}\aeb@exiii\@stringiiUnicode
        \fi
    \fi
}
\def\getRawUnicode{\expandafter\@getRawUnicode}
\def\@getRawUnicode#1#2#3#4{#1#2#3#4\@stringiiUnicode}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\unicodeStr}
% A convenience command for setting the initial value of a form field with unicode.
% Usage:
%\begin{verbatim}
%\labelName{myCoolIV}{\u0022\u20AC|e^\u007B\u005Cln(17)\u007D|$\u0022}
%\textField[\textSize{10}\textFont{MyriadPro-Regular}
%    \uDV{\unicodeStr(myCoolIV)}\uV{\unicodeStr(myCoolIV)}
%]{myCoolIV}{1.5in}{12bp}
%\end{verbatim}
% First you set the string using \cs{labelName}. The argument for \cs{unicodeStr}
% is delimited by parentheses, the argument itself is the label defined with
% \cs{labelName}.
%    \begin{macrocode}
\def\unicodeStr(#1){\aeb@exiii\stringiiUnicode\aref(#1)\relax}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{\cs{labelName} and \cs{autolabelNum}}
%
%    \begin{macro}{\autolabelNum}
%    \begin{macro}{\autolabelNum*}
%    \begin{macro}{\labelName}
% Commands for defining the description string for the attachments.
% It is important that the description of the attached file, and the reference
% to in in the \texttt{/GoToE} exactly match. The commands define here set up the
% mapping between a ``\LaTeX'' label and the description. These commands also allow
% the document author to overwrite the default attachment descriptions. Usage:
%\begin{enumerate}
%\item\verb!\autolabelNum[<label>]{<attachment_number>}!
%\item\verb!\autolabelNum*[<label>]{<attachment_number>}{<description>}!
%\item\verb!\labelName{<label>}{<description>}!
%\end{enumerate}
% \cs{autolabelNum} and \cs{autolabelNum*} are used with attachments attached using the
% \texttt{attachments} option, while \cs{labelName} is used it the document author attached
% a file using the \texttt{docassembly} environment. \cs{labelName} is also used by
% \cs{autolabelNum} and \cs{autolabelNum*} to make definitions, in that respect, \cs{labelName}
% is the low-level command for setting up the mappings and definitions.
%    \begin{macrocode}
\def\sanitize@attach{\@makeother\#\@makeother\$\@makeother\%\@makeother~}
{\obeyspaces\gdef\aebarg#1{\gdef\thearg{#1}\aeb@labelName}\gdef\aebargstar#1{\gdef\thearg{#1}\aeb@labelNamestar}}%
{\obeyspaces\gdef\xaebarg{\xdef\thearg{AeB Attachment \aeb@attachNum}\aeb@labelName}}%
\def\labelName#1{\bgroup\def\ddargi{#1}\obeyspaces\sanitize@attach\aebarg}%
\def\labelName@star#1{\bgroup\def\ddargi{#1}\obeyspaces\sanitize@attach\aebargstar}%
\def\aeb@@autolabelNum#1#2{\bgroup\def\ddargi{#1}\gdef\aeb@attachNum{#2}\obeyspaces\sanitize@attach\xaebarg}%
\newcommand{\autolabelNum}{\@ifstar{\aeb@autoLabelNumstar}{\aeb@autoLabelNum}}
\newcommand\aeb@autoLabelNum[2][]{\def\alnargi{#1}%
    \ifx\alnargi\@empty
         \def\aeb@next{\labelName{attach#2}{AeB\space Attachment\space #2}}%
    \else
        \def\aeb@next{\labelName{#1}{AeB\space Attachment\space #2}}%
    \fi
    \aeb@next%
}
\newcommand{\aeb@autoLabelNumstar}[2][]{\def\alnargi{#1}\gdef\@thisattachnum{#2}%
    \ifx\alnargi\@empty
        \def\aeb@next{\labelName@star{attach#2}}%
    \else
        \def\aeb@next{\labelName@star{#1}}%
    \fi
    \aeb@next
}
\def\aeb@labelName{\global\expandafter\let\csname aeb@aName@\ddargi\endcsname\thearg\egroup}
\def\aeb@labelNamestar{\global\expandafter\let\csname aeb@aName@\ddargi\endcsname\thearg
    \global\expandafter\let\csname aeb@aName@attach\@thisattachnum\endcsname\thearg\egroup
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
% We need a general verbatim write environment, here is the one used by exerquiz and several other packages.
% If exerquiz is loaded, no need to redefine it.
%    \begin{macrocode}
\@ifpackageloaded{exerquiz}{}
{%
    \def\verbatimwrite{\@bsphack
        \let\do\@makeother\dospecials
        \catcode`\^^M\active \catcode`\^^I=12
        \def\verbatim@processline{%
            \immediate\write\verbatim@out
            {\the\verbatim@line}}%
        \verbatim@start}
        \def\endverbatimwrite{\@esphack}
}
%    \end{macrocode}
%    \begin{environment}{attachmentNames}
% Enclose the \cs{labelName} and \cs{autolabelNum} commands this environment, which writes
% it contents verbatim to the file \cs{jobname\_xref.cut} and inputs it back in.  Child files can input this
% file to get the labels assigned for them by the parent document.
%    \begin{macrocode}
\newenvironment{attachmentNames}
{%
    \newwrite \aeb@attachments@xref
    \immediate\openout \aeb@attachments@xref \jobname_xref.cut
    \let\verbatim@out\aeb@attachments@xref
    \verbatimwrite}
{%
    \endverbatimwrite
    \immediate\closeout \aeb@attachments@xref
    \aftergroup\aeb@Input@xref
}
\def\aeb@Input@xref{\InputIfFileExists{\jobname_xref.cut}{}{}}
%    \end{macrocode}
%    \end{environment}
%    \begin{macrocode}
%</unicode>
%<*unicode1>
%    \end{macrocode}
%
% Latin-1 unicode set
%
%    \begin{macrocode}
\convertChriiUnicode{�}{00A1}
\convertChriiUnicode{�}{00A2}
\convertChriiUnicode{�}{00A3}
\convertChriiUnicode{�}{00A4}
\convertChriiUnicode{�}{00A5}
\convertChriiUnicode{�}{00A6}
\convertChriiUnicode{�}{00A7}
\convertChriiUnicode{�}{00A8}
\convertChriiUnicode{�}{00A9}
\convertChriiUnicode{�}{00AA}
\convertChriiUnicode{�}{00AB}
\convertChriiUnicode{�}{00AC}
\convertChriiUnicode{�}{00AD}
\convertChriiUnicode{�}{00AE}
\convertChriiUnicode{�}{00AF}
\convertChriiUnicode{�}{00B0}
\convertChriiUnicode{�}{00B1}
\convertChriiUnicode{�}{00B2}
\convertChriiUnicode{�}{00B3}
\convertChriiUnicode{�}{00B4}
\convertChriiUnicode{�}{00B5}
\convertChriiUnicode{�}{00B6}
\convertChriiUnicode{�}{00B7}
\convertChriiUnicode{�}{00B8}
\convertChriiUnicode{�}{00B9}
\convertChriiUnicode{�}{00BA}
\convertChriiUnicode{�}{00BB}
\convertChriiUnicode{�}{00BC}
\convertChriiUnicode{�}{00BD}
\convertChriiUnicode{�}{00BE}
\convertChriiUnicode{�}{00BF}
\convertChriiUnicode{�}{00C0}
\convertChriiUnicode{�}{00C1}
\convertChriiUnicode{�}{00C2}
\convertChriiUnicode{�}{00C3}
\convertChriiUnicode{�}{00C4}
\convertChriiUnicode{�}{00C5}
\convertChriiUnicode{�}{00C6}
\convertChriiUnicode{�}{00C7}
\convertChriiUnicode{�}{00C8}
\convertChriiUnicode{�}{00C9}
\convertChriiUnicode{�}{00CA}
\convertChriiUnicode{�}{00CB}
\convertChriiUnicode{�}{00CC}
\convertChriiUnicode{�}{00CD}
\convertChriiUnicode{�}{00CE}
\convertChriiUnicode{�}{00CF}
\convertChriiUnicode{�}{00D0}
\convertChriiUnicode{�}{00D1}
\convertChriiUnicode{�}{00D2}
\convertChriiUnicode{�}{00D3}
\convertChriiUnicode{�}{00D4}
\convertChriiUnicode{�}{00D5}
\convertChriiUnicode{�}{00D6}
\convertChriiUnicode{�}{00D7}
\convertChriiUnicode{�}{00D8}
\convertChriiUnicode{�}{00D9}
\convertChriiUnicode{�}{00DA}
\convertChriiUnicode{�}{00DB}
\convertChriiUnicode{�}{00DC}
\convertChriiUnicode{�}{00DD}
\convertChriiUnicode{�}{00DE}
\convertChriiUnicode{�}{00DF}
\convertChriiUnicode{�}{00E0}
\convertChriiUnicode{�}{00E1}
\convertChriiUnicode{�}{00E2}
\convertChriiUnicode{�}{00E3}
\convertChriiUnicode{�}{00E4}
\convertChriiUnicode{�}{00E5}
\convertChriiUnicode{�}{00E6}
\convertChriiUnicode{�}{00E7}
\convertChriiUnicode{�}{00E8}
\convertChriiUnicode{�}{00E9}
\convertChriiUnicode{�}{00EA}
\convertChriiUnicode{�}{00EB}
\convertChriiUnicode{�}{00EC}
\convertChriiUnicode{�}{00ED}
\convertChriiUnicode{�}{00EE}
\convertChriiUnicode{�}{00EF}
\convertChriiUnicode{�}{00F0}
\convertChriiUnicode{�}{00F1}
\convertChriiUnicode{�}{00F2}
\convertChriiUnicode{�}{00F3}
\convertChriiUnicode{�}{00F4}
\convertChriiUnicode{�}{00F5}
\convertChriiUnicode{�}{00F6}
\convertChriiUnicode{�}{00F7}
\convertChriiUnicode{�}{00F8}
\convertChriiUnicode{�}{00F9}
\convertChriiUnicode{�}{00FA}
\convertChriiUnicode{�}{00FB}
\convertChriiUnicode{�}{00FC}
\convertChriiUnicode{�}{00FD}
\convertChriiUnicode{�}{00FE}
\convertChriiUnicode{�}{00FF}
%</unicode1>
%<*aebpro>
%    \end{macrocode}
% \section{Document Assembly Methods}
% \subsection{The \texttt{docassembly} Environment}
%    \begin{environment}{docassembly}
% This is a wrapper environment for the \texttt{execJS} environment of the
% \textsf{insDLJS} Package. Place JavaScript lines in this environment and
% the script will execute one time after the file has been distilled and opened
% in Acrobat Pro for the fist time.
%    \begin{macrocode}
\newenvironment{docassembly}{%
\execJS{docassembly}
}{\endexecJS}
%    \end{macrocode}
%    \end{environment}
% \subsection{Supported Assembly JS API}
%    \begin{macro}{\theDocObject}
%    \begin{macro}{\addWatermarkFromFile}
%    \begin{macro}{\importIcon}
%    \begin{macro}{\importSound}
%    \begin{macro}{\appopenDoc}
%    \begin{macro}{\insertPages}
%    \begin{macro}{\importDataObject}
% These are convenience commands to executing security restricted JavaScript. The JS methods
% are defined in the \texttt{aeb\_pro.js} file, kept as folder JavaScript. These commands
% are executed in a verbatim environment where \verb!\! is still the escape charter, so, as
% a result, The two arguments of these commands are \verb|({| which must immediately follow
% the command name, with no intervening spaces. See the example below for correct usage.
%\begin{verbatim}
%\begin{docassembly}
%\addWatermarkFromFile({
%    bOnTop:false,
%    cDIPath:"/C/AcroTeX/AcroPackages/ManualBGs/Manual_BG_Print_AeB.pdf"
%});
%\end{docassembly}
%\end{verbatim}
% For each of the methods below, see the \textsl{JavaScript for Acrobat API Reference}.
%
%\medskip\noindent The command \cs{theDocObject} is normally set to \texttt{this}, meaning
% the current document. You may need to set it to some other doc object if you are trying to
% access a doc object other than the current one.
%    \begin{macrocode}
\def\theDocObject{this}
%    \end{macrocode}
% This is the method \texttt{Doc.addWatermarkFromFile}.
%    \begin{macrocode}
\def\addWatermarkFromFile#1#2{%
aebTrustedFunctions#1\theDocObject, aebAddWatermarkFromFile, #2}
%    \end{macrocode}
% This is the method \texttt{Doc.importIcon}.
%    \begin{macrocode}
\def\importIcon#1#2{%
aebTrustedFunctions#1\theDocObject, aebImportIcon, #2}
%    \end{macrocode}
% This is the method \texttt{Doc.importSound}.
%    \begin{macrocode}
\def\importSound#1#2{%
aebTrustedFunctions#1\theDocObject, aebImportSound, #2}
%    \end{macrocode}
% This is the method \texttt{app.openDoc}.
%    \begin{macrocode}
\def\appopenDoc#1#2{%
aebTrustedFunctions#1\theDocObject, aebAppOpenDoc, #2} % doesn't use doc
%    \end{macrocode}
% This is the method \texttt{Doc.insertPages}.
%    \begin{macrocode}
\def\insertPages#1#2{%
aebTrustedFunctions#1\theDocObject, aebInsertPages, #2}
%    \end{macrocode}
% This is the method \texttt{Doc.importDataObject}.
%    \begin{macrocode}
\def\importDataObject#1#2{%
aebTrustedFunctions#1\theDocObject, aebImportDataObject, #2}
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
% This is the method \texttt{Doc.importDataObject}.
%    \begin{macrocode}
\def\executeSave#1{%
aebTrustedFunctions#1\theDocObject, aebSaveAs, "Save"}
%    \end{macrocode}
%    \begin{macrocode}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macrocode}
%</aebpro>
%    \end{macrocode}
%  \Finale
\endinput
