% COOPE style

\usepackage{graphicx}
\usepackage[small,bf,justification=justified,singlelinecheck=false]{caption}
\usepackage[margin=.7in]{geometry}
\usepackage{listings}
\usepackage{color}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{multirow}

\hypersetup{colorlinks,
           citecolor=black,
           filecolor=black,
           linkcolor=black,
           urlcolor=black,
           bookmarksopen=true,
           pdftex}

\definecolor{gray}{rgb}{0.3,0.3,0.3}
\definecolor{darkgray}{rgb}{0.2,0.2,0.2}
\definecolor{lightgray}{rgb}{0.6,0.6,0.6}

\newcommand{\jsref}{\textmd Listing~\ref}
\newcommand{\fref}{\textmd Figure~\ref}

% denotes a non-free reference (to be used in .bib file)
\newcommand{\citenf}{\textbf[NF]}

\lstdefinelanguage{JavaScript}{%
  keywords={%
    undefined,null,true,false,NaN,Infinity,return,%
    try,catch,finally,function,var,if,then,else,%
    in,while,do,done,case,break,continue,%
    new,typeof,void,in,instanceof%
  },
  keywordstyle=\color{gray},
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  commentstyle=\color{lightgray}
}

\lstset{%
  language=JavaScript,
  aboveskip=12pt,
  columns=fullflexible,
  keepspaces=true,
  basicstyle=\small\ttfamily,
  xleftmargin=18pt,
  captionpos=b,
  abovecaptionskip=12pt,
  numbers=left,
  numbersep=10pt,
  numberstyle=\small\color{darkgray}
}

\newenvironment{jsex}[2]
  {%
    \begin{lstlisting}
    \captionof{#2}
    \label{#1}
  }
  {%
    \end{lstlisting}
  }

\newenvironment{jsexspan}[2]
    {%
        \begin{js*}
        \caption{#2}
        \label{lst:#1}
        \begin{multicols}{2}
        \columnwidth 10in
        \small
    }
    {%
        \end{multicols}
        \end{js*}
    }

\newcommand{\dfn}{\emph}
\newcommand{\var}{\texttt}
\newcommand{\code}{\texttt}
\newcommand{\keyword}{\texttt}
\newcommand{\operator}{\texttt}
\newcommand{\func}{\texttt}

\hyphenation{ECMA-Script Java-Script}

