you can't unlock the iphone 3g
you will need to buy a turbosim type hack, and theres no guarantee these will always work
also, why not buy it then cancel the contract and pay an early termination fee, or whatever your country uses as each is different