It's called Lucid Dreaming, after having 5-6 hours of sleep you enter REM and at this point it is possible to lucid dream.
http://brain.web-us.com/lucid/luciddreamingFAQ.htm