So I was assigned the task of creating a mobile version of the website I work for.
Luckily I came across this great starting point provided by the guys from nettuts.com
Check out the tutorial which includes javascript to detect the users browsers and the orientation of the iPhone to serve up the correct stylesheet for either portrait or landscape view.
http://net.tutsplus.com/misc/learn-how-to-develop-for-the-iphone/