  In this paper we discuss the issue of computation of the bilateral credit
valuation adjustment (CVA) under rating triggers, and in presence of
ratings-linked margin agreements. Specifically, we consider collateralized OTC
contracts, that are subject to rating triggers, between two parties -- an
investor and a counterparty. Moreover, we model the margin process as a
functional of the credit ratings of the counterparty and the investor. We
employ a Markovian approach for modeling of the rating transitions of the two
parties to the contract. In this framework, we derive the representation for
bilateral CVA. We also introduce a new component in the decomposition of the
counterparty risky price: namely the rating valuation adjustment (RVA) that
accounts for the rating triggers. We give two examples of dynamic
collateralization schemes where the margin thresholds are linked to the credit
ratings of the parties. We account for the rehypothecation risk in the presence
of independent amounts. Our results are illustrated via computation of various
counterparty risk adjustments for a CDS contract and for an IRS contract.
