gotcha. can a locked one be unlocked by the bloke on the market or is it software stuff?
Yes / No
it can only be properly unlocked on all firmwares by the carrier as far as i'm aware.
However, you can get software unlocks which can be installed when you jailbrake it. These disappear as soon as you remove the jailbreak firmware however, and if you've got the latest firmware on your phone, the only jailbrake currently available for the latest firmware is a tethered one - ie one that means the jailbreak disappears every time you sync it with itunes
Contract Mobiles come locked to their Network, and the point at which the carrier will offer to unlock the phone varies. Vodafone for example, won't unlock till after your contract has run out.
O2 however, will unlock it mid contract. Think its 6 or 12 months or something.
If you buy the phone PAYG directly from Apple (New), it comes unlocked.
If somebody is selling a contract phone still locked to a network, dont buy it unless they can get their carrier to unlock it.
Sorry to go on so much, but in short, make life easier for yourself and make sure you buy an unlocked one. There are plenty around as O2 are quite happy to unlock after 6/12 months ish, and O2 had the monopoly on iphones for a long time.