\RequirePackage{xspace} 
%
\RequirePackage{color}
\definecolor{nocolor}{gray}{1}
\definecolor{Grythrty}{gray}{.7}
\definecolor{Gryten}{gray}{.8}
\definecolor{Black}{gray}{0}

\def\chpcolor{blue!45}
\def\chpcolortxt{blue!60}

\def\nocolor{\color{nocolor}}
\def\Grythrty{\color{Grythrty}}
\def\Gryten{\color{Gryten}}
\def\Black{\color{Black}}
%


% change margin:================================================
\newenvironment{changemargin}[2]{
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}

\newcommand{\sectionfont}{\normalfont\Large\bfseries}
\newcommand{\subsectionfont}{\normalfont\large\bfseries}
\newcommand{\subsubsectionfont}{\normalfont\large\bfseries}
\newcommand{\paragraphfont}{\normalfont}

\renewcommand\chaptermark[1]{}
\setcounter{secnumdepth}{3}
 
 %357
%\@startsection{<type>}{<level>}{<indent>}{<beforeskip>}{<afterskip>}{<style>}
\renewcommand\@chapapp{\chaptername}
\renewcommand\section{\@startsection {section}{1}{-64pt}%{<type>}{<level>}{<indent>}
                                   {-24pt \@plus -6pt \@minus -3pt}%{<beforeskip>}
                                   {12pt}% {<afterskip>}
                                   {\sectionfont}}%{<style>}
\renewcommand\subsection{\@startsection{subsection}{2}{-64pt}
                                     {-12pt \@plus -6pt \@minus -3pt}%
                                     {6pt}% 
                                     {\subsectionfont}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{-64pt}
                                     {-12pt \@plus -1pt \@minus -.2pt}%
                                     {6pt}% 
                                     {\subsubsectionfont}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{-64pt}%
                                    {-6pt \@plus2pt}%
                                    {0.001pt}%
                                    {\paragraphfont}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1pc}%
                                      {\reset@font\normalsize\bfseries}}
%

%  Chapter Title  %%%%%%%%%%%%%%%%%%%%%%%%%%
%
\long\def\chapter{\clearpage%\@chapteropentrue
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\long\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}
                    \fi
                    \chaptermark{#1}%
                      \@makechapterhead{#2}%
                      \@afterheading
                    }
\def\@makechapterhead#1{%
	{  \parindent \z@ \raggedleft \huge
	\parbox[c][22pt][c]{90pt}{\color{\chpcolortxt}  \hfill 
		\colorbox{\chpcolor} { \parbox[c][42pt][c]{20pt}{ \color{white} \thechapter}}
	}\hspace*{5pt}
	\begin{minipage}[b][48pt][t]{\textwidth}
  		\vspace{33pt}
  		\color{\chpcolortxt} #1
  		\par\vfill\vspace*{-6pt}
  		\noindent\color{\chpcolortxt}%
  		\rule{\textwidth}{2pt}
	\end{minipage}
 	}
}
%\def\@schapter#1{\if@twocolumn \@topnewpage[\@makeschapterhead{#1}]
% \else \@makeschapterhead{#1}
% \chaptermark{#1}
% \@afterheading\fi}

%Section: ---------------------------------------------------------------------------------
\def\@makesectionhead#1{ 
	{ \vspace{20pt}
	\parindent 0pt \raggedleft \sectionfont 
%	\colorbox{blue!50}{\hspace*{15pt}
%	\color{white} \thesection } \hspace*{5pt}
	\colorbox{\chpcolor} { \parbox[c][17pt][c]{90pt}{\color{white} \hfill \thesection }}
	\hspace*{5pt}
	\vspace{10pt}
	\begin{minipage}[c][17pt][c]{\textwidth}
		\color{\chpcolortxt} #1
	\end{minipage}
	}
 }
\def\section{\@afterindentfalse \secdef\@section\@ssection}
\def\@section[#1]#2{\ifnum \c@secnumdepth >\m@ne
 \refstepcounter{section}
 \addcontentsline{toc}{section}{\protect
 \numberline{\thesection}#1}\else
 \addcontentsline{toc}{section}{#1}\fi
 \sectionmark{#1}
 \if@twocolumn\@topnewpage[\@makesectionhead{#2}]
 \else \@makesectionhead{#2}\@afterheading \fi}
%\def\@ssection#1{\if@twocolumn \@topnewpage[\@makessectionhead{#1}]
% \else \@makessectionhead{#1}\@afterheading\fi}



%SubSection: ---------------------------------------------------------------------------------
\def\@makesubsectionhead#1{ 
	{ \vspace{17pt}
	\parindent 0pt \raggedleft \subsectionfont 
	\parbox[c][17pt][c]{60pt}{\color{\chpcolortxt} \hfill \thesubsection }
	\hspace*{5pt}
	\vspace{10pt}
	\begin{minipage}[c][17pt][c]{\textwidth}
		\color{\chpcolortxt} #1
	\end{minipage}
	}
 }
%\def\@makessubsectionhead#1{ \vsecspace{16pt} { \parindent 0pt \raggedright
% \small\rm \uppercase{#1}\par
% \nobreak \vskip 8pt} }

\def\subsection{\@afterindentfalse \secdef\@subsection\@ssubsection}
\def\@subsection[#1]#2{\ifnum \c@secnumdepth >\m@ne
 \refstepcounter{subsection}
 \addcontentsline{toc}{subsection}{\protect
 \numberline{\thesubsection}#1}\else
 \addcontentsline{toc}{subsection}{#1}\fi
 \if@twocolumn\@topnewpage[\@makesubsectionhead{#2}]
 \else \@makesubsectionhead{#2}\@afterheading \fi}
%\def\@ssubsection#1{\if@twocolumn \@topnewpage[\@makessubsectionhead{#1}]
% \else \@makessubsectionhead{#1}\@afterheading\fi}



%Paragraph: ---------------------------------------------------------------------------------
\def\partitle{{\normalsize\it}}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  End Chapter Title  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%