Well you are in luck. There is a prewritten library of I2C functions that comes with the compiler. They are documented in the following link:
http://ww1.microchip.com/downloads/e...ies_51297d.pdf
Also, source code for all of these functions can be found in the C18 install directory assuming you selected it when you installed C18.