You can only buy online if you have a billing and a shipping address in the USA. Apple online stores are country specific, and Apple USA does not ship outside of the USA.
Also, if you want an unlocked iPhone, you must specifically buy an unlocked one, as not all those available from the online store are unlocked. You must specifically choose the unlocked model.
Note too that the new iPhone 5 GSM only phone comes in two versions, differing in the LTE data channels they support. The non-USA specific LTE version will likely not even be sold in the USA, so you need to check which LTE frequencies the provider you plan to use offers, and make sure you are getting the model best suited for your carrier.