You're better off just writing dynamic width sites and avoiding all that detection. Where handheld devices are concerned you probably don't have a choice.