\newif\ifPlain
\newif\ifLaTeX
\ifx\documentclass\undefined
  \Plaintrue \LaTeXfalse
  \input opmac
  \catcode`\@=11
\else
  \Plainfalse \LaTeXtrue
\fi
\let\ea\expandafter
\long\def\long@empty{}
\long\def\gobblepar#1\par{}
\ifPlain
  \let\@namedef\sdef
  \def\@nameuse#1{\csname#1\endcsname}
  \def\@empty{}
  \long\def\@firstofone#1{#1}
  \newlinechar10
  \def\Message#{\immediate\write16}
  \def\ProvidesClass#1[#2]{\Message{Document Class: #1 #2}}
  \def\ClassError#1#2#3{\Message{Class #1 Error:}%
    {\errorcontextlines0
    \edef\x{#3}\ea\errhelp\ea{\x}%
    \errmessage{#2}}}
  \def\DeclareOption#1#2{\sdef{#1}{#2}%
    \ea\@onlypreamble\csname#1\endcsname}
  \def\pagebreak{\par\vfil\break}
  \def\normalsize{\typobase}
  \def\large{\typobase\typoscale[1200/1200]}
  \def\Large{\typobase\typoscale[1440/1440]}
  \def\huge{\typobase\typoscale[2074/2074]}
  \def\normalfont{\rm}
  \font\sc=cscsc10 at12pt \regfont\sc
  \regfont\tensl
  \def\AtBeginDocument#1{\OP@addto\ABDqueue{#1}}
  \def\ABDqueue{}
  \def\begindocument{\ABDqueue}
  \def\@onlypreamble#1{\AtBeginDocument{\preamble@only#1}}
  \def\preamble@only#1{\def#1{\p@oerr#1}}
  \def\p@oerr#1{\JS@ClassError
    {V dokumentu nelze pouzit \string#1}
    {Makro \string#1 se pouziva pouze pred
      \string\begindocument.}}
  \def\@ifnextchar#1#2#3{\let\@tempe #1\def\@tempa:{#2}%
    \def\@tempb:{#3}\futurelet \@tempc\@ifnch}
  \def\@ifnch{\ifx \@tempc \@sptoken \let\@tempd\@xifnch
    \else \ifx \@tempc\@tempe \let\@tempd\@tempa
    \else \let\@tempd\@tempb
    \fi
    \fi \@tempd:}
  \futurelet\@sptoken{ } % toto taky vkládá space token
  \def\@xifnch: {\futurelet\@tempc\@ifnch}
\fi
\ifLaTeX
  \def\adef#1{\catcode`#1=13
    \begingroup \lccode`\~=`#1\lowercase{\endgroup\def~}}
  \let\testin\@inputcheck
  \def\chyph{\selectlanguage{czech}}
  \def\ehyph{\selectlanguage{english}}
\fi
\ifPlain
  \def\JS@pagestyleempty{\headline{\hss}\footline{\hss}}
\else
  \def\JS@pagestyleempty{\pagestyle{empty}}
\fi
\def\JS@begincenter{\begingroup
  \leftskip0ptplus1fil \rightskip\leftskip
  \parindent0pt \parfillskip0pt \hyphenpenalty10000
  \noindent}
\def\JS@endcenter{\par\endgroup}
\def\OP@addto#1#2{\ea\def\ea#1\ea{#1#2}}
\def\JS@ClassName{irp}
\ifLaTeX
  \NeedsTeXFormat{LaTeX2e}
\fi
\ProvidesClass{\JS@ClassName}[2016/03/11 v0.0^^JTrida
  pro sazbu zrcadlovych studijnich materialu.]
\def\JS@ClassError{\ClassError{\JS@ClassName}}
\newif\ifJS@czech
\newif\ifJS@english
\newif\ifJS@print
\JS@czechtrue \JS@englishtrue \JS@printtrue
\DeclareOption{czech}{\JS@englishfalse}
\DeclareOption{english}{\JS@czechfalse}
\DeclareOption{print}{\JS@printtrue}
\DeclareOption{screen}{\JS@printfalse}
\ifPlain
  \DeclareOption{final}{\overfullrule=0pt}
\fi
\ifLaTeX
  \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
  \PassOptionsToClass{12pt}{article}
  \ProcessOptions
\fi
\def\choice#1#2{\ifJS@print#1\else#2\fi}
\ifPlain
  \def\emph#1{\ifJS@print{\sl#1}\else{\localcolor\Blue#1}\fi}
\else
  \RequirePackage{color}
  \def\emph#1{\ifJS@print{\textsl{#1}}\else{\color{blue}#1}\fi}
\fi
\ifPlain
  \def\nastavformatstrany{\ifJS@print
      \margins/1 a4 (25,25,25,25)mm
    \else
      \margins/1 a5l (1,1,1,1)cm
    \fi
    \typosize[12/14]}
  \AtBeginDocument\nastavformatstrany
\else
  \LoadClass[12pt]{article}
  \ifJS@print
    \RequirePackage[a4paper,margin=25mm]{geometry}
  \else
    \RequirePackage[a5paper,landscape,margin=1cm,bottom=15mm]{geometry}
  \fi
\fi
\ifPlain
  \AtBeginDocument{\ifJS@czech\chyph\fi
    \ifJS@english\ehyph\fi}
\else
  \RequirePackage[czech,english]{babel}
  \ifJS@czech\chyph\fi
  \ifJS@english\ehyph\fi
\fi
\def\chapter#1#2{\pagebreak
  \ifPlain
    \global\advance\chapternum1
    \wlabel{\the\chapternum}
  \else
    \refstepcounter{chapter}
  \fi
  \nadpiskapitoly{#1}{#2}
  \bigskip
  \begingroup
  \everypar{\zacatekodstavce}
  \parskip6pt plus6pt
  \parindent0pt}
\def\endchapter{\vysazej
  \endgroup}
\def\vysazej{\ifJS@czech\ifJS@english
    \ifJS@print
      \CEPvysazej
    \else
      \CEpvysazej
    \fi
  \fi\fi}
\ifPlain
  \newcount\chapternum
  \def\thechapternum{\the\chapternum}
  \def\fontnadpisukapitoly{\typoscale[1440/1440]\bf}
  \def\fontnadpisupodkapitoly{\typoscale[1200/1200]\bf}
\else
  \newcounter{chapter}
  \def\thechapternum{\arabic{chapter}}
  \def\fontnadpisukapitoly{\Large\bf}
  \def\fontnadpisupodkapitoly{\large\bf}
\fi
\def\subchapter{\vysazej
  \par\quitvmode\nadpispodkapitoly}
\def\nastavverzi{
  \ifJS@czech % czech=true
    \ifJS@english % czech=true, english=true
      \ifJS@print % czech=true, english=true, print=true
        \nastavverziCEP
      \else % czech=true, english=true, print=false
        \nastavverziCEp
      \fi
    \else % czech=true, english=false
      \nastavverziCe
    \fi
  \else % czech=false
    \ifJS@english % czech=false, english=true
      \nastavverzicE
    \else % czech=false, english=false
      \nastavverzice
    \fi
  \fi}
\AtBeginDocument\nastavverzi
\def\nastavverziCEP{
  \def\CZ{{\ifPlain\localcolor\Red\fi(CZ)}}
  \def\EN{{\ifPlain\localcolor\Red\fi(EN)}}
  \let\CEPvysazej\relax
  \def\CEPnadpiskapitoly##1##2{(##1)(##2)}
  \let\nadpiskapitoly\CEPnadpiskapitoly
  \def\zacatekodstavce{}}
\def\nastavverziCEP{
  \let\CZ\CEpCZ
  \let\EN\CEpEN
  \let\zacatekodstavce\CEpzacatekodstavce
  \let\nadpiskapitoly\CEpnadpiskapitoly
  \let\nadpispodkapitoly\CEpnadpispodkapitoly
  \let\CEPvysazej\CEpvysazej
  \let\CEpvysazejA\CEPvysazejA}
\pdfpageresources{/ExtGState <</tmavsi
  << /Type /ExtGState /BM /Multiply >> >>}
\def\CEPvysazejA{\par\vskip\parskip
  \hbox to\hsize{\everypar{}%
    \parskip0pt
    \pdfliteral{/tmavsi gs}%
    \vtop{\noindent\ifx\textodstavceEN\prazdnytext\else
      \ehyph\ENfont
      \localcolor\setcmykcolor{0 0.5 0 0}\textodstavceEN\fi}\hfil
    \hskip-\hsize
    \vtop{\noindent\ifx\textodstavceCZ\prazdnytext\else
      \chyph\CZfont
      \localcolor\setcmykcolor{0.5 0 0 0}\textodstavceCZ\fi}}\par
  \let\textodstavceEN\prazdnytext
  \let\textodstavceCZ\prazdnytext}
\def\nastavverziCEp{
  \let\CZ\CEpCZ
  \let\EN\CEpEN
  \let\zacatekodstavce\CEpzacatekodstavce
  \let\nadpiskapitoly\CEpnadpiskapitoly
  \let\nadpispodkapitoly\CEpnadpispodkapitoly}
\def\prazdnytext{}
\let\textodstavceCZ\prazdnytext
\let\textodstavceEN\prazdnytext
\long\def\CEpCZ#1\par{
  \ifx\textodstavceCZ\prazdnytext
    \def\textodstavceCZ{#1}
    \ifx\textodstavceEN\prazdnytext\else
      \CEpvysazej
    \fi
  \else
    \CEpvysazej
    \def\textodstavceCZ{#1}
  \fi}
\long\def\CEpEN#1\par{
  \ifx\textodstavceEN\prazdnytext
    \def\textodstavceEN{#1}
    \ifx\textodstavceCZ\prazdnytext\else
      \CEpvysazej
    \fi
  \else
    \CEpvysazej
    \def\textodstavceEN{#1}
  \fi}
\def\CEpzacatekodstavce#1\par
  {\CEpvysazej
  {\everypar{}#1\par}}
\def\CEpvysazej{\ifx\textodstavceEN\prazdnytext
    \ifx\textodstavceCZ\prazdnytext
    \else
      \CEpvysazejA
    \fi
  \else
    \CEpvysazejA
  \fi}
\def\CEpvysazejA{\par\vskip\parskip
  \hbox to\hsize{\everypar{}%
    \parskip0pt
    \hsize0.47\hsize
    \vtop{\noindent\ifx\textodstavceEN\prazdnytext\else
      \ehyph\ENfont\textodstavceEN\fi}\hfil
    \vtop{\noindent\ifx\textodstavceCZ\prazdnytext\else
      \chyph\CZfont\textodstavceCZ\fi}}\par
  \let\textodstavceEN\prazdnytext
  \let\textodstavceCZ\prazdnytext}
\def\CEpnadpiskapitoly#1#2{\hbox to\hsize{%
    \fontnadpisukapitoly
    \hsize0.45\hsize \parfillskip0pt
    \vtop{\leftskip0ptplus\hsize\noindent\ehyph#1}%
    \hss\thechapternum\hss
    \vtop{\rightskip0ptplus\hsize\noindent\chyph#2}%
  }}
\def\CEpnadpispodkapitoly#1#2{\hbox to\hsize{%
    \fontnadpisupodkapitoly
    \hsize0.45\hsize \parfillskip0pt
    \vtop{\leftskip0ptplus\hsize\noindent\ehyph#1}%
    \hss
    \vtop{\rightskip0ptplus\hsize\noindent\chyph#2}%
  }}
\def\nastavverziCe{
  \let\CZ\relax
  \let\EN\gobblepar
  \def\zacatekodstavce{}
  \let\nadpiskapitoly\Cenadpiskapitoly
  \let\nadpispodkapitoly\Cenadpispodkapitoly}
\def\Cenadpiskapitoly#1#2{{\fontnadpisukapitoly
  \leftskip2em
  \noindent\llap{\hbox to2em{\thechapternum\hss}}%
  \chyph#2\par}}
\def\Cenadpispodkapitoly#1#2{{\fontnadpisupodkapitoly
  \leftskip2em
  \noindent
  \chyph#2\par}}
\def\nastavverzicE{
  \let\CZ\gobblepar
  \let\EN\relax
  \def\zacatekodstavce{}
  \let\nadpiskapitoly\cEnadpiskapitoly
  \let\nadpispodkapitoly\cEnadpispodkapitoly}
\def\cEnadpiskapitoly#1#2{{\fontnadpisukapitoly
  \leftskip2em
  \noindent\llap{\hbox to2em{\thechapternum\hss}}%
  \ehyph#1\par}}
\def\cEnadpispodkapitoly#1#2{{\fontnadpisupodkapitoly
  \leftskip2em
  \noindent
  \ehyph#1\par}}
\def\nastavverzice{
    \this@cant@happen}
\gdef\implicitnifont{\rm}
\let\ENfont\implicitnifont
\let\CZfont\implicitnifont
\ifLaTeX
  \def\noveprostredi#1#2#3#4#5{
    \newcounter{#1}
    \@namedef{#1}{\refstepcounter{#1}%
      {\bf#2~\arabic{#1}}
      \gdef\ENfont{#5}\ENfont}
    \@namedef{end#1}{\global\let\ENfont\implicitnifont
      \ENfont}
    \newcounter{#3}
    \@namedef{#3}{\refstepcounter{#3}%
      {\bf#4~\arabic{#3}}
      \gdef\CZfont{#5}\CZfont}
    \@namedef{end#3}{\global\let\CZfont\implicitnifont
      \CZfont}
    }
\else
  \def\noveprostredi#1#2#3#4#5{
    \csname newcount\expandafter\endcsname\csname c@#1\endcsname
    \@namedef{#1}{\global\expandafter\advance\csname c@#1\endcsname1
      \wlabel{\expandafter\the\csname c@#1\endcsname}%
      {\bf#2~\expandafter\the\csname c@#1\endcsname}
      \gdef\ENfont{#5}\ENfont}
    \@namedef{end#1}{\global\let\ENfont\implicitnifont
      \ENfont}
    \csname newcount\expandafter\endcsname\csname c@#3\endcsname
    \@namedef{#3}{\global\expandafter\advance\csname c@#3\endcsname1
      \wlabel{\expandafter\the\csname c@#3\endcsname}%
      {\bf#4~\expandafter\the\csname c@#3\endcsname}
      \gdef\CZfont{#5}\CZfont}
    \@namedef{end#3}{\global\let\CZfont\implicitnifont
      \CZfont}
    }
\fi
\noveprostredi{theorem}{Theorem}{veta}{V\v eta}{\sl}
\noveprostredi{example}{Example}{priklad}{P\v r\'\i klad}{\rm}
\noveprostredi{exercise}{Exercise}{cviceni}{Cvi\v cen\'\i}{\rm}
\noveprostredi{definition}{Definition}{definice}{Definice}{\rm}
\ifPlain
  \let\ori@begtt\begtt
  \def\begtt{\vysazej\ori@begtt}
\fi
\ifPlain
  \catcode`\@=12
\fi
