%%
%% Copyright (C) 2006-2007 by:
%% Josef Kleber
%% <josef.kleber@gmx.net>
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3 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.3 or later is part of all distributions of LaTeX version
%% 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "author-maintained".
%% 
%% This Current Maintainer of this work is Josef Kleber.
%%
%% This work consists of all files listed in manifest.txt.
%%
%% This style is largely based on Scott Pakin's cooltooltips.sty with minor
%% adjustmjents for the needs of dvdcoll.cls plus some new commands
%% 
\NeedsTeXFormat{LaTeX2e}[2001/06/01]%
\ProvidesPackage{pdfnotiz}[2007/03/16 v1.2 PDF tooltips (pdfnotiz.sty)]%
\RequirePackage{ifpdf}%
\RequirePackage{marginnote}%
\newcommand*{\ctip@form@fields}{}%
\ifpdf%
  \AtEndDocument{%
    \immediate\pdfobj {%
      <<%
        /Fields [\ctip@form@fields]%
        /NeedAppearances true%
      >>%
    }%
    \pdfcatalog {%
      /AcroForm \the\pdflastobj\space 0 R%
    }%
  }%
\fi%
\ifpdf%
  \setbox\@tempboxa=\hbox{}%
  \immediate\pdfxform\@tempboxa%
  \edef\ctip@empty@icon{\the\pdflastxform}%
\fi%
\newcommand*{\ctip@tip@number}{0}%
\newcommand*{\ctip@make@Text}[3][0 1 0]{%
  \pdfannot width 0pt height 0pt depth 0pt {%
    /Subtype /Text%
    /C [#1]%
    /Subj (#2)%
    /Contents (#3)%
    /NM (ctip Text \ctip@tip@number)%
    /AP <<%
      /N \ctip@empty@icon\space 0 R%
      /D \ctip@empty@icon\space 0 R%
      /R \ctip@empty@icon\space 0 R%
    >>%
    /Open false%
  }%
}%
\newcommand*{\ctip@current@page}{1}%
\newcommand*{\ctip@last@invis}{0}%
\let\ctip@label=\label%
\newcommand*{\ctip@update@pagenum}{%
  \ctip@label{ctip:tip:\ctip@tip@number}%
  \expandafter\let\expandafter\ctip@refname%
    \csname r@ctip:tip:\ctip@tip@number\endcsname%
  \@ifundefined{ctip@refname}{%
    \xdef\ctip@current@page{\thepage}%
  }{%
    \def\ctip@secondofN##1##2##3!{%
      \xdef\ctip@current@page{##2}%
    }%
    \expandafter\ctip@secondofN\ctip@refname!%
  }%
}%
\newcommand*{\ctip@make@invisible@Widget}{%
  \pdfannot width 0pt height 0pt depth 0pt {%
    /Subtype /Widget%
    /FT /Btn%
    /T (ctip invisible Widget \ctip@current@page)%
    /DA (/Helv 10 Tf 0 0 0 rg)%
    /Ff 65536%
    /F 2%
    /AA <<%
      /Fo <<%
        /Type /Action%
        /S /JavaScript%
        /JS (event.target.display = display.hidden)%
     >>%
    >>%
  }%
}%
\newsavebox{\ctip@content@box}%

\newcommand*{\ctip@unfocus@js}{%
  var ctipField =%
    this.getField("ctip invisible Widget \ctip@current@page");%
  ctipField.display = display.visible;%
  ctipField.setFocus();%
}
\newcommand*{\ctip@enter@js}{%
  if (!global.ctip_disable_popups) {%
    var ctipText =%
      this.getAnnot(this.pageNum, "ctip Text \ctip@tip@number");%
    ctipText.popupOpen = true;%
    \ctip@unfocus@js%
  }%
}%
\newcommand*{\ctip@exit@js}{%
  if (!global.ctip_disable_popups) {%
    var ctipText =%
      this.getAnnot(this.pageNum, "ctip Text \ctip@tip@number");%
    ctipText.popupOpen = false;%
    \ctip@unfocus@js%
  }%
}%
\newcommand*{\ctip@make@Widget}[3][0 1 0]{%
  \setlength{\@tempdima}{\wd\ctip@content@box}%
  \addtolength{\@tempdima}{\fboxsep}%
  \setlength{\@tempdimb}{\ht\ctip@content@box}%
  \addtolength{\@tempdimb}{0.5\fboxsep}%
  \setlength{\@tempdimc}{\dp\ctip@content@box}%
  \addtolength{\@tempdimc}{0.5\fboxsep}%
  \hspace*{-0.5\fboxsep}%
  \immediate%
  \pdfobj {%
    <<%
      /Type /Action%
	  /S /JavaScript%
%insert for click opening%
      /JS (\ctip@enter@js)%
%deleted link ability%
%     /S /URI%
%     /URI (#2)%
    >>%
  }%
  \edef\ctip@action@object{\the\pdflastobj\space 0 R}%
  \makebox[0pt][l]{%
    \advance\fboxrule by 0.9999pt%
    \pdfannot width \@tempdima%
              height \@tempdimb%
              depth \@tempdimc {%
      /Subtype /Link%
      /A \ctip@action@object%
      /Border [0 0 \strip@pt\fboxrule]%
      /C [#1]%
    }%
  }%
  \pdfannot width \@tempdima%
            height \@tempdimb%
            depth \@tempdimc {%
    /Subtype /Widget%
    /FT /Btn%
    /T (ctip Field \ctip@tip@number)%
    /TU (#3)%
    /DA (/Helv 10 Tf 0 0 0 rg)%
    /Ff 65536%
    /BS <<%
      /Type /Border%
      /W \strip@pt\fboxrule%
    >>%
    /MK <<%
      /BC [#1]%
      /TP 1%
    >>%
    /AA <<%
%deleting moseover effects
%      /E <<
%        /Type /Action
%        /S /JavaScript
%        /JS (\ctip@enter@js)
%      >>
%      /X <<
%        /Type /Action
%        /S /JavaScript
%        /JS (\ctip@exit@js)
%      >>
      /U <<%
        /Type /Action%
        /S /JavaScript%
        /JS (\ctip@unfocus@js)%
        /Next \ctip@action@object%
      >>%
    >>%
  }%
  \xdef\ctip@form@fields{\ctip@form@fields\space\the\pdflastannot\space 0 R}%
}%
\DeclareRobustCommand{\cooltooltip}[1][0 1 0]{%
  \def\ctip@popup@color{#1}%
  \ctip@cooltooltip@i%
}%
\newcommand*{\ctip@cooltooltip@i}[6][\ctip@popup@color]{%
  \savebox{\ctip@content@box}{#6}%
  \@tempcnta=\ctip@tip@number%
  \advance\@tempcnta by 1%
  \xdef\ctip@tip@number{\the\@tempcnta}%
  \ctip@update@pagenum%
  \@tempcnta=\ctip@last@invis%
  \@tempcntb=\ctip@current@page%
  \ifnum\@tempcnta<\@tempcntb%
    \ctip@make@invisible@Widget%
    \xdef\c@ctip@last@invis{\ctip@current@page}%
  \fi%
  \makebox[0pt][l]{%
    \ctip@make@Widget[#1]{#4}{#5}%
    \makebox[\paperwidth][r]{%
      \ctip@make@Text[\ctip@popup@color]{#2}{#3}%
    }%
  }%
  \usebox{\ctip@content@box}%
}%
\DeclareRobustCommand{\cooltooltiptoggle}[1]{%
  \savebox{\ctip@content@box}{#1}%
  \makebox[0pt][l]{%
    \pdfannot width \wd\ctip@content@box%
              height \ht\ctip@content@box%
              depth \dp\ctip@content@box {%
      /Subtype /Link%
      /Border [0 0 0]%
      /A <<%
        /Type /Action%
        /S /JavaScript%
        /JS (%
          global.ctip_disable_popups = !global.ctip_disable_popups;%
          var ctipField;%
          var i;%
          for (i=1; (ctipField=this.getField("ctip Field " + i)); i++)%
            ctipField.display =%
              global.ctip_disable_popups ? display.hidden : display.visible;%
        )%
      >>%
    }%
  }%
  \usebox{\ctip@content@box}%
}%
\RequirePackage{ifpdf}%
\ifpdf%
\else%
  \PackageWarning{pdfnotiz}{%
    Not running pdfLaTeX in PDF mode; disabling pdf annotations%
  }%
  \renewcommand*{\ctip@cooltooltip@i}[6][]{\mbox{#6}}%
\fi%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%simplfied run time optimized version of hyperrref's \pdfstringdef for long texts
\def\pn@pdf@string@def#1#2{%
  \begingroup
    \escapechar`\\%
    \edef\0{\string\0}%
    \edef\1{\string\1}%
    \edef\2{\string\2}%
    \edef\3{\string\3}%
    \ifHy@unicode
      \edef\8{\string\8}%
      \edef\9{\string\9}%
      \fontencoding{PU}%
      \HyPsd@UTFviii
    \else
      \fontencoding{PD1}%
    \fi
    \enc@update
    \@inmathwarn\pdfstringdef
    \let\@inmathwarn\HyPsd@inmathwarn
    \let\add@accent\HyPsd@add@accent
    \let\{\textbraceleft
    \let\}\textbraceright
    \let\\\textbackslash
    \let\#\textnumbersign
    \let\$\textdollar
    \let\%\textpercent
    \let\&\textampersand
    \let\_\textunderscore
    \let\P\textparagraph
    \let\ldots\textellipsis
    \let\dots\textellipsis
    \def\\{\pdfstringdefWarn\\}%
    \def\newline{\pdfstringdefWarn\newline}%
    \def\TeX{TeX}%
    \def\LaTeX{La\TeX}%
    \def\LaTeXe{\LaTeX2e}%
    \def\eTeX{e-\TeX}%
    \def\MF{Metafont}%
    \def\MP{Metapost}%
    \let\emph\@firstofone
    \let\textbf\@firstofone
    \let\textit\@firstofone
    \let\textmd\@firstofone
    \let\textnormal\@firstofone
    \let\textrm\@firstofone
    \let\textsc\@firstofone
    \let\textsf\@firstofone
    \let\textsl\@firstofone
    \let\texttt\@firstofone
    \let\textup\@firstofone
    \let\ttfamily\@empty
    \let\sffamily\@empty
    \let\itshape\@empty
    \let\upshape\@empty
    \let\bfseries\@empty
    \let\rm\@empty
    \let\Huge\@empty
    \let\LARGE\@empty
    \let\Large\@empty
    \let\footnotesize\@empty
    \let\huge\@empty
    \let\large\@empty
    \let\normalsize\@empty
    \let\scriptsize\@empty
    \let\small\@empty
    \let\tiny\@empty
    \def\textcolor##1##{\@secondoftwo}%
    \let\textlatin\@firstofone
    \@ifundefined{language@group}{}{%
      \csname HyPsd@babel@\language@group\endcsname
    }%
    \let\@safe@activestrue\relax
    \let\@safe@activesfalse\relax
    \let\cyr\relax
    \let\es@roman\@Roman
    \let\glqq\textglqq
    \let\grqq\textgrqq
    \let\glq\textglq
    \let\grq\textgrq
    \let\flqq\textflqq
    \let\frqq\textfrqq
    \let\flq\textflq
    \let\frq\textfrq
    \let\if@mid@expandable\@firstoftwo
    \HyPSD@AMSclassfix
    \let\hspace\HyPsd@hspace
    \let\label\@gobble
    \let\index\@gobble
    \let\glossary\@gobble
    \let\href\@secondoftwo
    \let\ref\HyPsd@ref
    \let\pageref\HyPsd@pageref
    \let\autoref\HyPsd@autoref
    \let\leavevmode\@empty
    \let\mbox\@empty
    \def\halign{\pdfstringdefWarn\halign\@gobble}%
    \ifHy@CJKbookmarks
      \HyPsd@CJKhook
    \fi
    \Hy@pdfstringtrue
    \pdfstringdefPreHook
    \HyPsd@LetUnexpandableSpace\space
    \HyPsd@LetUnexpandableSpace\ %
    \HyPsd@LetUnexpandableSpace~%
    \HyPsd@LetUnexpandableSpace\nobreakspace
    \@ifundefined{@xspace}{%
      \let\xspace\HyPsd@ITALCORR
    }{%
      \let\xspace\HyPsd@XSPACE
    }%
    \let\/\HyPsd@ITALCORR
    \let\bgroup\/%
    \let\egroup\/%
    \let\discretionary\@gobbletwo
    \let\@ifnextchar\HyPsd@ifnextchar
    \let\@ifnextchar\HyPsd@new@ifnextchar
    \let\@protected@testopt\HyPsd@protected@testopt
    \begingroup
      \let\GenericError\@gobblefour
      \let\GenericWarning\@gobbletwo
      \let\GenericInfo\@gobbletwo
      \ifx\nofrenchguillemets\@undefined
      \else
        \nofrenchguillemets
      \fi
      \let\Hy@temp\xdef
      \let\def\HyPsd@DefCommand
      \let\gdef\HyPsd@DefCommand
      \let\edef\HyPsd@DefCommand
      \let\xdef\HyPsd@DefCommand
      \let\futurelet\HyPsd@LetCommand
      \let\let\HyPsd@LetCommand
      \Hy@temp#1{#2}%
    \endgroup
    \ifx#1\@empty
    \else
      \xdef#1{#1\@empty}%
    \fi
    \ifHy@unicode
      \HyPsd@ConvertToUnicode#1%
    \fi
    \pdfstringdefPostHook#1%
  \endgroup
}%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\pn@pdf@boxcolor{0 0 1}%
\def\pn@pdf@linkcolor{0 0 1}%
\gdef\pn@pdf@desc{}%
%
\newcommand{\pdfnote}[1]%
{%
  \cooltooltip[\pn@pdf@boxcolor][\pn@pdf@linkcolor]{\dc@pdf@subject}{\pn@pdf@desc}{}{}{#1}%
  \gdef\pn@pdf@desc{}%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\pn@pdfmarginnote@color{0 0 1}%
\def\pn@pdfmarginnote@subject{Info}%
\def\pn@pdfmarginnote@type{Help}%
%
\newcommand{\pdfmarginnote}[2][\pn@pdfmarginnote@type]{%
\def\pn@notiz{}%
\pdfstringdef\pn@notiz{#2}%
\marginnote{%
             \pdfannot width 0pt height \baselineskip depth 0pt%
             {%
               /Subtype /Text%
		       /C [\pn@pdfmarginnote@color]%
		       /Subj (\pn@pdfmarginnote@subject)%
		       /Name (#1)%
               /TU ( )%
               /Contents (\pn@notiz)%
               /Open false%
             }%
           }%
}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput%