%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% historian.cbx, v0.4, 2010/08/22
% A citation style for use with biblatex
% Developed and maintained by Sander Gliboff, 
% based on guidelines from the Turabian Manual for Writers, 7th ed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesFile{historian.cbx}[2010/08/22 v0.4 historian citation style]

   \@ifpackagelater{biblatex}{2010/08/04}
     {}
     {\PackageError{biblatex}
	{Outdated 'biblatex' package
	The 'historian' style requires biblatex v0.9b or later.\MessageBreak
	 You are using: '\csuse{ver@biblatex.sty}'.\MessageBreak
	 This is a fatal error.}%
      \endinput}


%Redefine \blockcquote command of the csquotes package to generate a footnote
\SetCiteCommand{\footcite}


\ExecuteBibliographyOptions{citetracker=context,ibidtracker=constrict,singletitle,pagetracker,autocite=footnote}%
\DeclareLanguageMapping{american}{historian}%Added
\ExecuteBibliographyOptions{abbreviate=false,dateabbrev=false}%Added

%Option to suppress the crossreferences to first citation of a source (new in v. 0.2)
\newtoggle{noterefsflag}
\toggletrue{noterefsflag}
\DeclareBibliographyOption{printnoterefs}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{noterefsflag}}%
		{\togglefalse{noterefsflag}}}%
\DeclareEntryOption{printnoterefs}[true]
	{\ifstrequal{#1}{true}
		{\toggletrue{noterefsflag}}%
		{\togglefalse{noterefsflag}}}%
		
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This style builds on Lehman's original verbose-inote style,
%from which the following macros are copied:


\DeclareFieldFormat{bibhyperlink}{%
  \bibhyperlink{\thefield{entrykey}:\csuse{cbx@\iffootnote{f}{t}@\thefield{entrykey}}}{#1}}
  
\DeclareFieldFormat{bibhypertarget}{%
  \bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{#1}}
  
\providecommand*{\mkibid}[1]{#1}

\newtoggle{cbx:loccit}
\newtoggle{cbx:pageref}

%The following are changed from verbose-inote to initialize the citepages option as `omit'
\newcommand\citepagesseparator{\bibpagespunct}
\newbibmacro*{cite:citepages}{}
\newbibmacro*{cite:full:citepages}{\ifboolexpr{
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
      and
      test {\iffieldpages{postnote}}
    }
      {\togglefalse{printpagerange}}
      {}}
\newbibmacro*{cite:postnote}{\usebibmacro{cite:postnote:ibidpage}}

\DeclareBibliographyOption{ibidpage}[true]{%
  \ifstrequal{#1}{true}
    {\ExecuteBibliographyOptions{loccittracker=constrict}}
    {\ExecuteBibliographyOptions{loccittracker=false}}}
\DeclareBibliographyOption{pageref}[true]{%
  \settoggle{cbx:pageref}{#1}}

\DeclareBibliographyOption{citepages}[permit]{%
  \ifcsdef{cbx@opt@citepages@#1}
    {\csuse{cbx@opt@citepages@#1}}
    {\PackageError{biblatex}
       {Invalid option 'citepages=#1'}
       {Valid values are 'permit', 'suppress', 'omit', 'separate'.}}}

\def\cbx@opt@citepages@permit{%
  \renewcommand\citepagesseparator{\addcomma\addspace}%Changed: no colon in this case
  \renewbibmacro*{cite:citepages}{}%
  \renewbibmacro*{cite:full:citepages}{}%
  \renewbibmacro*{cite:postnote}{%
    \usebibmacro{cite:postnote:ibidpage}}}

\def\cbx@opt@citepages@suppress{%
  \renewbibmacro*{cite:citepages}{}%
  \renewbibmacro*{cite:full:citepages}{%
    \togglefalse{printpagerange}}%
  \renewbibmacro*{cite:postnote}{%
    \usebibmacro{cite:postnote:ibidpage}}}

\def\cbx@opt@citepages@omit{%
\relax}%Changed--macros initialized for the omit option

\def\cbx@opt@citepages@separate{%
  \renewcommand\citepagesseparator{\addcomma\addspace}%Changed: no colon in this case
  \providetoggle{cbx:fullcite}%
  \renewbibmacro*{cite:citepages}{%
    \global\togglefalse{cbx:fullcite}}%
  \renewbibmacro*{cite:full:citepages}{%
    \global\toggletrue{cbx:fullcite}}%
  \renewbibmacro*{cite:postnote}{%
    \ifboolexpr{
      togl {cbx:fullcite}
      and
      test {\iffieldpages{postnote}}
      and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
      and
      (
	not test {\iffieldundef{pages}}
	or
	not test {\iffieldundef{pagetotal}}
      )
    }
      {\usebibmacro{cite:postnote:pages}}
      {\usebibmacro{cite:postnote:ibidpage}}}
  \providebibmacro*{cite:postnote:pages}{%
    \setunit{\postnotedelim}%
    \bibstring{thiscite}%
    \setunit{\addspace}%
    \printfield{postnote}}}

\newbibmacro*{cite}{%
  \usebibmacro{cite:citepages}%
  \global\togglefalse{cbx:loccit}%
  \ifciteseen
    {\iffieldundef{shorthand}
       {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
          {\usebibmacro{cite:ibid}}
          {\usebibmacro{cite:short}}}
       {\usebibmacro{cite:shorthand}}}
    {\usebibmacro{cite:full}%
     \usebibmacro{cite:save}}}

\newbibmacro*{cite:save}{%
  \csxdef{cbx@t@\thefield{entrykey}}{\the\value{instcount}}}

\newbibmacro*{cite:full}{%
  \usebibmacro{cite:full:citepages}%
  \printtext[bibhypertarget]{%
    \usedriver
      {\DeclareNameAlias{sortname}{default}}
      {\thefield{entrytype}}}%
  \usebibmacro{shorthandintro}}

\newbibmacro*{cite:short}{%
  \printnames{labelname}%
  \setunit*{\nametitledelim}%
  \printtext[bibhyperlink]{%
    \printfield[citetitle]{labeltitle}}}

\newbibmacro*{cite:shorthand}{%
  \printtext[bibhyperlink]{\printfield{shorthand}}}

\newbibmacro*{cite:ibid}{%
  \printtext[bibhyperlink]{\bibstring[\mkibid]{ibidem}}%
  \ifloccit
    {\global\toggletrue{cbx:loccit}}
    {}}

\newbibmacro*{cite:postnote:ibidpage}{%
  \iftoggle{cbx:loccit}
    {}
    {\usebibmacro{postnote}}}

%\newbibmacro*{footcite}{%
%  \usebibmacro{cite:citepages}%
%  \global\togglefalse{cbx:loccit}%
%  \ifciteseen
%    {\iffieldundef{shorthand}
%       {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
%          {\usebibmacro{footcite:ibid}}
%          {\usebibmacro{footcite:note}}}
%       {\usebibmacro{footcite:shorthand}}}
%    {\usebibmacro{footcite:full}%
%     \usebibmacro{footcite:save}}}

\newbibmacro*{footcite:save}{%
  \csxdef{cbx@f@\thefield{entrykey}}{\the\value{instcount}}%
  \label{cbx@\the\value{instcount}}}

%\newbibmacro*{footcite:full}{%
%  \usebibmacro{cite:full:citepages}%
%  \printtext[bibhypertarget]{%
%    \usedriver
%      {\DeclareNameAlias{sortname}{default}}
%      {\thefield{entrytype}}}%
%  \usebibmacro{shorthandintro}}

%\newbibmacro*{footcite:note}{%
%  \ifnameundef{labelname}
%    {\printfield{label}}
%    {\printnames{labelname}}%
%  \ifsingletitle
%    {}
%    {\setunit*{\nametitledelim}%
%     \printfield[title]{labeltitle}}%
%  \setunit*{\addcomma\space}%
%  \printtext{%
%    \bibstring{seenote}\addnbspace
%    \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}%
%    \iftoggle{cbx:pageref}
%      {\ifsamepage{\the\value{instcount}}
%                  {\csuse{cbx@f@\thefield{entrykey}}}
%         {}
%	 {\addcomma\space\bibstring{page}\addnbspace
%	  \pageref{cbx@\csuse{cbx@f@\thefield{entrykey}}}}}
%      {}}}

\newbibmacro*{footcite:shorthand}{%
  \printtext[bibhyperlink]{\printfield{shorthand}}}

\newbibmacro*{footcite:ibid}{%
  \printtext[bibhyperlink]{\bibstring[\mkibid]{ibidem}}%
  \ifloccit
    {\global\toggletrue{cbx:loccit}}
    {}}

%\DeclareCiteCommand{\cite}
%  {\usebibmacro{prenote}}
%  {\usebibmacro{citeindex}%
%   \iffootnote
%     {\usebibmacro{footcite}}
%     {\usebibmacro{cite}}}
%  {\multicitedelim}
%  {\usebibmacro{cite:postnote}}

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

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

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}
  
%End of inherited routines from verbose-inote 

%%%%%%%%%%		MODIFIED CITE AND FOOTCITE CITECOMMANDS		%%%%%%%%%%%%%%%%%%%%%%%%%%

\newtoggle{repeatedcitationflag}%Needed for punctuating postnote

\DeclareCiteCommand{\cite}
	{\usebibmacro{prenote}}
	{\usebibmacro{citeindex}%
%Test for repeated citation before the new key gets saved
	\ifciteseen
		{\toggletrue{repeatedcitationflag}}%
		{\togglefalse{repeatedcitationflag}}%
		\iffootnote
			{%then call footcite macro
				\usebibmacro{footcite}}%
			{%else cite macro instead of footcite
				\usebibmacro{cite}}}%
	{\multicitedelim}
	{\ifthenelse{\equal{\thefield{entrytype}}{\entrytypearticle}}
		{%Then special case for articles with page ranges in postnote
			\ifboolexpr{test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
     					 and test {\iffieldpages{postnote}}}
				{%Page range was suppressed; need colon instead of comma before postnote
					\iftoggle{repeatedcitationflag}
						{%then exception after short forms in repeated citations
							\relax}%
						{%else insert the colon
							\citepagesseparator}%
					}%
				{%else no page range recognized in postnote
					\relax}%
			}%
		{%Else not an article
			\relax
			}%
		\usebibmacro{cite:postnote}
	}%End postcode


\DeclareCiteCommand{\footcite}[\mkbibfootnote]
	{\usebibmacro{prenote}}
	{\usebibmacro{citeindex}%
%Test for repeated citation before the new key gets saved
	\ifciteseen
		{\toggletrue{repeatedcitationflag}}%
		{\togglefalse{repeatedcitationflag}}%
	\usebibmacro{footcite}}
	{\multicitedelim}
{\ifthenelse{\equal{\thefield{entrytype}}{\entrytypearticle}}
		{%Then special case for articles with page ranges in postnote
			\ifboolexpr{test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
     					 and test {\iffieldpages{postnote}}}
				{%Pages field was suppressed; need colon instead of comma before postnote
					\iftoggle{repeatedcitationflag}
						{%then exception after short forms in repeated citations
							\relax}%
						{%else insert the colon
							\citepagesseparator}%
					}%
				{%else no page range recognized in postnote
					\relax}%
			}%
		{%Else not an article
			\relax
			}%
		\usebibmacro{cite:postnote}
	}%End postcode
  

%%%%%%%%%%		MODIFIED FOOTCITE MACRO		%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Loopcode of footcite command modified from verbose-inote to include special short forms
\newbibmacro*{footcite}{%
\usebibmacro{cite:citepages}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
	{%then1 repeated citation
		\iffieldundef{shorthand}%
       		{%Then2 no shorthand
				\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypeclassic}%
       			\OR\equal{\thefield{entrysubtype}}{\subtypebiblical}}%
       				{%Then3 use special short form for classics, instead of ibid. or note
						\usebibmacro{footcite:shortclassic}}%
					{%Else3
						\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypepublicdocument}%
						\OR\equal{\thefield{entrytype}}{legal}%
						\OR\equal{\thefield{entrytype}}{legislation}%
						\OR\equal{\thefield{entrytype}}{jurisdiction}}%
							{%Then4 different short form for government documents
								\usebibmacro{footcite:shortgov}}%
							{%Else4 default routines
								\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
									{\usebibmacro{footcite:ibid}}%
          							{\usebibmacro{footcite:note}}%
							}%Endif, end else4
					}%Endif, end else3
			}%End then2
			{%Else2 use shorthand
				\usebibmacro{footcite:shorthand}%
			}%Endif, end else2
	}%End then1
    {%Else1 not a repeated citation: cite in full
    	\usebibmacro{footcite:full}%
     	\usebibmacro{footcite:save}%
	}%Endif, end else1
}%End footcite macro

     
%Like the Verbose styles, historian.cbx uses the drivers from the bbx file
\newbibmacro*{footcite:full}{%
%Bbx file defines periods as unit punctuation; here we change to commas
\renewcommand\newunitpunct{\addcomma\addspace}%
\usebibmacro{cite:full:citepages}%
\printtext[bibhypertarget]{%
	\usedriver
      {\DeclareNameAlias{sortname}{default}}
      {\thefield{entrytype}}}%
  \usebibmacro{shorthandintro}}%


\newbibmacro*{footcite:shorthand}{%
  \printtext[bibhyperlink]{\printfield{shorthand}}}

\newbibmacro*{footcite:ibid}{%
  \printtext[bibhyperlink]{\bibstring[\mkibid]{ibidem}}%
  \ifloccit
    {\global\toggletrue{cbx:loccit}}
    {}}


\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

%Modified from verbose-inote.cbx to include special short forms for letters, archives, documents, and some non-print sources
\newbibmacro*{footcite:note}{%
\ifnameundef{labelname}
    {\printfield{label}}%
    {\ifthenelse{\equal{\thefield{entrytype}}{performance}}%
		{%Titles only
			\printfield[title]{labeltitle}}%
		{\printnames{labelname}%
    		\ifthenelse{\equal{\thefield{entrytype}}{letter}}%
    			{\setunit*{\addspace\bibstring{letterto}\addspace}%
			\printnames[labelname]{namec}%
			\setunit{\addcomma\addspace}%
			\usebibmacro{date}}%
			{\ifthenelse{\equal{\thefield{entrytype}}{customa}}
				{\setunit*{\addspace}%
				\printfield[noformat]{nameaddon}}%
				{\relax}}}%
    }%
\ifsingletitle
    {\relax}%
    {\ifthenelse{\equal{\thefield{entrytype}}{performance}}
    		{%Title label already printed
			\relax}%
		{\setunit*{\nametitledelim}%
		\printfield[title]{labeltitle}%
		\ifthenelse{\equal{\thefield{entrytype}}{customd}}%
			{\setunit*{\addcomma\addspace}%
			\printfield[noformat]{titleaddon}%
			\setunit*{\addspace}%
			\printnames[labelname]{namec}}%
		{\relax}%
     	}%
	}%
\iftoggle{noterefsflag}%
	{%Then option set for note references
		\iftoggle{xrefflag}
  			{%Then suppress note function in crossreferences in any case
				\relax}%
			{%Else print note number
				\setunit{\addcomma\space}%
				\printtext {%
				    \bibstring{seenote}\addnbspace
				    \ref{cbx@\csuse{cbx@f@\thefield{entrykey}}}%
				    \iftoggle{cbx:pageref}
				      {\ifsamepage{\the\value{instcount}}
				                  {\csuse{cbx@f@\thefield{entrykey}}}
				         {}
					 {\addcomma\space\bibstring{page}\addnbspace
					  \pageref{cbx@\csuse{cbx@f@\thefield{entrykey}}}}}
				      {}}%end printtext
      			}%endelse, endiftoggle
		}%Endthen
    {%Else option set to suppress note references
    		\relax}%Endiftoggle
}
     
\newbibmacro{footcite:shortclassic}{%
\iffieldundef{label}%
	{\ifnameundef{shortauthor}
		{\printnames{author}}%
		{\printnames{shortauthor}}%
	\unspace
	\setunit{\addspace}%
	\iffieldundef{shorttitle}
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
			{\printfield[noformat]{title}}%
			{\printfield{title}}}%
		{\ifthenelse{\equal{\thefield{entrysubtype}}{\subtypebiblical}}
			{\printfield[noformat]{shorttitle}\isdot}%
			{\printfield[title]{shorttitle}\isdot}}}%
	{\printfield{label}}%
}%

     
\newbibmacro{footcite:shortgov}{%
\iffieldundef{label}%
	{\ifnameundef{shortauthor}%
		{\ifthenelse{\equal{\thefield{authortype}}{\authortyperedundant}}%
			{\relax}%
			{\printnames{author}\setunit*{\addcomma\addspace}}}%
		{\printnames{shortauthor}\setunit*{\addcomma\addspace}}%
	\iffieldundef{shorttitle}%
		{\iffieldundef{title}%
			{\iffieldundef{shortjournal}%
				{\printfield[title]{journaltitle}}%
				{\printfield[title]{shortjournal}\isdot}%
			\setunit{\addcomma\addspace}%
			\printfield{note}\isdot\setunit{\addcomma\addspace}%
			\printfield[noformat]{volume}%
			\printfield{part}%
			}%
			{\printfield{title}}%
			}%
		{\printfield[title]{shorttitle}\isdot}}%
	{\printfield{label}}%
}%

%%%%%%%%%%	CITE-COMMAND VARIATIONS WITH ALTERNATE PUNCTUATION		%%%%%%%%

%Special foocite command with a period before the postnote
\DeclareCiteCommand{\footcitedot}[\mkbibfootnote]
  {\bibsentence
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}%
  {\multicitedelim}%
  {\iftoggle{cbx:loccit}
    {}
    {\iffieldundef{postnote}
    		{}
    		{\addperiod\addspace
     	\printfield{postnote}}}}%
 
%Special footcite command without punctuation or spacing before the postnote    
\DeclareCiteCommand{\footcitenodot}[\mkbibfootnote]
  {\bibsentence
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}%
  {\multicitedelim}%
  {\iftoggle{cbx:loccit}%
    {}%
    {\iffieldundef{postnote}%
    		{}%
    		{\setunit{\unspace}%
		\printfield{postnote}}}}%
		
 
%Special footcite command with a colon before the postnote    
\DeclareCiteCommand{\footcitecolon}[\mkbibfootnote]
{\bibsentence
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%   		
%Set flag to have article driver print pages field only when there's no postnote
\iffieldundef{postnote}
	{\toggletrue{printpagerange}}%
	{\togglefalse{printpagerange}}%
\usebibmacro{footcite}}%
{\multicitedelim}%
{\iftoggle{cbx:loccit}%
	{}
    {\iffieldundef{postnote}%
    		{\relax}%
    		{\bibpagespunct
		\printfield{postnote}}}}%
		

%Special cite command with a period before the postnote (new in v. 0.2)
\DeclareCiteCommand{\citedot}[]
  {\bibsentence
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}% [Sic. The \cite macro doesn't have all the short forms]
  {\multicitedelim}%
  {\iftoggle{cbx:loccit}
    {}
    {\iffieldundef{postnote}
    		{}
    		{\addperiod\addspace
     	\printfield{postnote}}}}%
 
%Special cite command without punctuation before the postnote (new in v. 0.2)
\DeclareCiteCommand{\citenodot}[]
  {\bibsentence
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{footcite}}% [Sic. The \cite macro doesn't have all the short forms]
  {\multicitedelim}%
  {\iftoggle{cbx:loccit}%
    {}%
    {\iffieldundef{postnote}%
    		{}%
    		{%\addspace
		\printfield{postnote}}}}%
		
%Special cite command with a colon before the postnote (new in v. 0.2)
\DeclareCiteCommand{\citecolon}[]%
{\bibsentence
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%   		
%Set flag to have article driver print pages only when there's no postnote
\iffieldundef{postnote}
	{\toggletrue{printpagerange}}%
	{\togglefalse{printpagerange}}%
\usebibmacro{footcite}}% [Sic. The \cite macro doesn't have all the short forms]
{\multicitedelim}%
{\iftoggle{cbx:loccit}%
	{}
    {\iffieldundef{postnote}%
    		{\relax}%
    		{\bibpagespunct
		\printfield{postnote}}}}%
		
%Multicite versions with modified punctuation between citations

\DeclareMultiCiteCommand{\footcitedots}[\mkbibfootnote]{\footcite}{\addperiod\addspace}%
\DeclareMultiCiteCommand{\footcitenodots}[\mkbibfootnote]{\footcite}{\space}

%%%%%%%%%		MODIFIED PARENCITE	%%%%%%%%%%%%%%%%%%%%%%%%%

%Special author-title form for parenthetical notes
\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
    \iffieldundef{shorthand}%
    {\usebibmacro{parenauthor}%
    \setunit*{\addcomma\addspace}%
    \iffieldundef{shorttitle}%
    {\printfield[citetitle]{title}}%
    {\printfield[citetitle]{shorttitle}}}%
    {\printfield{shorthand}}}%
  {\multicitedelim}%
  {\usebibmacro{cite:postnote}}%
\newbibmacro{parenauthor}{%
\ifnameundef{author}
    {%Then Author not in use; try editor, translator
    		\ifnameundef{editor}%
       		{\ifnameundef{translator}%
					{}
    				{\printnames[lastname]{translator}%
    				 \addcomma\space
    				 \usebibmacro{translatorstrg}}%
				}%
       		{\printnames[lastname]{editor}%
    			 \addcomma\space
				\iffieldundef{editortype}
				    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
				       {eds.\isdot}%
				       {ed.\isdot}%
				       }%
				    {\ifthenelse{\value{editor}>1\OR\ifandothers{editor}}
				       {\bibstring{type\thefield{editortype}s}}%
				       {\bibstring{type\thefield{editortype}}}%
				       }%
				}%
	}%
	{%Else check for anonymous, but known, authorship
		\ifthenelse{\equal{\thefield{authortype}}{\authortypeanon}}%
			{%then anonymous author goes in brackets; usual punctuation outside brackets
					\mkbibbrackets{\printnames[lastname]{author}}%
			}%
			{%else check for uncertain authorship
				\ifthenelse{\equal{\thefield{authortype}}{\authortypeunsure}}%
					{%then question mark in brackets; usual punctuation outside brackets
						\mkbibbrackets{\printnames[lastname]{author}\addquestion}%
					}%
					{%else no brackets; check for redundant author
						\ifthenelse {\equal{\thefield{authortype}}{\authortyperedundant}}%
							{\relax}%
							{%else authortype not redundant, just print as usual
								\printnames[lastname]{author}}%
					}%
			}%endif
	\iffieldundef{nameaddon}%
		{\relax}%
		{\setunit*{\addspace}%
		\printfield{nameaddon}\ifpunctmark{.}{\isdot}{\relax}}%
		\setunit*{\labelnamepunct\addspace}%
	}%
}%end of macro

%%%%%%%%%	CITE COMMAND FOR ANNOTATIONS---new in v. 0.2  %%%%%%%%%%%%%
%For printing both abstract and annotation after main citation (new in v. 0.2)
\DeclareCiteCommand{\citeannote}[]
{%
\bibsentence%
\usebibmacro{prenote}%
}%
{\usebibmacro{citeindex}%
\usebibmacro{footcite}%
\setunit{\addperiod}%
\printtext{\unspace}%Just to force unit punctuation before indentannote environment
    \begin{indentannote}
    		\usebibmacro{annotation}%
		\finentry
	\end{indentannote}
}%
{}%
{\iftoggle{cbx:loccit}
	{}
	{\iffieldundef{postnote}
		{}%
		{\addcomma\addspace
     	\printfield{postnote}}%
	}%
}%

%%%%%%%%%%		MODIFIED CITE AND FOOTCITE WITH URL AFTER POSTNOTE		%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareCiteCommand{\citeurllast}
	{\usebibmacro{prenote}}
	{\usebibmacro{citeindex}%
	\toggletrue{urllastflag}%
	\iffootnote
		{\usebibmacro{footcite}}%
		{\usebibmacro{cite}}}%
	{\multicitedelim}
	{\relax}% Postnote already printed by onlinelocation macro in bbx


\DeclareCiteCommand{\footciteurllast}[\mkbibfootnote]
	{\usebibmacro{prenote}}%
	{\usebibmacro{citeindex}%
	\toggletrue{urllastflag}%
	\usebibmacro{footcite}}%
	{\multicitedelim}%
	{\relax}% Postnote already printed by onlinelocation macro in bbx	
%%%%%%%%%%	CITE COMMANDS FOR CROSSREFERENCING  %%%%%%%%%%%%%%%%%%%%%%
  
% Cross-referencing to collection in footnotes
%(The corresponding routine for bibliography cross-referencing is in the bbx file)
\DeclareCiteCommand{\cbx@crosstocoll}[]{}{%
\toggletrue{xrefflag}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
	{\iffieldundef{shorthand}%
		{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
			{\usebibmacro{footcite:ibid}}%
			{\usebibmacro{footcite:note}}%
		}%
		{\usebibmacro{footcite:shorthand}%
		}%
	}%
	{\printtext{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{%
			\usebibmacro{getbookinfo}}%
			\usebibmacro{shorthandintro}}%	
			\usebibmacro{footcite:save}%
	}%
}{}{}%

  
% Cross-referencing to periodical in footnotes
%(The corresponding routine for bibliography cross-referencing is in the bbx file)
\DeclareCiteCommand{\cbx@crosstoper}[]{}{%
\toggletrue{xrefflag}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
	{\iffieldundef{shorthand}%
		{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
			{\usebibmacro{footcite:ibid}}%
			{\usebibmacro{footcite:note}}%
		}%
		{\usebibmacro{footcite:shorthand}%
		}%
	}%
	{\printtext{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{%
			\usebibmacro{journal+issuetitle}}%
			\usebibmacro{shorthandintro}}%	
			\usebibmacro{footcite:save}%
	}%
}{}{}%
  
% Cross-referencing to customa in footnotes
%(The corresponding routine for bibliography cross-referencing is in the bbx file)
\DeclareCiteCommand{\cbx@crosstoarch}[]{}{%
\toggletrue{xrefflag}%
\global\togglefalse{cbx:loccit}%
\usebibmacro{in:}%
\ifciteseen%
	{\iffieldundef{shorthand}%
		{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
			{\usebibmacro{footcite:ibid}}%
			{\usebibmacro{footcite:note}}%
		}%
		{\usebibmacro{footcite:shorthand}%
		}%
	}%
	{\printtext{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{%
			\usebibmacro{getarchiveinfo}}%
			\usebibmacro{shorthandintro}}%	
			\usebibmacro{footcite:save}%
	}%
}{}{}%

  
% Cross-referencing to reference in footnotes
%(The corresponding routine for bibliography cross-referencing is in the bbx file)
\DeclareCiteCommand{\cbx@crosstoref}[]{}{%
\toggletrue{xrefflag}%
\global\togglefalse{cbx:loccit}%
\ifciteseen
	{\iffieldundef{shorthand}%
		{\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}%
			{\usebibmacro{footcite:ibid}}%
			{\usebibmacro{footcite:note}}%
		}%
		{\usebibmacro{footcite:shorthand}%
		}%
	}%
	{\printtext{\bibhypertarget{\thefield{entrykey}:\the\value{instcount}}{%
				\usebibmacro{getbooktitle}%
				\newunit\newblock
				\printfield{edition}%
				\newunit\newblock
				\printfield{note}%
				}%
			\usebibmacro{shorthandintro}}%	
			\usebibmacro{footcite:save}%
	}%
}{}{}%

\endinput