To detect WAP, I'm *guessing* you could use respond_to, like:
respond_to do |format| format.html ... format.wml ... end
You may need WML to be registered first in your environment.rb:
Mime::Type.register "text/vnd.wap.wml", :wml
As far as a "javascript equivalent" in WAP... no idea there, good
luck
- Tyler