%%
%% This is file `fancytooltips.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fancytooltips.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007 by Robert Marik <marik@mendelu.cz>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{fancytooltips}
    [2012/06/12 v1.12 fancytooltips.dtx  file]
\RequirePackage{graphicx}
\RequirePackage{xkeyval}
\RequirePackage{atbegshi}

\newif\if@fancytooltips@createtips\@fancytooltips@createtipsfalse
\DeclareOptionX{createtips}{\@fancytooltips@createtipstrue}

\newif\ifTooltip@usepdftex\Tooltip@usepdftextrue
\DeclareOptionX{dvips}{\Tooltip@usepdftexfalse}

\newif\if@fancytooltips@extratext\@fancytooltips@extratexttrue
\DeclareOptionX{noextratext}{\@fancytooltips@extratextfalse}

\newif\if@fancytooltips@movetips\@fancytooltips@movetipsfalse
\DeclareOptionX{movetips}{\@fancytooltips@movetipstrue}

\newif\if@fancytooltips@mouseover\@fancytooltips@mouseoverfalse
\DeclareOptionX{mouseover}{\@fancytooltips@mouseovertrue}

\newif\if@fancytooltips@inactive\@fancytooltips@inactivefalse
\DeclareOptionX{inactive}{\@fancytooltips@inactivetrue}

\newif\if@fancytooltips@active\@fancytooltips@activefalse
\DeclareOptionX{active}{\@fancytooltips@activetrue}

\newif\if@fancytooltips@fg\@fancytooltips@fgfalse
\DeclareOptionX{fg}{\@fancytooltips@fgtrue}

\DeclareOptionX{filename}{\xdef\TooltipFilename{#1}}
\DeclareOptionX{pages}{\xdef\TooltipPages{#1}}

\newif\if@fancytooltips@blur\@fancytooltips@blurfalse
\DeclareOptionX{blur}[0.4]{\@fancytooltips@blurtrue
  \xdef\fancytooltips@transparency{#1}}

\newif\if@fancytooltips@fixcolor\@fancytooltips@fixcolorfalse
\DeclareOptionX{fixcolor}{\@fancytooltips@fixcolortrue}

\newif\if@fancytooltips@preview\@fancytooltips@previewfalse
\DeclareOptionX{preview}{\@fancytooltips@previewtrue}

\newif\if@fancytooltips@previewall\@fancytooltips@previewallfalse
\DeclareOptionX{previewall}{\@fancytooltips@previewtrue\@fancytooltips@previewalltrue}

\newif\if@fancytooltips@nosoap\@fancytooltips@nosoapfalse
\DeclareOptionX{nosoap}{\@fancytooltips@nosoaptrue}

\def\@@fancytipmark{}
\DeclareOptionX{tooltipmark}{\xdef\@@fancytipmark{#1}}

\def\fancytooltipsdebugmsg{}
\DeclareOptionX{debug}{\def \fancytooltipsdebugmsg
{
if (this.getField("ikona") == null)
  {app.alert("No buttons for placing tootlips are available. Contact the author. The file may  need more compilations.");}
  else
  {app.alert("Buttons for placing tooltips are available. Congratulations! Hope everything will work.");}
if (this.getField("animtiph") == null)
  {app.alert("No hidden buttons containing tooltips available. The interactive features will not work. \n\n If you created the file by dvips, run the command ImportTooltips() in the Javascript console (Ctrl+J, write the command followed by semicolon and Ctrl+Enter).");}
  else
  {app.alert("Hidden buttons containing tooltips are available. Congratulations! Hope everything will work.");}
}}

\ProcessOptionsX

\if@fancytooltips@blur
\ifTooltip@usepdftex\else
\@fancytooltips@blurfalse
\AtEndDocument{\PackageWarning{fancytooltips}
  {Blur option is incompatible with dvips. ^^J The option blur is turned off }}
\fi
\fi

\ifTooltip@usepdftex\else
\@fancytooltips@fgfalse
\fi

\newdimen\buttontipwidth
\newdimen\buttontipheight
\newdimen\fancy@a
\newdimen\fancy@b
\newdimen\fancy@layerHshift\fancy@layerHshift=0pt
\newdimen\fancy@layerVshift\fancy@layerVshift=0pt
\newdimen\fancy@button@Vshift \fancy@button@Vshift=0pt
\newdimen\fancy@button@Hshift \fancy@button@Hshift=0pt
\newtoks\pos@fancy@toks

\if@fancytooltips@active\@fancytooltips@inactivefalse\fi

\if@fancytooltips@inactive
\newcommand{\tooltip}{\@ifstar\tooltip@Star\tooltip@NoStar}%
\newcommand{\tooltip@Star}[2]{#1}%
\newcommand{\tooltip@NoStar}[2]{#1}%

\newcommand{\tooltipanim}{\@ifstar\tooltipanim@Star\tooltipanim@NoStar}%
\newcommand{\tooltipanim@Star}[3]{#1}%
\newcommand{\tooltipanim@NoStar}[3]{#1}%
\def\keytip#1{}%
\def\TooltipPage#1#2{}%
\let\TooltipExtratext\relax
\let\TooltipRefmark\relax
\ifx\@ocg@makeknown\undefined
  \def\@ocg@makeknown#1#2#3{}\fi
\def\fancy@@pushButton#1#2#3#4#5#6#7#8{}
\def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{}

\PackageWarning{fancytooltips}{Fancytooltips inactive}%
\expandafter\endinput\fi

\newcount\fancycheckcount\fancycheckcount=0
\def\fancy@second#1#2#3#4{#2}

\def\fancypreview@refhook{%
\global\let\oldref\ref
\gdef\ref##1{\oldref{##1}\global\advance\fancycheckcount by 1\relax
\edef\templabel{fancyanchorref:\the\fancycheckcount}%
\expandafter\label\expandafter{\templabel}%
\expandafter\ifx \csname FancyToolTip@##1\endcsname\relax \else\hbox to 0 pt{%
  \expandafter\ifx \csname r@##1\endcsname \relax\else
    \expandafter\let\expandafter\fancytooltip@temp@a\csname r@##1\endcsname
    \edef\fan@tempa{\expandafter\fancy@second\fancytooltip@temp@a}%
  \fi
  \expandafter\ifx \csname r@fancyanchorref:\the\fancycheckcount\endcsname \relax\else
    \expandafter\let\expandafter\fan@temp@w\csname r@fancyanchorref:\the\fancycheckcount\endcsname
    \edef\fan@temp@ww{\expandafter\fancy@second\fan@temp@w}%
    \fi
\if@fancytooltips@previewall\def\fan@tempa{not a page number}\fi
\ifx\fan@tempa\fan@temp@ww\else\smash{%
  \let\TooltipExtratext\relax\tooltip{\strut\TooltipRefmark}{##1}}%
\fi
\hss}%
\fi}%
\ifx\NAT@citea@mbox\undefined
\def\@citex[##1]##2{\leavevmode
    \let\@citea\@empty
    \@cite{\@for\@citeb:=##2\do
      {\@citea\def\@citea{,\penalty\@m\ }%
        \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
        \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
        \@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries ?}%
          \G@refundefinedtrue
          \@latex@warning
          {Citation `\@citeb' on page \thepage \space undefined}}%
        {\ifx\csname r@fancy:cite:\@citeb\endcsname\undefined \@cite@ofmt{\csname b@\@citeb\endcsname}\else\tooltip*{\@cite@ofmt{\csname b@\@citeb\endcsname}}{fancy:cite:\@citeb}\fi
        }}}{##1}}%
\else
\def\NAT@citea@mbox{%
 \@citea\mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}\tooltip*{}{fancy:cite:\@citeb}}
\fi
}

\if@fancytooltips@nosoap
  \def\TooltipRefmark{\hbox{\ }}%
\else
  \ifTooltip@usepdftex
  \def\TooltipRefmark{\hbox {\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
          {fancytipmark\@@fancytipmark.pdf}}}}}%
  \else
  \def\TooltipRefmark{\hbox {\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
          {fancytipmark.eps}}}}}%
  \fi%\ifTooltip@usepdftex
\fi%\if@fancytooltips@nosoap

\if@fancytooltips@preview\AtBeginDocument{\fancypreview@refhook}\fi

\if@fancytooltips@createtips
\newwrite\tipfile
\immediate\openout\tipfile \jobname.tips
\def\keytip#1{\write\tipfile{\string\tooltipname{#1}{\arabic{page}}}}
\expandafter\endinput\fi

\ifx\TooltipFilename\undefined
\PackageWarning{fancytooltips}{** The filename with tooltips is not given. **}
\fi

\ifTooltip@usepdftex
\RequirePackage[pdftex]{eforms}
\def\TooltipExtratext{\hbox{\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
        {fancytipmark\@@fancytipmark.pdf}}}}}
\else
\RequirePackage[dvips]{eforms}
\def\TooltipExtratext{\hbox{\smash{\raisebox{0.4em}{\includegraphics[width=0.7em]%
        {fancytipmark.eps}}}}}
\fi%\ifTooltip@usepdftex

\if@fancytooltips@nosoap
  \def\TooltipExtratext{\hbox{\ }}%
\fi%\if@fancytooltips@nosoap

\if@fancytooltips@extratext\else\let\TooltipExtratext\relax\fi

\AtBeginDocument{
\global\buttontipwidth=\paperwidth
\global\buttontipheight=\paperheight
}

\ifTooltip@usepdftex
\def\frametip@{%
  \pdfstartlink user{%
    /Subtype /Widget
    /F 6
    /T (ikona.\thepage)
    /FT /Btn
    /Ff 65536
    /H /N
    /BS << /W 1 /S /S >>
    /MK << /TP 1 /IF <</A[1.0 1.0]/SW /B>>  >>
  }%
  \vbox to \buttontipheight {\vss\hbox to \buttontipwidth{\hss}}\pdfendlink}%
\else
\def\everyeqIcon#1{\def\every@eqIcon{#1}}
\def\every@eqIcon{}
\newcommand\eqIconFTT[4][]
{%
  \push@@Button{#1}{#2}{#3}{#4}{}{\eq@setButtonProps\eq@Button@driver}%
  {\eqIconDefaults\every@ButtonField\every@eqIcon}%
}
\def\eqIconDefaults
{%
  \rawPDF{}\S{}\mkIns{/TP 1 /IF<</A[1.0 1.0]/SW/B>>}\R{0}
  \CA{}\RC{}\AC{}\BC{}\BG{}\H{B}
  \textColor{0 g}\Ff{\FfReadOnly}
}
\def\frametip@{\eqIconFTT[\BC{}\BG{}\F{\FHidden}]%
  {ikona.\thepage}{\paperwidth}{\paperheight}%
}%
\fi%\ifTooltip@usepdftex

\def\fancytooltips@one{1}
\if@fancytooltips@blur
  \RequirePackage{ocg}
  \ifx\fancytooltips@one\fancytooltips@transparency
    \def\transparent#1{}
  \else
    \RequirePackage{transparent}
  \fi
\else
  \ifx\@ocg@makeknown\undefined
    \def\@ocg@makeknown#1#2#3{}\fi
\fi

\if@fancytooltips@fg
\else
\RequirePackage{eso-pic}
\def\frametip{%
  \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax
  \else
  \setbox0=\hbox{\frametip@}%
  \hbox{\raise \dp0 \box0}
  \fi}%
\AddToShipoutPicture{\hbox to 0 pt{\frametip\hss}}
\fi

\def\fancytooltips@save@position{\pdfsavepos%
  \write\@auxout{\string\global\string \fancy@layerVshift \the\pdflastypos sp\string\relax}%
  \write\@auxout{\string\global\string \fancy@layerHshift \the\pdflastxpos sp\string\relax}%
  \global\let\fancytooltips@save@position\relax%
}

\def\fancy@beginshipout@hook{}
\AtBeginShipout{%
\TooltipPageopencloseJS
\setbox\AtBeginShipoutBox=\hbox{%
  \hbox to 0 pt{\TooltipHidden}\global\def\TooltipHidden{}%
  \fancy@beginshipout@hook\if@fancytooltips@fixcolor\hbox to 0 pt{\resizebox{1pt}{!}{\TooltipExtratext}\hss}\fi
  \hbox to 0 pt{\box\AtBeginShipoutBox\hss}%
  \ifTooltip@usepdftex
    \fancytooltips@save@position
    \if@fancytooltips@blur
      \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax \else
      \lower\fancy@layerVshift\hbox to 0 pt{\kern-\fancy@layerHshift\relax
        \begin{ocg}{fancyOCG\thepage}{fancyOCG\thepage}{0}%
          \expandafter\transparent\expandafter{\fancytooltips@transparency}%
          \color{black}%
          \vbox to 0 pt{\vss\hbox{\vrule width \paperwidth height \paperheight}}%
        \end{ocg}\hss}%
      \fi
    \fi%\if@fancytooltips@blur
    \if@fancytooltips@fg
      \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax
      \else
        \lower\fancy@layerVshift\vbox to 0 pt{\vss\hbox to 0 pt{\kern-\fancy@layerHshift\relax\hbox{\frametip@}\hss}}%
      \fi%\ifx
      \lower\fancy@layerVshift\vbox to 0 pt{\vss\hbox to 0 pt{\kern-\fancy@layerHshift\relax\hbox to 0 pt{\the\pos@fancy@toks\hss}\hss}}%
    \fi%\if@fancytooltips@fg
  \fi%\ifTooltip@usepdftex
  \kern\hsize}%
}%

\definecolor{tooltipcolor}{rgb}{0,0,1}

\newcount\tooltip@count
\newtoks\tooltip@toks
\newtoks\tooltip@pagetoks
\tooltip@pagetoks={\thepage}
\def\tooltippage{}

\def\TooltipPage#1#2{%
\expandafter\gdef\csname TooltipPage#2\endcsname{#2}%
\expandafter\gdef\csname Tooltipcount2page#1\endcsname{#2}%
}

\def\fancy@JS#1{\JS{var DirtyBeforeTooltip=this.dirty; #1
  this.dirty=DirtyBeforeTooltip;}}

\newcommand{\tooltip}{\@ifstar
                     \tooltip@Star%
                     \tooltip@NoStar%
}

\newcommand{\tooltip@Star}[2]{{\color{tooltipcolor}#1}%
  {\let\SaveTooltipExtratext\TooltipExtratext
   \let\TooltipExtratext\relax
   \hbox to 0 pt{\tooltip@NoStar{\SaveTooltipExtratext
       \vrule height 10pt depth 0 pt width 0 pt}{#2}\hss}}}

\newcommand{\tooltip@NoStar}[2]{%
  \global\advance\tooltip@count by 1%
  \edef\act{\write\@auxout{\noexpand\string\noexpand\TooltipPage{\the\tooltip@count}{\the\tooltip@pagetoks}}}\act
  \expandafter\ifx\csname Tooltipcount2page\the\tooltip@count \endcsname\relax
  \global\edef\tooltippage{}
  \else
  \global\edef\tooltippage{\csname Tooltipcount2page\the\tooltip@count \endcsname}%
  \fi
  \checkTipNumber{#2}\edef\TipNumber{\FindTipNumber{#2}}%
  \leavevmode
  \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\copy0\fancy@a=\dp0\advance\fancy@a by \ht0\relax\hbox to 0 pt{\smash{\TooltipExtratext}\hss}\fancy@pushButton{\TipNumber}{\tooltippage}{TooltipField}{\wd0}{\fancy@a}{\dp0}}

\def\fancy@tooltip@options#1#2{\BC{}\BG{}
  \S{}\AA{\AAMouseExit{\fancy@JS{CloseTooltips();}}%
  \if@fancytooltips@mouseover
  \AAMouseEnter{\fancy@JS{this.getField("ikona."+(#2)).hidden=false;
      try {app.clearInterval(animace);}catch (e) {}
      \if@fancytooltips@movetips nastav(#1,#2);\fi
      \if@fancytooltips@blur
      try{
      for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
      {
        if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
        fancytooltipsOCGs[i].state = true;
        else
        fancytooltipsOCGs[i].state = false;
      }} catch (e) {};
      \fi
      zobraz(#1,#2);
    }}
  \fi}
  \A{\fancy@JS{this.getField("ikona."+(#2)).hidden=false;
      try {app.clearInterval(animace);}catch (e) {}
      \if@fancytooltips@movetips nastav(#1,#2);\fi
      \if@fancytooltips@blur
      try {
      for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
      {
        if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
        fancytooltipsOCGs[i].state = true;
        else
        fancytooltipsOCGs[i].state = false;
      }} catch (e) {};
      \fi
      zobraz(#1,#2);
    }}}

\newtoks\@fxtoks\@fxtoks={\the\pdflastxpos}
\newtoks\@fytoks\@fytoks={\the\pdflastypos}

\def\fancy@pushButton#1#2#3#4#5#6{%
  \lower #6\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltip@options{#1}{#2}]{#3}{#4}{#5}}}
\def\fancy@@pushButton#1#2#3#4#5#6#7#8{}

\ifTooltip@usepdftex
\if@fancytooltips@fg
\def\fancy@pushButton#1#2#3#4#5#6{\pdfsavepos%
  \edef\act{\write\@auxout{\string\fancy@@pushButton{#1}{#2}{#3}{\the#4}{\the#5}{\the\@fxtoks}{\the\@fytoks}{\the#6}}}\act%
}
\def\fancy@@pushButton#1#2#3#4#5#6#7#8{%
  \expandafter\global\expandafter\pos@fancy@toks\expandafter{\the\pos@fancy@toks\fancy@onlypage{#2}{\vbox to 0 pt{\vss\hbox to 0 pt{\kern #6 sp\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltip@options{#1}{#2}]{#3}{#4}{#5}}\hss}\kern #7sp\kern-#8}}}}
\fi
\fi

\def\fancy@onlypage#1#2{\def\ft@a{#1}\edef\ft@b{\thepage}%
\ifx\ft@a\ft@b#2\fi}

\def\delayinterval{200}

\newcommand{\tooltipanim}{\@ifstar
                     \tooltipanim@Star%
                     \tooltipanim@NoStar%
}

\newcommand{\tooltipanim@Star}[3]{{\color{tooltipcolor}#1}%
  {\let\SaveTooltipExtratext\TooltipExtratext
   \let\TooltipExtratext\relax
   \hbox to 0 pt{\tooltipanim@NoStar{\SaveTooltipExtratext
       \vrule height 10pt depth 0 pt width 0 pt}{#2}{#3}\hss}}}

\newcommand{\tooltipanim@NoStar}[3]{%
  \global\advance\tooltip@count by 1%
  \edef\act{\write\@auxout{\noexpand\string\noexpand\TooltipPage{\the\tooltip@count}{\the\tooltip@pagetoks}}}\act
  \expandafter\ifx\csname Tooltipcount2page\the\tooltip@count \endcsname\relax
  \global\edef\tooltippage{}
  \else
  \global\edef\tooltippage{\csname Tooltipcount2page\the\tooltip@count \endcsname}%
  \fi
  \checkTipNumber{#2}\edef\TipNumberA{\FindTipNumber{#2}}%
  \checkTipNumber{#3}\edef\TipNumberB{\FindTipNumber{#3}}%
  \leavevmode
  \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\copy0\fancy@a=\dp0\advance\fancy@a by \ht0\relax\hbox to 0 pt{\smash{\TooltipExtratext}\hss}\fancy@anim@pushButton{\TipNumberA}{\tooltippage}{TooltipField}{\wd0}{\fancy@a}{\dp0}{\TipNumberB}}

\def\fancy@tooltipanim@options#1#2#3{
\BC{}\BG{}\S{}\AA{\AAMouseExit{\fancy@JS{CloseTooltips();}}
  \if@fancytooltips@mouseover
  \AAMouseEnter{\fancy@JS{
      try {app.clearInterval(animace);}catch (e) {}
      var cislo=#1;
      \if@fancytooltips@movetips nastav(#1,#2);\fi
      \if@fancytooltips@blur
      try{
      for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
      {
        if(fancytooltipsOCGs[i].name == "fancyOCG"+(#2))
        fancytooltipsOCGs[i].state = true;
        else
        fancytooltipsOCGs[i].state = false;
      }} catch (e) {};
      \fi
      function animuj()
      {
        var DirtyBeforeTooltipanim=this.dirty;
        if (cislo<#3) cislo=cislo+1;
        this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+cislo).buttonGetIcon());
        this.dirty=DirtyBeforeTooltipanim;
      };
      this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+#1).buttonGetIcon());
      this.getField("ikona."+(#2)).hidden=false;
      animace=app.setInterval('animuj();', \delayinterval);
    }}
  \fi}
  \A{\fancy@JS{
      try {app.clearInterval(animace);}catch (e) {}
      var cislo=#1;
      \if@fancytooltips@movetips nastav(#1,#2);\fi
      \if@fancytooltips@blur
      try{
      for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
      {
        if(fancytooltipsOCGs[i].name == "fancyOCG"+(#3))
        fancytooltipsOCGs[i].state = true;
        else
        fancytooltipsOCGs[i].state = false;
      }} catch (e) {};
      \fi
      function animuj()
      {
        var DirtyBeforeTooltipanim=this.dirty;
        if (cislo<#3) cislo=cislo+1;
        this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+cislo).buttonGetIcon());
        this.dirty=DirtyBeforeTooltipanim;
      };
      this.getField('ikona.'+(#2)).buttonSetIcon(this.getField("animtiph."+#1).buttonGetIcon());
      this.getField("ikona."+(#2)).hidden=false;
      animace=app.setInterval('animuj();', \delayinterval);
    }}
}

\def\fancy@anim@pushButton#1#2#3#4#5#6#7{%
  \lower #6 \hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltipanim@options{#1}{#2}{#7}]{#3}{#4}{#5}}}
\def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{}

\ifTooltip@usepdftex
\if@fancytooltips@fg
\def\fancy@anim@pushButton#1#2#3#4#5#6#7{\pdfsavepos%
  \edef\act{\write\@auxout{\string\fancy@@anim@pushButton{#1}{#2}{#3}{\the#4}{\the#5}{\the\@fxtoks}{\the\@fytoks}{\the#6}{#7}}}\act%
}
\def\fancy@@anim@pushButton#1#2#3#4#5#6#7#8#9{%
  \expandafter\global\expandafter\pos@fancy@toks\expandafter{\the\pos@fancy@toks\fancy@onlypage{#2}{\vbox to 0 pt{\vss\hbox to 0 pt{\kern #6 sp\hbox to 0 pt{\hss\expandafter\pushButton\expandafter[\fancy@tooltipanim@options{#1}{#2}{#9}]{#3}{#4}{#5}}\hss}\kern #7sp\kern-#8}}}}
\fi
\fi

\edef\fancytooltips@pdfpageattrJS{%
  var DirtyBeforeCloseTooltip=this.dirty;
  \if@fancytooltips@blur
  try{
    var temp = fancytooltipsOCGs.length;
    for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
    {
      fancytooltipsOCGs[i].state = false;
    }
  }
  catch (e){}
  \fi
  CloseTooltips();
  this.dirty=DirtyBeforeCloseTooltip;
}
\ifTooltip@usepdftex
\edef\fancy@temp{/AA << /O << /S /JavaScript /JS (
    \fancytooltips@pdfpageattrJS) >>  >>}
\expandafter\def\expandafter\TooltipPageopencloseJS\expandafter{
\expandafter\global\expandafter\pdfpageattr\expandafter{\fancy@temp}%
}
\pdfximage{\TooltipFilename.pdf}%
\edef\TooltipPages{\the\pdflastximagepages}%
\else
\edef\fancy@temp{     [ {ThisPage} << /AA <<
    /O << /S /JavaScript /JS (var DirtyBeforeCloseTooltip=this.dirty; CloseTooltips(); this.dirty=DirtyBeforeCloseTooltip;) >>
    >> >> /PUT pdfmark}
\expandafter\def\expandafter\TooltipPageopencloseJS\expandafter{
\expandafter\literalps@out\expandafter{\fancy@temp}}
\edef\fancy@@temp{/S /JavaScript /JS ( \fancytooltips@pdfpageattrJS)}
\expandafter\OpenAction\expandafter{\fancy@@temp}
\fi%\ifTooltip@usepdftex

\ifTooltip@usepdftex
\def\fancytempA{}
\ifx\FancytooltipsAfterClose\undefined\else\edef\fancytempA{\FancytooltipsAfterClose}\fi
\def\fancytempAA{}
\ifx\FancytooltipsAfterShow\undefined\else\edef\fancytempAA{\FancytooltipsAfterShow}\fi

\if@fancytooltips@blur
\def\fancytempAAA{
  var inifancytooltipsOCGs = this.getOCGs();
  var fancytooltipsOCGs = [];
  for(var i=0; inifancytooltipsOCGs && i<inifancytooltipsOCGs.length;i++)
  {
    if(inifancytooltipsOCGs[i].name.substr(0,5) == "fancy")
    {
      fancytooltipsOCGs.push(inifancytooltipsOCGs[i]);
      inifancytooltipsOCGs[i].state=false;
    }
  }
  inifancytooltipsOCGs[0].state=true;
  inifancytooltipsOCGs[0].state=false;
}
\else
\def\fancytempAAA{}
\fi

\if@fancytooltips@blur
\def\fancytempB{
  try {for(var i=0; fancytooltipsOCGs && i<fancytooltipsOCGs.length;i++)
    {fancytooltipsOCGs[i].state = false;} } catch (e) {}}
\else
\def\fancytempB{}
\fi

\begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
  \fancytooltipsdebugmsg

  var animace;
  var fancyTooltipsLoaded = true;

  \fancytempAAA

  function CloseTooltips()
  {
    try {this.getField("ikona").hidden=true;}catch (e) {}
    try {app.clearInterval(animace);}catch (e) {}
    \fancytempB
    \fancytempA
  }

  function nastav(cislo,strana)
  {
    var f=this.getField("ikona."+(strana));
    var g=this.getField("animtiph."+cislo);
    var sourf=f.rect;
    var sourg=g.rect;
    if ((mouseX+sourg[2]-sourg[0])<sourf[2])
    var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    else
    var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
    if (percX>100) percX=100;
    if (percY>100) percY=100;
    if (percX<0) percX=0;
    if (percY<0) percY=0;
    f.buttonAlignX=percX;
    f.buttonAlignY=percY;
  }

  function zobraz(cislo,strana)
  {
    var f=this.getField("ikona."+(strana));
    var g=this.getField("animtiph."+cislo);
    f.hidden=false;
    f.buttonSetIcon(g.buttonGetIcon());
    \fancytempAA
  }

  this.dirty=false;
  app.focusRect = false;
\end{insDLJS}
\else
\begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
  var animace;
  var fancyTooltipsLoaded = true;

  \fancytooltipsdebugmsg

  function CloseTooltips()
  {
    try {this.getField("ikona").hidden=true;}catch (e) {}
    try {app.clearInterval(animace);}catch (e) {}
  }

  function ImportTooltips()
  {
    console.println("importing pictures");
    for (var i=1;i<=\TooltipPages;i++)
    {
      this.insertPages(this.numPages-1,"\TooltipFilename.pdf",(i-1),(i-1));
      var rozm=this.getPageBox("Crop",this.numPages-1);
      this.deletePages(this.numPages-1);
      var p=this.addField("animtiph."+i,"button",0,rozm);
      p.buttonPosition=position.iconOnly;
      p.hidden=true;
      this.getField("animtiph."+i).buttonImportIcon("\TooltipFilename.pdf",(i-1));
    }
    console.println("Imported \TooltipPages pictures, save the PDF file.");
    return(1);
  }

  function nastav(cislo,strana)
  {
    var f=this.getField("ikona."+(strana));
    var g=this.getField("animtiph."+cislo);
    var sourf=f.rect;
    var sourg=g.rect;
    if ((mouseX+sourg[2]-sourg[0])<sourf[2])
    var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    else
    var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
    if (percX>100) percX=100;
    if (percY>100) percY=100;
    if (percX<0) percX=0;
    if (percY<0) percY=0;
    f.buttonAlignX=percX;
    f.buttonAlignY=percY;
  }

  function zobraz(cislo,strana)
  {
    var f=this.getField("ikona."+(strana));
    var g=this.getField("animtiph."+cislo);
    f.hidden=false;
    f.buttonSetIcon(g.buttonGetIcon());
  }

  this.dirty=false;
  app.focusRect = false;
\end{insDLJS}
\fi
\newcount\tooltip@count
\ifTooltip@usepdftex
\newcommand*{\TooltipHidden}{%
  \count@=0
  \@whilenum\count@<\TooltipPages \do{%
    \tooltip@count=\count@
    \advance \tooltip@count by 1%
    \bgroup
    \immediate\pdfximage
    page \the\tooltip@count{\TooltipFilename.pdf}%
    \mbox{\leavevmode
      \vbox to 0 pt{\vss\hbox to 0 pt{\pdfstartlink user{%
        /Subtype /Widget
        /F 6
        /T (animtiph.\the\tooltip@count)
        /FT /Btn
        /Ff 65536
        /H /N
        /BS << /W 1 /S /S >>
        /MK <<
        /TP 1
        /I \the\pdflastximage\space 0 R
        /IF << /SW /A >>
        >>
      }%
      \phantom{\pdfrefximage \pdflastximage}%
      \pdfendlink\hss}}}%
    \egroup
    \advance\count@\@ne}%
}
\else
\let\TooltipHidden\relax
\fi
\AtBeginDocument{\IfFileExists{\TooltipFilename.tips}%
  {\input{\TooltipFilename.tips}
  \PackageInfo{fancytooltips}{Inputting \TooltipFilename.tips.}}%
  {\PackageWarning{fancytooltips}{No file \TooltipFilename.tips!
      Your keywords for tooltips will not work!}}}

\def\tooltipname#1#2{\expandafter\xdef\csname FancyToolTip@#1\endcsname{#2}}

\def\FindTipNumber#1{\expandafter\ifx \csname FancyToolTip@#1\endcsname\relax
  #1\else\csname FancyToolTip@#1\endcsname\fi}

\def\checkTipNumber#1{\expandafter\ifx
  \csname FancyToolTip@#1\endcsname\relax \PackageInfo{fancytooltips}{No
    framenumber is assigned to keyword #1. I assume that #1 is the
    number of the frame.}%
  \fi}

\endinput
%%
%% End of file `fancytooltips.sty'.
