The issues involved with generating random IDs have been discussed multiple times on this site. Check out
Randomizing Unique ID?, which is one of the more long winded threads. (My particular solution was
RE: RE: RE: Randomizing Unique ID? but you should really read the whole thread.)