% $Id: authortitle.cbx,v 0.8e 2009/07/04 15:02:31 lehman beta $

\ProvidesFile{authortitle.cbx}
[\abx@cbxid $Id: authortitle.cbx,v 0.8e 2009/07/04 15:02:31 lehman beta $]

\ExecuteBibliographyOptions{autocite=footnote}
\newbool{cbx:parens}

\newbibmacro*{cite}{%
  \global\let\cbx@tempa=\empty
  \iffieldundef{shorthand}
    {\ifnameundef{labelname}
       {}
       {\printnames{labelname}%
        \gdef\cbx@tempa{\addcomma\space}}%
     \usebibmacro{cite:title}}%
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{citetitle}{%
  \global\let\cbx@tempa=\empty
  \iffieldundef{shorthand}
    {\usebibmacro{cite:title}}%
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{textcite}{%
  \ifnameundef{labelname}
    {\global\let\cbx@tempa=\empty}
    {\printnames{labelname}%
     \gdef\cbx@tempa{%
       \global\booltrue{cbx:parens}%
       \addspace\bibleftparen}}%
  \iffieldundef{shorthand}
    {\usebibmacro{cite:title}}%
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{cite:title}{%
  \cbx@tempa
  \printtext[bibhyperref]{%
    \printfield[citetitle]{labeltitle}}}

\newbibmacro*{cite:shorthand}{%
  \cbx@tempa
  \printtext[bibhyperref]{\printfield{shorthand}}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citetitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citetitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
  {\boolfalse{cbx:parens}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibrightparen\global\boolfalse{cbx:parens}}
     {}%
   \multicitedelim}
  {\iffieldundef{postnote}
     {\ifbool{cbx:parens}
        {\bibrightparen}
	{}}
     {\ifbool{cbx:parens}
        {\postnotedelim}
	{\addspace\bibleftparen}%
      \printfield{postnote}\bibrightparen}}

\endinput
