Be prepared for a wait at immigration, there are often long queues and not enough officials. Trains from the airport to Cassa Voyagers station take 45 minutes, I think they run hourly, From Cassa Voyagers to Marrakech takes 3 hrs 15 Min's, and leaves every 2 hours. Should you miss the train there are plenty of tea shops in the area for relaxation and people watching.
You will find the timetable at
http://www.oncf.ma/En/horraires.aspx?ep=7&elt=26&CodeRD=0093&CodeGD=00200&CodeRA=0093&CodeGA=00110&heure=0000&date=23/05/2008
You will have plenty time to see Marrakech and visit the Atlas mountains, there are plenty agencies booking trips.
A very helpful website for travel questions is
http://www.virtualtourist.com/ you will find recommendations for what to see and where to stay all written by travellers.
Have a nice trip...