Basically you have your main link that, when clicked on opens sub navigation under the main link.
It is really easy to create this using php. All you have to is pass a query string (or an in page variable) to the page you are loading. The nav checks to see what subnav to display - its that easy.
All you have to do is build your navigation complete with all the sub links. You enclose the sublinks in a simple if statement. So if you make your url page.php?linkid_1=1 then your if statement looks like this
if($linkid_1){your sublinks here}
Take a look at a demo page - there are no bells an whistles, just the bare bones so you can see how easy it is. It's up to you how you implement it on your site but the principle is basically the same.
If you don't want to pass a query string you can set the variable required on the page that's loaded. for example
<?$linkid_1=1;?>
as long as you place that before your navigation it will work.
As you can see it's really easy to see how it all works. What's more its really effective and only a few lines of php code.