Not sure about the php but I have a solution for your random pictures in css.
You could setup a tab on your home page which is called header and within that have a dataobject list of images. Then when you site loads it picks one of those images at random and loads that to a inline style in you site.
I have done something similar on a site I recently completed where the client is able to change he background image. I didn't use a list of images as they only need one background at time.
checkout the tutorial on relationships to work out how to get setup dataobjects with relation to a page.
As a tip you are going to want to use "new FileIFrameField" as the standard image upload won't work correctly in a popup. Well that has been my experience.