How to unlock brand new iphone 3gs?

A friend gave me his old iphone 3gs (he's with o2) and i just went to the apple store and payed to get it replaced as it's pretty smashed up. I have brought it home with my Vodaphone sim in, and it says 'your sim card is not compatible' and can't access the phone at all. Why? And how do i unlock it!
Any help appreciated, Many thanks x

Its illegal to now, sorry

Ask your friend about getting it unlocked, through O2.

@Benny: The unlock illegality concerns new phones bought in the US after January 26th

So what if its illegal? There won't be federals standing at your door the next day… Half the phones in the world are unlocked… Anyways just go to YouTube and look up how to unlock an iPhone 3GS.

Hi, read the manual and get right advice from the apple store. If not illegal! So long.

O2 need to unlock it
Although Apple replaced it, they replaced it with an identical profile - locked to O2 still.

Only your friend (the official owner) can get it unlocked from O2.
it take a few days, and then you put it on iTunes, and it gets updated to be 'unlocked'

http://service.o2.co.uk/IQ/SRVS/CGI-BIN/WEBCGI.EXE?New, Kb=Companion, question=ref(User):str(Mobile), CASE=17424 - unlocking on O2
(free if contract else 15 pounds)