How is this done?

I have started making my portfolio and Im trying to make a navigation similar to to the one at which is by the way one of the coolest little sites Ive ever seen!!

my problem is I dont know how they have made it.

I made my own but version of the navigation sysyem but its just one big if statement!! surely there is an easier way!

I would really appreciate any help on how to make the navigation system or a good tutorial so I can make a decent version of my own!

many thanks