In continued reading I found an extended Euclid's algorithm which returns the gcd and the multiplicative inverse, if one exists.
here is an article about it and an example implementation.
updated to fix register_globals off error
... and since you didn't provide an actual page for people to look at, here it is, for a temporary time, of course:
http://www.ultimatespin.com/e_art_example.php
thanks buzz, I'm still working on my site. It'll be in my articles area once the site is up.