There are two flow charts over at d20pfsrd.com:
Chart 1
Chart 2
Keep in mind that if you get hit by an AoO while initiating the Grapple, you take the damage as penalty to your CMB-Roll. Also, both parties gain the "Grappled" Condition and thus all associated penalties.
The Grappler also gets a +5 Bonus on all Grapple-Checks he makes.