as Ron points out, X10 is the way to go for automation. I'm a big fan of building versus buying, but when it comes to stuff that needs to be reliable or could be dangerous if it fails, then I often look to commercial products. controlling line voltage lights and appliances with 'logic' is not difficult, but it can be dangerous, and the parts to do it safely cost more than pre-built commercial products.
the X10.com website is kinda trashy, advertising spy cameras and bikini wearing models, but their products are pretty good. Smarthome.com is higher end stuff, and I'm sure google will list other purveyors of x10 related goods.
lets take your bathroom example:
1) place an "eagle eye" PIR sensor somewhere so it can see the door, but is not triggered by people passing by the outside of the door.
2) replace the light switch with a "wall switch module", or use a "socket rocket" which installs between the bulb socket and the bulb.
3) set the PIR's unit code to correspond with your switch's control code, and set the PIRs off-delay time to something reasonable, usually 2-5 min.
that's it!
person walks into the bathroom, PIR detects motion and sends a ON command using its unit code (which is the same as your switch) and the lights come on. After no motion is detected for the off-delay, the PIR sends an OFF command using its unit code, and the lights turn off.
if you wanted to be fancy, you could involve a computer, running sensors on one house code (house codes a-m, units 1-16). PIR sends an ON command, computer reads this and sends a DIM command to the light module (or other proprietary command) so it lights up at something other than full power. problem here is most light modules won't "start" at anything but full power, so it's something to play around with. one suggestion, using the computer you can do time of day based event handling. if it's after midnight, turn on a nightlight, if it's during waking hours, turn on the main lights.
alternately, forget x10 and just invest in some electroluminescent night lights. I've got some that take 0.07 watts ... it costs me roughly 10 cents/year to run each one. Only bad thing is, they hog an outlet that would otherwise serve a hair drier, razor, etc.